Use the same report files as before

This commit is contained in:
Tim Hockin 2023-05-09 18:43:04 -07:00
parent ef796dca9b
commit 6607834207
No known key found for this signature in database
11 changed files with 35 additions and 19 deletions

View File

@ -1,10 +1,8 @@
# Existing API Rule Violations # Existing API Rule Violations
This folder contains the checked-in report file of known API rule violations This folder contains the checked-in report file of known API rule violations.
for the main Kubernetes repository. Reports for staging repositories are The file violation\_exceptions.list is used by Make rule during OpenAPI spec generation to make
checked in to those repositories. These files are used during OpenAPI spec sure that no new API rule violation is introduced into our code base.
generation to make sure that no new API rule violation is introduced into our
code base.
## API Rule Violation Format ## API Rule Violation Format

View File

@ -32,6 +32,7 @@ kube::golang::setup_env
DBG_CODEGEN="${DBG_CODEGEN:-0}" DBG_CODEGEN="${DBG_CODEGEN:-0}"
GENERATED_FILE_PREFIX="${GENERATED_FILE_PREFIX:-zz_generated.}" GENERATED_FILE_PREFIX="${GENERATED_FILE_PREFIX:-zz_generated.}"
UPDATE_API_KNOWN_VIOLATIONS="${UPDATE_API_KNOWN_VIOLATIONS:-}" UPDATE_API_KNOWN_VIOLATIONS="${UPDATE_API_KNOWN_VIOLATIONS:-}"
API_KNOWN_VIOLATIONS_DIR="${API_KNOWN_VIOLATIONS_DIR:-"${KUBE_ROOT}/api/api-rules"}"
OUT_DIR="_output" OUT_DIR="_output"
PRJ_SRC_PATH="k8s.io/kubernetes" PRJ_SRC_PATH="k8s.io/kubernetes"
@ -515,7 +516,7 @@ function codegen::openapi() {
gen_openapi_bin="$(kube::util::find-binary "openapi-gen")" gen_openapi_bin="$(kube::util::find-binary "openapi-gen")"
local output_dir="pkg/generated/openapi" local output_dir="pkg/generated/openapi"
local known_violations_file="api/api-rules/violation_exceptions.list" local known_violations_file="${API_KNOWN_VIOLATIONS_DIR}/violation_exceptions.list"
local report_file="${OUT_DIR}/api_violations.report" local report_file="${OUT_DIR}/api_violations.report"
# When UPDATE_API_KNOWN_VIOLATIONS is set to be true, let the generator to write # When UPDATE_API_KNOWN_VIOLATIONS is set to be true, let the generator to write
@ -792,7 +793,10 @@ function codegen::subprojects() {
for sub in "${subs[@]}"; do for sub in "${subs[@]}"; do
kube::log::status "Generating code for subproject ${sub}" kube::log::status "Generating code for subproject ${sub}"
pushd "${sub}" >/dev/null pushd "${sub}" >/dev/null
CODEGEN_PKG="${codegen}" ./hack/update-codegen.sh > >(indent) 2> >(indent >&2) CODEGEN_PKG="${codegen}" \
UPDATE_API_KNOWN_VIOLATIONS="${UPDATE_API_KNOWN_VIOLATIONS}" \
API_KNOWN_VIOLATIONS_DIR="${API_KNOWN_VIOLATIONS_DIR}" \
./hack/update-codegen.sh > >(indent) 2> >(indent >&2)
popd >/dev/null popd >/dev/null
done done
} }

View File

