From a78983906f4cf6f94029a3e6cf3171ef42b395d7 Mon Sep 17 00:00:00 2001 From: Madhav Bhargava Date: Wed, 22 Jan 2025 13:34:36 +0530 Subject: [PATCH] Adding support for providing version for functions in kube_codegen.sh (#129658) * adding support for providing version for functions in kube_codegen.sh * addressed review comments * addressed review comments --- .../src/k8s.io/code-generator/kube_codegen.sh | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/staging/src/k8s.io/code-generator/kube_codegen.sh b/staging/src/k8s.io/code-generator/kube_codegen.sh index 6b2ba321e63..f9778bde6c1 100755 --- a/staging/src/k8s.io/code-generator/kube_codegen.sh +++ b/staging/src/k8s.io/code-generator/kube_codegen.sh @@ -27,6 +27,11 @@ set -o pipefail KUBE_CODEGEN_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +# Callers which want a specific tag of the k8s.io/code-generator repo should +# set the KUBE_CODEGEN_TAG to the tag name, e.g. KUBE_CODEGEN_TAG="release-1.32" +# before sourcing this file. +CODEGEN_VERSION_SPEC="${KUBE_CODEGEN_TAG:+"@${KUBE_CODEGEN_TAG}"}" + function kube::codegen::internal::findz() { # We use `find` rather than `git ls-files` because sometimes external # projects use this across repos. This is an imperfect wrapper of find, @@ -103,9 +108,9 @@ function kube::codegen::gen_helpers() { # and then install with forced module mode on and fully qualified name. cd "${KUBE_CODEGEN_ROOT}" BINS=( - conversion-gen - deepcopy-gen - defaulter-gen + conversion-gen"${CODEGEN_VERSION_SPEC}" + deepcopy-gen"${CODEGEN_VERSION_SPEC}" + defaulter-gen"${CODEGEN_VERSION_SPEC}" ) # shellcheck disable=2046 # printf word-splitting is intentional GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}") @@ -324,7 +329,7 @@ function kube::codegen::gen_openapi() { # and then install with forced module mode on and fully qualified name. cd "${KUBE_CODEGEN_ROOT}" BINS=( - openapi-gen + openapi-gen"${CODEGEN_VERSION_SPEC}" ) # shellcheck disable=2046 # printf word-splitting is intentional GO111MODULE=on go install $(printf "k8s.io/kube-openapi/cmd/%s " "${BINS[@]}") @@ -554,10 +559,10 @@ function kube::codegen::gen_client() { # and then install with forced module mode on and fully qualified name. cd "${KUBE_CODEGEN_ROOT}" BINS=( - applyconfiguration-gen - client-gen - informer-gen - lister-gen + applyconfiguration-gen"${CODEGEN_VERSION_SPEC}" + client-gen"${CODEGEN_VERSION_SPEC}" + informer-gen"${CODEGEN_VERSION_SPEC}" + lister-gen"${CODEGEN_VERSION_SPEC}" ) # shellcheck disable=2046 # printf word-splitting is intentional GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}") @@ -729,7 +734,7 @@ function kube::codegen::gen_register() { # and then install with forced module mode on and fully qualified name. cd "${KUBE_CODEGEN_ROOT}" BINS=( - register-gen + register-gen"${CODEGEN_VERSION_SPEC}" ) # shellcheck disable=2046 # printf word-splitting is intentional GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}")