mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
Codegen subprojects: regen defaulters when needed
If you manually remove generated defaults, they do not get regenerated without this.
This commit is contained in:
parent
5200f4b0d3
commit
8b68e063e1
@ -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" \
|
||||
|
@ -25,7 +25,7 @@ if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") <generators> <output-package> <apis-package> <groups-versions> ...
|
||||
|
||||
<generators> the generators comma separated to run (deepcopy,applyconfiguration,client,lister,informer) or "all".
|
||||
<generators> the generators comma separated to run (deepcopy, defaulter,applyconfiguration,client,lister,informer) or "all".
|
||||
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
|
||||
<apis-package> the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis).
|
||||
<groups-versions> 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" \
|
||||
|
@ -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" \
|
||||
|
@ -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" \
|
||||
|
Loading…
Reference in New Issue
Block a user