@ -28,8 +28,11 @@ kube::codegen::gen_helpers \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then
update_report="--update-report" report_filename="${API_KNOWN_VIOLATIONS_DIR}/apiextensions_violation_exceptions.list"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then
update_report="--update-report"
fi
fi fi
kube::codegen::gen_openapi \ kube::codegen::gen_openapi \
@ -37,7 +40,7 @@ kube::codegen::gen_openapi \
--extra-pkgs k8s.io/api/autoscaling/v1 `# needed for Scale type` \ --extra-pkgs k8s.io/api/autoscaling/v1 `# needed for Scale type` \
--output-pkg-root k8s.io/apiextensions-apiserver/pkg/generated \ --output-pkg-root k8s.io/apiextensions-apiserver/pkg/generated \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
--report-filename "${SCRIPT_ROOT}/api_violation_exceptions.list" \ --report-filename "${report_filename:-"/dev/null"}" \
${update_report:+"${update_report}"} \ ${update_report:+"${update_report}"} \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"

View File

@ -34,15 +34,18 @@ kube::codegen::gen_helpers \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then
update_report="--update-report" report_filename="${API_KNOWN_VIOLATIONS_DIR}/codegen_violation_exceptions.list"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then
update_report="--update-report"
fi
fi fi
kube::codegen::gen_openapi \ kube::codegen::gen_openapi \
--input-pkg-root k8s.io/code-generator/examples/apiserver/apis \ --input-pkg-root k8s.io/code-generator/examples/apiserver/apis \
--output-pkg-root k8s.io/code-generator/examples/apiserver \ --output-pkg-root k8s.io/code-generator/examples/apiserver \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \
--report-filename "${SCRIPT_ROOT}/api_violation_exceptions.list" \ --report-filename "${report_filename:-"/dev/null"}" \
${update_report:+"${update_report}"} \ ${update_report:+"${update_report}"} \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"

View File

@ -255,6 +255,7 @@ function kube::codegen::gen_openapi() {
local v="${KUBE_VERBOSE:-0}" local v="${KUBE_VERBOSE:-0}"
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
echo "$1"
case "$1" in case "$1" in
"--input-pkg-root") "--input-pkg-root")
in_pkg_root="$2" in_pkg_root="$2"
@ -308,6 +309,7 @@ function kube::codegen::gen_openapi() {
return 1 return 1
fi fi
set -x
local new_report local new_report
new_report="$(mktemp -t "$(basename "$0").api_violations.XXXXXX")" new_report="$(mktemp -t "$(basename "$0").api_violations.XXXXXX")"
if [ -n "${update_report}" ]; then if [ -n "${update_report}" ]; then

View File

@ -28,15 +28,18 @@ kube::codegen::gen_helpers \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then
update_report="--update-report" report_filename="${API_KNOWN_VIOLATIONS_DIR}/aggregator_violation_exceptions.list"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then
update_report="--update-report"
fi
fi fi
kube::codegen::gen_openapi \ kube::codegen::gen_openapi \
--input-pkg-root k8s.io/kube-aggregator/pkg/apis \ --input-pkg-root k8s.io/kube-aggregator/pkg/apis \
--output-pkg-root k8s.io/kube-aggregator/pkg/generated \ --output-pkg-root k8s.io/kube-aggregator/pkg/generated \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
--report-filename "${SCRIPT_ROOT}/api_violation_exceptions.list" \ --report-filename "${report_filename:-"/dev/null"}" \
${update_report:+"${update_report}"} \ ${update_report:+"${update_report}"} \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"

View File

@ -33,15 +33,18 @@ kube::codegen::gen_helpers \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then
update_report="--update-report" report_filename="${API_KNOWN_VIOLATIONS_DIR}/sample_apiserver_violation_exceptions.list"
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then
update_report="--update-report"
fi
fi fi
kube::codegen::gen_openapi \ kube::codegen::gen_openapi \
--input-pkg-root k8s.io/sample-apiserver/pkg/apis \ --input-pkg-root k8s.io/sample-apiserver/pkg/apis \
--output-pkg-root k8s.io/sample-apiserver/pkg/generated \ --output-pkg-root k8s.io/sample-apiserver/pkg/generated \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
--report-filename "${SCRIPT_ROOT}/api_violation_exceptions.list" \ --report-filename "${report_filename:-"/dev/null"}" \
${update_report:+"${update_report}"} \ ${update_report:+"${update_report}"} \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"