Skip to content

Commit

Permalink
Updates codegen scripts from hack
Browse files Browse the repository at this point in the history
With the update of k8s dependencies, most of the codegen commands
changed (different flags, …), so this is adapting them.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Jan 28, 2025
1 parent 61eb52d commit 2092e23
Show file tree
Hide file tree
Showing 64 changed files with 617 additions and 2,993 deletions.
14 changes: 7 additions & 7 deletions hack/generate-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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.

Expand All @@ -40,6 +39,7 @@ fi

GENS="$1"
OUTPUT_PKG="$2"
OUTPUT_PATH=".${OUTPUT_PKG#github.com/tektoncd/pipeline}"
APIS_PKG="$3"
GROUPS_WITH_VERSIONS="$4"
shift 4
Expand Down Expand Up @@ -68,25 +68,25 @@ 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}" "$@"
"${PREFIX}/deepcopy-gen" --output-file zz_generated.deepcopy.go --bounding-dirs "${APIS_PKG}" "$@" $(codegen::join " " "${FQ_APIS[@]}")
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}" "$@"
"${PREFIX}/client-gen" --clientset-name "${CLIENTSET_NAME_VERSIONED:-versioned}" --input-base "" --input "$(codegen::join , "${FQ_APIS[@]}")" --output-pkg "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" --output-dir "${OUTPUT_PATH}/${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" "$@"
"${PREFIX}/lister-gen" --output-pkg "${OUTPUT_PKG}/listers" --output-dir "${OUTPUT_PATH}/listers" "$@" $(codegen::join " " "${FQ_APIS[@]}")
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" \
"$@"
--output-pkg "${OUTPUT_PKG}/informers" \
--output-dir "${OUTPUT_PATH}/informers" \
"$@" $(codegen::join " " "${FQ_APIS[@]}")
fi
22 changes: 11 additions & 11 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,37 @@ bash ${REPO_ROOT_DIR}/hack/generate-groups.sh "deepcopy,client,informer,lister"
github.com/tektoncd/pipeline/pkg/client github.com/tektoncd/pipeline/pkg/apis \
"pipeline:v1alpha1,v1beta1,v1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt
# This generates deepcopy,client,informer and lister for the resolution package (v1alpha1)
# This generates deepcopy,client,informer and lister for the resolution package (v1alpha1, v1beta1)
bash ${REPO_ROOT_DIR}/hack/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/tektoncd/pipeline/pkg/client/resolution github.com/tektoncd/pipeline/pkg/apis \
"resolution:v1alpha1,v1beta1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# Depends on generate-groups.sh to install bin/deepcopy-gen
${PREFIX}/deepcopy-gen \
-O zz_generated.deepcopy \
--output-file zz_generated.deepcopy.go \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
-i github.com/tektoncd/pipeline/pkg/apis/config
github.com/tektoncd/pipeline/pkg/apis/config

${PREFIX}/deepcopy-gen \
-O zz_generated.deepcopy \
--output-file zz_generated.deepcopy.go \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
-i github.com/tektoncd/pipeline/pkg/spire/config
github.com/tektoncd/pipeline/pkg/spire/config

${PREFIX}/deepcopy-gen \
-O zz_generated.deepcopy \
--output-file zz_generated.deepcopy.go \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
-i github.com/tektoncd/pipeline/pkg/apis/config/resolver
github.com/tektoncd/pipeline/pkg/apis/config/resolver

${PREFIX}/deepcopy-gen \
-O zz_generated.deepcopy \
--output-file zz_generated.deepcopy.go \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
-i github.com/tektoncd/pipeline/pkg/apis/pipeline/pod
github.com/tektoncd/pipeline/pkg/apis/pipeline/pod

${PREFIX}/deepcopy-gen \
-O zz_generated.deepcopy \
--output-file zz_generated.deepcopy.go \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
-i github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1
github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1

# Knative Injection

Expand Down
15 changes: 9 additions & 6 deletions hack/update-openapigen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ trap cleanup EXIT

for APIVERSION in "v1alpha1" "v1beta1" "v1"
do
input_dirs=./pkg/apis/pipeline/${APIVERSION},./pkg/apis/pipeline/pod,knative.dev/pkg/apis,knative.dev/pkg/apis/duck/v1beta1
input_dirs="./pkg/apis/pipeline/${APIVERSION} ./pkg/apis/pipeline/pod knative.dev/pkg/apis knative.dev/pkg/apis/duck/v1beta1"
if [ ${APIVERSION} = "v1beta1" ]
then
input_dirs=${input_dirs},./pkg/apis/resolution/v1beta1
input_dirs="${input_dirs} ./pkg/apis/resolution/v1beta1"
fi

set -x

echo "Generating OpenAPI specification for ${APIVERSION} ..."
go run k8s.io/kube-openapi/cmd/openapi-gen \
--input-dirs ${input_dirs} \
--output-package ./pkg/apis/pipeline/${APIVERSION} -o ./ \
GOFLAGS="-mod=mod" go run k8s.io/kube-openapi/cmd/openapi-gen \
--output-pkg github.com/tektoncd/pipeline/pkg/apis/pipeline/${APIVERSION} \
--output-dir ./pkg/apis/pipeline/${APIVERSION} \
--output-file openapi_generated.go \
--go-header-file hack/boilerplate/boilerplate.go.txt \
-r "${TMP_DIFFROOT}/api-report"
-r "${TMP_DIFFROOT}/api-report" ${input_dirs}

violations=$(diff --changed-group-format='%>' --unchanged-group-format='' <(sort "hack/ignored-openapi-violations.list") <(sort "${TMP_DIFFROOT}/api-report") || echo "")
if [ -n "${violations}" ]; then
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1beta1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pkg/client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2092e23

Please sign in to comment.