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 8e993294c63..63fb68bb6be 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,applyconfiguration,client,lister,informer) or "all". + the generators comma separated to run (deepcopy, defaulter,applyconfiguration,client,lister,informer) or "all". 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 @@ -50,7 +50,7 @@ shift 4 # 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/{applyconfiguration-gen,client-gen,lister-gen,informer-gen,deepcopy-gen} + GO111MODULE=on go install k8s.io/code-generator/cmd/{applyconfiguration-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,defaulter-gen} ) # Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise: GOBIN="$(go env GOBIN)" @@ -77,6 +77,14 @@ if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then "$@" fi +if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then + echo "Generating defaulters" + "${gobin}/defaulter-gen" \ + --input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \ + -O zz_generated.defaults \ + "$@" +fi + if [ "${GENS}" = "all" ] || grep -qw "applyconfiguration" <<<"${GENS}"; then echo "Generating apply configuration for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}" "${gobin}/applyconfiguration-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 ff4dd288aa2..27cfd431b33 100755 --- a/staging/src/k8s.io/code-generator/hack/update-codegen.sh +++ b/staging/src/k8s.io/code-generator/hack/update-codegen.sh @@ -31,19 +31,19 @@ SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. "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" "applyconfiguration,client,deepcopy,informer,lister" \ +"${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" "applyconfiguration,client,deepcopy,informer,lister" \ +"${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" "applyconfiguration,client,deepcopy,informer,lister" \ +"${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" \