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[@]}")