diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh index 577c4e6b9f0..e3d87c3f10e 100755 --- a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh @@ -25,7 +25,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code- # --output-base because this script should also be able to run inside the vendor dir of # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir # instead of the $GOPATH directly. For normal projects this can be dropped. -"${CODEGEN_PKG}/generate-groups.sh" all \ +"${CODEGEN_PKG}/generate-groups.sh" "applyconfiguration,client,deepcopy,informer,lister" \ k8s.io/apiextensions-apiserver/examples/client-go/pkg/client \ k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis \ cr:v1 \ diff --git a/staging/src/k8s.io/apiextensions-apiserver/hack/update-codegen.sh b/staging/src/k8s.io/apiextensions-apiserver/hack/update-codegen.sh index 8261e98d56a..f5dc31758ca 100755 --- a/staging/src/k8s.io/apiextensions-apiserver/hack/update-codegen.sh +++ b/staging/src/k8s.io/apiextensions-apiserver/hack/update-codegen.sh @@ -23,7 +23,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code- CLIENTSET_NAME_VERSIONED=clientset \ CLIENTSET_PKG_NAME=clientset \ -"${CODEGEN_PKG}/generate-groups.sh" "deepcopy,client,lister,informer" \ +"${CODEGEN_PKG}/generate-groups.sh" "deepcopy,defaulter,client,lister,informer" \ k8s.io/apiextensions-apiserver/pkg/client \ k8s.io/apiextensions-apiserver/pkg/apis \ "apiextensions:v1beta1,v1" \ diff --git a/staging/src/k8s.io/code-generator/generate-groups.sh b/staging/src/k8s.io/code-generator/generate-groups.sh index a511ef17284..742719c7a9d 100755 --- a/staging/src/k8s.io/code-generator/generate-groups.sh +++ b/staging/src/k8s.io/code-generator/generate-groups.sh @@ -25,7 +25,7 @@ if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then cat < ... - the generators comma separated to run (deepcopy,defaulter,applyconfiguration,client,lister,informer) or "all". + the generators comma separated to run (deepcopy,defaulter,applyconfiguration,client,lister,informer). the output package name (e.g. github.com/example/project/pkg/generated). the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis). the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative @@ -33,9 +33,12 @@ Usage: $(basename "$0") ... - the generators comma separated to run (deepcopy,defaulter,conversion,client,lister,informer,openapi) or "all". + the generators comma separated to run (applyconfiguration,client,conversion,deepcopy,defaulter,informer,lister,openapi). the output package name (e.g. github.com/example/project/pkg/generated). - the internal types dir (e.g. github.com/example/project/pkg/apis). + the internal types dir (e.g. github.com/example/project/pkg/apis) or "" if none. the external types dir (e.g. github.com/example/project/pkg/apis or githubcom/example/apis). the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative to . ... arbitrary flags passed to all generator binaries. -Examples: - $(basename "$0") all github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1" - $(basename "$0") deepcopy,defaulter,conversion github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/apis "foo:v1 bar:v1alpha1,v1beta1" +Example: + $(basename "$0") \ + deepcopy,defaulter,conversion \ + github.com/example/project/pkg/client \ + github.com/example/project/pkg/apis \ + github.com/example/project/apis \ + "foo:v1 bar:v1alpha1,v1beta1" EOF exit 0 fi @@ -47,11 +51,32 @@ EXT_APIS_PKG="$4" GROUPS_WITH_VERSIONS="$5" shift 5 +if [ "${GENS}" = "all" ] || grep -qw "all" <<<"${GENS}"; then + ALL="client,conversion,deepcopy,defaulter,informer,lister,openapi" + echo "WARNING: Specifying \"all\" as a generator is deprecated." + echo "WARNING: Please list the specific generators needed." + echo "WARNING: \"all\" is now an alias for \"${ALL}\"; new code generators WILL NOT be added to this set" + echo + GENS="${ALL}" +fi + ( # To support running this script from anywhere, first cd into this directory, # and then install with forced module mode on and fully qualified name. cd "$(dirname "${0}")" - GO111MODULE=on go install k8s.io/code-generator/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,openapi-gen} + BINS=( + applyconfiguration-gen + client-gen + conversion-gen + deepcopy-gen + defaulter-gen + informer-gen + lister-gen + openapi-gen + ) + # Compile all the tools at once - it's slightly faster but also just simpler. + # shellcheck disable=2046 # printf word-splitting is intentional + GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}") ) # Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise: @@ -77,38 +102,51 @@ for GVs in ${GROUPS_WITH_VERSIONS}; do done done -if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then +if grep -qw "deepcopy" <<<"${GENS}"; then echo "Generating deepcopy funcs" "${gobin}/deepcopy-gen" \ - --input-dirs "$(codegen::join , "${ALL_FQ_APIS[@]}")" -O zz_generated.deepcopy \ + --input-dirs "$(codegen::join , "${ALL_FQ_APIS[@]}")" \ + -O zz_generated.deepcopy \ "$@" fi -if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then +if grep -qw "defaulter" <<<"${GENS}"; then echo "Generating defaulters" "${gobin}/defaulter-gen" \ - --input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" -O zz_generated.defaults \ + --input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \ + -O zz_generated.defaults \ "$@" fi -if [ "${GENS}" = "all" ] || grep -qw "conversion" <<<"${GENS}"; then +if grep -qw "conversion" <<<"${GENS}"; then echo "Generating conversions" "${gobin}/conversion-gen" \ - --input-dirs "$(codegen::join , "${ALL_FQ_APIS[@]}")" -O zz_generated.conversion \ + --input-dirs "$(codegen::join , "${ALL_FQ_APIS[@]}")" \ + -O zz_generated.conversion \ "$@" fi -if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then +if grep -qw "applyconfiguration" <<<"${GENS}"; then + echo "Generating apply configuration for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}" + APPLY_CONFIGURATION_PACKAGE="${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}" + "${gobin}/applyconfiguration-gen" \ + --input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \ + --output-package "${APPLY_CONFIGURATION_PACKAGE}" \ + "$@" +fi + +if grep -qw "client" <<<"${GENS}"; then echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" "${gobin}/client-gen" \ --clientset-name "${CLIENTSET_NAME_VERSIONED:-versioned}" \ --input-base "" \ --input "$(codegen::join , "${EXT_FQ_APIS[@]}")" \ --output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" \ + --apply-configuration-package "${APPLY_CONFIGURATION_PACKAGE:-}" \ "$@" fi -if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then +if grep -qw "lister" <<<"${GENS}"; then echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers" "${gobin}/lister-gen" \ --input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \ @@ -116,7 +154,7 @@ if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then "$@" fi -if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then +if grep -qw "informer" <<<"${GENS}"; then echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers" "${gobin}/informer-gen" \ --input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \ @@ -126,7 +164,7 @@ if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then "$@" fi -if [ "${GENS}" = "all" ] || grep -qw "openapi" <<<"${GENS}"; then +if grep -qw "openapi" <<<"${GENS}"; then echo "Generating OpenAPI definitions for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/openapi" declare -a OPENAPI_EXTRA_PACKAGES "${gobin}/openapi-gen" \ diff --git a/staging/src/k8s.io/code-generator/hack/update-codegen.sh b/staging/src/k8s.io/code-generator/hack/update-codegen.sh index ce0f073a61a..27cfd431b33 100755 --- a/staging/src/k8s.io/code-generator/hack/update-codegen.sh +++ b/staging/src/k8s.io/code-generator/hack/update-codegen.sh @@ -24,26 +24,26 @@ SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. # - --output-base because this script should also be able to run inside the vendor dir of # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir # instead of the $GOPATH directly. For normal projects this can be dropped. -"${SCRIPT_ROOT}/generate-internal-groups.sh" all \ +"${SCRIPT_ROOT}/generate-internal-groups.sh" "client,conversion,deepcopy,defaulter,informer,lister,openapi" \ k8s.io/code-generator/examples/apiserver \ k8s.io/code-generator/examples/apiserver/apis \ k8s.io/code-generator/examples/apiserver/apis \ "example:v1 example2:v1 example3.io:v1" \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" -"${SCRIPT_ROOT}/generate-groups.sh" all \ +"${SCRIPT_ROOT}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \ k8s.io/code-generator/examples/crd \ k8s.io/code-generator/examples/crd/apis \ "example:v1 example2:v1" \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" -"${SCRIPT_ROOT}/generate-groups.sh" all \ +"${SCRIPT_ROOT}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \ k8s.io/code-generator/examples/MixedCase \ k8s.io/code-generator/examples/MixedCase/apis \ "example:v1" \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" -"${SCRIPT_ROOT}/generate-groups.sh" all \ +"${SCRIPT_ROOT}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \ k8s.io/code-generator/examples/HyphenGroup \ k8s.io/code-generator/examples/HyphenGroup/apis \ "example:v1" \ diff --git a/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh b/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh index f85abd44ccc..ef04f9bd650 100755 --- a/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh +++ b/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh @@ -23,7 +23,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code- CLIENTSET_NAME_VERSIONED=clientset \ CLIENTSET_PKG_NAME=clientset_generated \ -"${CODEGEN_PKG}/generate-groups.sh" "deepcopy,client,lister,informer" \ +"${CODEGEN_PKG}/generate-groups.sh" "deepcopy,defaulter,client,lister,informer" \ k8s.io/kube-aggregator/pkg/client \ k8s.io/kube-aggregator/pkg/apis \ "apiregistration:v1beta1,v1" \ diff --git a/staging/src/k8s.io/metrics/hack/update-codegen.sh b/staging/src/k8s.io/metrics/hack/update-codegen.sh index 633146dbf94..7c4f1cbd827 100755 --- a/staging/src/k8s.io/metrics/hack/update-codegen.sh +++ b/staging/src/k8s.io/metrics/hack/update-codegen.sh @@ -32,7 +32,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code- k8s.io/metrics/pkg/client \ k8s.io/metrics/pkg/apis \ k8s.io/metrics/pkg/apis \ - "metrics:v1alpha1,v1beta1 custom_metrics:v1beta1 external_metrics:v1beta1" \ + "metrics:v1alpha1,v1beta1 custom_metrics:v1beta1,v1beta2 external_metrics:v1beta1" \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" "${CODEGEN_PKG}/generate-groups.sh" "client" \ diff --git a/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh b/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh index 9fd4e236dc0..c3b4e45659d 100755 --- a/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh +++ b/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh @@ -25,7 +25,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code- # --output-base because this script should also be able to run inside the vendor dir of # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir # instead of the $GOPATH directly. For normal projects this can be dropped. -"${CODEGEN_PKG}/generate-groups.sh" all \ +"${CODEGEN_PKG}/generate-groups.sh" "applyconfiguration,client,deepcopy,informer,lister" \ k8s.io/sample-apiserver/pkg/generated \ k8s.io/sample-apiserver/pkg/apis \ "wardle:v1alpha1,v1beta1" \