mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #123261 from skitt/allow-codegen-verification
codegen: don't nuke files if only verifying
This commit is contained in:
commit
1dce896e2c
@ -55,6 +55,12 @@ echo "WARNING: $(basename "$0") is deprecated."
|
||||
echo "WARNING: Please use k8s.io/code-generator/kube_codegen.sh instead."
|
||||
echo
|
||||
|
||||
# If verification only is requested, avoid deleting files
|
||||
verify_only=""
|
||||
for ((i = 1; i <= $#; i++)); do
|
||||
if [ "${!i}" = --verify-only ]; then verify_only=1; fi
|
||||
done
|
||||
|
||||
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."
|
||||
@ -124,12 +130,14 @@ CLIENTSET_PKG="${CLIENTSET_PKG_NAME:-clientset}"
|
||||
CLIENTSET_NAME="${CLIENTSET_NAME_VERSIONED:-versioned}"
|
||||
|
||||
if grep -qw "deepcopy" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${ALL_FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.deepcopy.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${ALL_FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.deepcopy.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Generating deepcopy funcs"
|
||||
"${gobin}/deepcopy-gen" \
|
||||
@ -139,12 +147,14 @@ if grep -qw "deepcopy" <<<"${GENS}"; then
|
||||
fi
|
||||
|
||||
if grep -qw "defaulter" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${ALL_FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.defaults.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${ALL_FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.defaults.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Generating defaulters"
|
||||
"${gobin}/defaulter-gen" \
|
||||
@ -154,12 +164,14 @@ if grep -qw "defaulter" <<<"${GENS}"; then
|
||||
fi
|
||||
|
||||
if grep -qw "conversion" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${ALL_FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.conversion.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${ALL_FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.conversion.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Generating conversions"
|
||||
"${gobin}/conversion-gen" \
|
||||
@ -171,15 +183,17 @@ fi
|
||||
if grep -qw "applyconfiguration" <<<"${GENS}"; then
|
||||
APPLY_CONFIGURATION_PACKAGE="${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}"
|
||||
|
||||
# Nuke existing files
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${APPLY_CONFIGURATION_PACKAGE}" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by applyconfiguration-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${APPLY_CONFIGURATION_PACKAGE}" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by applyconfiguration-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Generating apply configuration for ${GROUPS_WITH_VERSIONS} at ${APPLY_CONFIGURATION_PACKAGE}"
|
||||
@ -190,15 +204,17 @@ if grep -qw "applyconfiguration" <<<"${GENS}"; then
|
||||
fi
|
||||
|
||||
if grep -qw "client" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${OUTPUT_PKG}/${CLIENTSET_PKG}/${CLIENTSET_NAME}" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by client-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${OUTPUT_PKG}/${CLIENTSET_PKG}/${CLIENTSET_NAME}" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by client-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG}"
|
||||
@ -212,18 +228,20 @@ if grep -qw "client" <<<"${GENS}"; then
|
||||
fi
|
||||
|
||||
if grep -qw "lister" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
for gv in "${GROUP_VERSIONS[@]}"; do
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${OUTPUT_PKG}/listers/${gv}" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by lister-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
fi
|
||||
done
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
for gv in "${GROUP_VERSIONS[@]}"; do
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${OUTPUT_PKG}/listers/${gv}" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by lister-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
|
||||
"${gobin}/lister-gen" \
|
||||
@ -233,15 +251,17 @@ if grep -qw "lister" <<<"${GENS}"; then
|
||||
fi
|
||||
|
||||
if grep -qw "informer" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${OUTPUT_PKG}/informers/externalversions" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by informer-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
root="$(GO111MODULE=on go list -f '{{.Dir}}' "${OUTPUT_PKG}/informers/externalversions" 2>/dev/null || true)"
|
||||
if [ -n "${root}" ]; then
|
||||
pushd "${root}" >/dev/null
|
||||
git_grep -l --null \
|
||||
-e '^// Code generated by informer-gen. DO NOT EDIT.$' \
|
||||
':(glob)**/*.go' \
|
||||
| xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers"
|
||||
@ -254,12 +274,14 @@ if grep -qw "informer" <<<"${GENS}"; then
|
||||
fi
|
||||
|
||||
if grep -qw "openapi" <<<"${GENS}"; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.openapi.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
if [ ! "$verify_only" ]; then
|
||||
# Nuke existing files
|
||||
for dir in $(GO111MODULE=on go list -f '{{.Dir}}' "${FQ_APIS[@]}"); do
|
||||
pushd "${dir}" >/dev/null
|
||||
git_find -z ':(glob)**'/zz_generated.openapi.go | xargs -0 rm -f
|
||||
popd >/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Generating OpenAPI definitions for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/openapi"
|
||||
declare -a OPENAPI_EXTRA_PACKAGES
|
||||
|
Loading…
Reference in New Issue
Block a user