K8s: Update common openapi generation scripts (#81857)
This commit is contained in:
+1
-3
@@ -23,9 +23,7 @@ go mod download
|
||||
# the happy path
|
||||
./hack/update-codegen.sh
|
||||
|
||||
# if wanting to agree to a change which introduces different openapi violations, run with the bool set to true
|
||||
UPDATE_API_KNOWN_VIOLATIONS=true ./hack/update-codegen.sh
|
||||
```
|
||||
|
||||
Note that the script deletes existing openapi go code and regenerates in place so that you will temporarily see
|
||||
deleted files in your `git status`. After a successful run, you should see them restored.
|
||||
```
|
||||
|
||||
@@ -39,6 +39,7 @@ function grafana::codegen::gen_openapi() {
|
||||
local out_base=""
|
||||
local report="/dev/null"
|
||||
local update_report=""
|
||||
local include_common_input_dirs=""
|
||||
local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt"
|
||||
local v="${KUBE_VERBOSE:-0}"
|
||||
|
||||
@@ -48,6 +49,14 @@ function grafana::codegen::gen_openapi() {
|
||||
in_pkg_single="$2"
|
||||
shift 2
|
||||
;;
|
||||
"--include-common-input-dirs")
|
||||
if [ "$2" == "true" ]; then
|
||||
COMMON_INPUT_DIRS='--input-dirs "k8s.io/apimachinery/pkg/apis/meta/v1" --input-dirs "k8s.io/apimachinery/pkg/runtime" --input-dirs "k8s.io/apimachinery/pkg/version"'
|
||||
else
|
||||
COMMON_INPUT_DIRS=""
|
||||
fi
|
||||
shift 2
|
||||
;;
|
||||
"--output-base")
|
||||
out_base="$2"
|
||||
shift 2
|
||||
@@ -143,6 +152,7 @@ function grafana::codegen::gen_openapi() {
|
||||
--output-base "${out_base}" \
|
||||
--output-package "${in_pkg_single}" \
|
||||
--report-filename "${new_report}" \
|
||||
${COMMON_INPUT_DIRS} \
|
||||
"${inputs[@]}"
|
||||
fi
|
||||
|
||||
|
||||
@@ -19,27 +19,26 @@ source "${CODEGEN_PKG}/kube_codegen.sh"
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/openapi-codegen.sh"
|
||||
|
||||
kube::codegen::gen_helpers \
|
||||
--input-pkg-root github.com/grafana/grafana/pkg/apis \
|
||||
--output-base "${OUTDIR}" \
|
||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
--input-pkg-root github.com/grafana/grafana/pkg/apis \
|
||||
--output-base "${OUTDIR}" \
|
||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
|
||||
|
||||
if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then
|
||||
update_report="--update-report"
|
||||
fi
|
||||
|
||||
for api_pkg in $(ls ./pkg/apis); do
|
||||
if [[ "${1-}" != "" && ${api_pkg} != $1 ]]; then
|
||||
continue
|
||||
fi
|
||||
include_common_input_dirs=$([[ ${api_pkg} == "common" ]] && echo "true" || echo "false")
|
||||
for pkg_version in $(ls ./pkg/apis/${api_pkg}); do
|
||||
echo "Generating openapi package for ${api_pkg}, version=${pkg_version} ..."
|
||||
|
||||
grafana::codegen::gen_openapi \
|
||||
--input-pkg-single github.com/grafana/grafana/pkg/apis/${api_pkg}/${pkg_version} \
|
||||
--output-base "${OUTDIR}" \
|
||||
--report-filename "${OPENAPI_VIOLATION_EXCEPTIONS_FILENAME}" \
|
||||
${update_report:+"${update_report}"} \
|
||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
--update-report \
|
||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--include-common-input-dirs ${include_common_input_dirs}
|
||||
done
|
||||
|
||||
violations_file="${OUTDIR}/github.com/grafana/grafana/pkg/apis/${api_pkg}/${pkg_version}/${OPENAPI_VIOLATION_EXCEPTIONS_FILENAME}"
|
||||
|
||||
Reference in New Issue
Block a user