diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index d021f9b5bd8..646f2f9d093 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -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[@]}") \