hack: glob-remove all validation-gen outputs in update-codegen.sh

The cleanup step removed only zz_generated.validations.go and left the
per-Kind coverage test fixtures (zz_generated.<version>_test.go,
zz_generated.main_test.go) on disk, so renamed or removed Kinds would
leak stale files. Move every validation-gen output under a shared
zz_generated.validations. prefix and remove them via a single glob.
This commit is contained in:
Yongrui Lin 2026-05-12 20:31:20 +00:00
parent 553312e6c2
commit b622d5d2a2

View file

@ -420,8 +420,11 @@ function codegen::validation() {
k8s.io/code-generator/cmd/validation-gen
# TODO: Where do we want these output? It should be somewhere internal..
# The result file, in each pkg, of validation generation.
local output_file="${GENERATED_FILE_PREFIX}validations.go"
# All files emitted by validation-gen (the per-pkg validations file and the
# per-Kind coverage test fixtures under test/declarative_validation/) share
# this prefix so the cleanup below can glob-remove them in one pass.
local output_file_prefix="${GENERATED_FILE_PREFIX}validations."
local output_file="${output_file_prefix}go"
# All directories that request any form of validation generation.
if [[ "${DBG_CODEGEN}" == 1 ]]; then
@ -462,14 +465,14 @@ function codegen::validation() {
done
fi
git_find -z ':(glob)**'/"${output_file}" | xargs -0 rm -f
git_find -z ':(glob)**'/"${output_file_prefix}"'*' | xargs -0 rm -f
validation-gen \
-v "${KUBE_VERBOSE}" \
--go-header-file "${BOILERPLATE_FILENAME}" \
--output-file "${output_file}" \
--test-output-root "test/declarative_validation" \
--test-output-file-prefix "${GENERATED_FILE_PREFIX}" \
--test-output-file-prefix "${output_file_prefix}" \
--test-allowlist "test/declarative_validation/coverage-allowlist.yaml" \
--lint-rules=known-tags-only,require-explicit-disablement \
$(printf -- " --readonly-pkg %s" "${readonly_pkgs[@]}") \