-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
- Loading branch information
1 parent
64da7c5
commit 460bcb2
Showing
267 changed files
with
79,109 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gopath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Copyright 2023 The OpenShift Pipelines Authors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2017 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
|
||
# generate-groups generates everything for a project with external types only, e.g. a project based | ||
# on CustomResourceDefinitions. | ||
|
||
if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then | ||
cat <<EOF | ||
Usage: $(basename "$0") <generators> <output-package> <apis-package> <groups-versions> ... | ||
<generators> the generators comma separated to run (deepcopy,defaulter,client,lister,informer) or "all". | ||
<output-package> the output package name (e.g. github.com/example/project/pkg/generated). | ||
<apis-package> the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis). | ||
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative | ||
to <api-package>. | ||
... arbitrary flags passed to all generator binaries. | ||
Examples: | ||
$(basename "$0") all github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" | ||
$(basename "$0") deepcopy,client github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" | ||
EOF | ||
exit 0 | ||
fi | ||
|
||
GENS="$1" | ||
OUTPUT_PKG="$2" | ||
APIS_PKG="$3" | ||
GROUPS_WITH_VERSIONS="$4" | ||
shift 4 | ||
|
||
( | ||
# To support running this script from anywhere, we have to first cd into this directory | ||
# so we can install the tools. | ||
cd "$(dirname "${0}")" | ||
go install k8s.io/code-generator/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen} | ||
) | ||
|
||
set -x | ||
|
||
PREFIX=${GOBIN:-${GOPATH}/bin} | ||
|
||
function codegen::join() { local IFS="$1"; shift; echo "$*"; } | ||
|
||
# enumerate group versions | ||
FQ_APIS=() # e.g. k8s.io/api/apps/v1 | ||
for GVs in ${GROUPS_WITH_VERSIONS}; do | ||
IFS=: read -r G Vs <<<"${GVs}" | ||
|
||
# enumerate versions | ||
for V in ${Vs//,/ }; do | ||
FQ_APIS+=("${APIS_PKG}/${G}/${V}") | ||
done | ||
done | ||
|
||
if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then | ||
echo "Generating deepcopy funcs for ${GROUPS_WITH_VERSIONS}" | ||
"${PREFIX}/deepcopy-gen" --input-dirs "$(codegen::join , "${FQ_APIS[@]}")" -O zz_generated.deepcopy --bounding-dirs "${APIS_PKG}" "$@" | ||
fi | ||
|
||
if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then | ||
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" | ||
"${PREFIX}/client-gen" --clientset-name "${CLIENTSET_NAME_VERSIONED:-versioned}" --input-base "" --input "$(codegen::join , "${FQ_APIS[@]}")" --output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" "$@" | ||
fi | ||
|
||
if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then | ||
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers" | ||
"${PREFIX}/lister-gen" --input-dirs "$(codegen::join , "${FQ_APIS[@]}")" --output-package "${OUTPUT_PKG}/listers" "$@" | ||
fi | ||
|
||
if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then | ||
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers" | ||
"${PREFIX}/informer-gen" \ | ||
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \ | ||
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}/${CLIENTSET_NAME_VERSIONED:-versioned}" \ | ||
--listers-package "${OUTPUT_PKG}/listers" \ | ||
--output-package "${OUTPUT_PKG}/informers" \ | ||
"$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2019 The Knative Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# generate-groups generates everything for a project with external types only, e.g. a project based | ||
# on CustomResourceDefinitions. | ||
|
||
if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then | ||
cat <<EOF | ||
Usage: $(basename $0) <generators> <client-package> <apis-package> <groups-versions> ... | ||
<generators> the generators comma separated to run (deepcopy,defaulter,client,lister,informer) or "all". | ||
<client-package> the client package dir (e.g. github.com/example/project/pkg/clientset). | ||
<apis-package> the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis). | ||
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative | ||
to <api-package>. | ||
... arbitrary flags passed to all generator binaries. | ||
Examples: | ||
$(basename $0) all github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" | ||
$(basename $0) injection,foo github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" | ||
EOF | ||
exit 0 | ||
fi | ||
|
||
GENS="$1" | ||
CLIENT_PKG="$2" | ||
APIS_PKG="$3" | ||
GROUPS_WITH_VERSIONS="$4" | ||
shift 4 | ||
|
||
( | ||
# To support running this script from anywhere, we have to first cd into this directory | ||
# so we can install the tools. | ||
cd $(dirname "${0}") | ||
go install knative.dev/pkg/codegen/cmd/injection-gen | ||
) | ||
|
||
PREFIX=${GOBIN:-${GOPATH}/bin} | ||
|
||
function codegen::join() { local IFS="$1"; shift; echo "$*"; } | ||
|
||
# enumerate group versions | ||
FQ_APIS=() # e.g. k8s.io/api/apps/v1 | ||
for GVs in ${GROUPS_WITH_VERSIONS}; do | ||
IFS=: read G Vs <<<"${GVs}" | ||
|
||
# enumerate versions | ||
for V in ${Vs//,/ }; do | ||
FQ_APIS+=(${APIS_PKG}/${G}/${V}) | ||
done | ||
done | ||
|
||
|
||
if grep -qw "injection" <<<"${GENS}"; then | ||
if [[ -z "${OUTPUT_PKG:-}" ]]; then | ||
OUTPUT_PKG="${CLIENT_PKG}/injection" | ||
fi | ||
|
||
if [[ -z "${VERSIONED_CLIENTSET_PKG:-}" ]]; then | ||
VERSIONED_CLIENTSET_PKG="${CLIENT_PKG}/clientset/versioned" | ||
fi | ||
|
||
if [[ -z "${EXTERNAL_INFORMER_PKG:-}" ]]; then | ||
EXTERNAL_INFORMER_PKG="${CLIENT_PKG}/informers/externalversions" | ||
fi | ||
|
||
if [[ -z "${LISTERS_PKG:-}" ]]; then | ||
LISTERS_PKG="${CLIENT_PKG}/listers" | ||
fi | ||
|
||
echo "Generating injection for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}" | ||
|
||
# Clear old injection | ||
rm -rf ${OUTPUT_PKG} | ||
|
||
${PREFIX}/injection-gen \ | ||
--input-dirs $(codegen::join , "${FQ_APIS[@]}") \ | ||
--versioned-clientset-package ${VERSIONED_CLIENTSET_PKG} \ | ||
--external-versions-informers-package ${EXTERNAL_INFORMER_PKG} \ | ||
--listers-package ${LISTERS_PKG} \ | ||
--output-package ${OUTPUT_PKG} \ | ||
"$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
# Conditionally create a temporary GOPATH for codegen | ||
# and openapigen to execute in. This is only done if | ||
# the current repo directory is not within GOPATH. | ||
function shim_gopath() { | ||
local REPO_DIR=$(git rev-parse --show-toplevel) | ||
local TEMP_GOPATH="${REPO_DIR}/.gopath" | ||
local TEMP_TEKTONCD="${TEMP_GOPATH}/src/github.com/openshift-pipelines" | ||
local TEMP_OPERATOR="${TEMP_TEKTONCD}/operator" | ||
local NEEDS_MOVE=1 | ||
|
||
# Checks if GOPATH exists without triggering nounset panic. | ||
EXISTING_GOPATH=${GOPATH:-} | ||
|
||
# Check if repo is in GOPATH already and return early if so. | ||
# Unfortunately this doesn't respect a repo that's symlinked into | ||
# GOPATH and will create a temporary anyway. I couldn't figure out | ||
# a way to get the absolute path to the symlinked repo root. | ||
if [ ! -z $EXISTING_GOPATH ] ; then | ||
case $REPO_DIR/ in | ||
$EXISTING_GOPATH/*) NEEDS_MOVE=0;; | ||
*) NEEDS_MOVE=1;; | ||
esac | ||
fi | ||
|
||
if [ $NEEDS_MOVE -eq 0 ]; then | ||
return | ||
fi | ||
|
||
echo "You appear to be running from outside of GOPATH." | ||
echo "This script will create a temporary GOPATH at $TEMP_GOPATH for code generation." | ||
|
||
# Ensure that the temporary pipelines symlink doesn't exist | ||
# before proceeding. | ||
delete_pipeline_repo_symlink | ||
|
||
mkdir -p "$TEMP_TEKTONCD" | ||
# This will create a symlink from | ||
# (repo-root)/.gopath/src/github.com/tektoncd/operator | ||
# to the user's pipeline checkout. | ||
ln -s "$REPO_DIR" "$TEMP_TEKTONCD" | ||
echo "Moving to $TEMP_OPERATOR" | ||
cd "$TEMP_OPERATOR" | ||
export GOPATH="$TEMP_GOPATH" | ||
} | ||
|
||
# Helper that wraps deleting the temp pipelines repo symlink | ||
# and prints a message about deleting the temp GOPATH. | ||
# | ||
# Why doesn't this func just delete the temp GOPATH outright? | ||
# Because it might be reused across multiple hack scripts and many | ||
# packages seem to be installed into GOPATH with read-only | ||
# permissions, requiring sudo to delete the directory. Rather | ||
# than surprise the dev with a password entry at the end of the | ||
# script's execution we just print a message to let them know. | ||
function shim_gopath_clean() { | ||
local REPO_DIR=$(git rev-parse --show-toplevel) | ||
local TEMP_GOPATH="${REPO_DIR}/.gopath" | ||
if [ -d "$TEMP_GOPATH" ] ; then | ||
# Put the user back at the root of the pipelines repo | ||
# after all the symlink shenanigans. | ||
echo "Moving to $REPO_DIR" | ||
cd "$REPO_DIR" | ||
delete_pipeline_repo_symlink | ||
echo "When you are finished with codegen you can safely run the following:" | ||
echo "sudo rm -rf \".gopath\"" | ||
fi | ||
} | ||
|
||
# Delete the temp symlink to pipelines repo from the temp GOPATH dir. | ||
function delete_pipeline_repo_symlink() { | ||
local REPO_DIR=$(git rev-parse --show-toplevel) | ||
local TEMP_GOPATH="${REPO_DIR}/.gopath" | ||
if [ -d "$TEMP_GOPATH" ] ; then | ||
local REPO_SYMLINK="${TEMP_GOPATH}/src/github.com/tektoncd/pipeline" | ||
if [ -L $REPO_SYMLINK ] ; then | ||
echo "Deleting symlink to pipelines repo $REPO_SYMLINK" | ||
rm -f "${REPO_SYMLINK}" | ||
fi | ||
fi | ||
} |
Oops, something went wrong.