bc8e7e10e1
Reviewed-on: #1 Co-authored-by: Timo Behrendt <t.behrendt@t00n.de> Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
51 lines
1.9 KiB
Bash
Executable File
51 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run Kubernetes code generators for pkg/apis using vendored kube_codegen.sh.
|
|
|
|
set -euo pipefail
|
|
|
|
# kube_codegen runs nested `go install` from the code-generator submodule. For this
|
|
# repo we force:
|
|
# -buildvcs=false — avoid git stamping failures (submodules, safe.directory)
|
|
# -mod=mod — do not use the repo root vendor/ (often stale vs go.mod
|
|
# or unrelated to generator tools); fetch modules instead.
|
|
export GOFLAGS="-buildvcs=false -mod=mod"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)"
|
|
|
|
MODULE="gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator"
|
|
KUBE_CODEGEN="${REPO_ROOT}/code-generator/kube_codegen.sh"
|
|
BOILERPLATE="${REPO_ROOT}/code-generator/examples/hack/boilerplate.go.txt"
|
|
API_ROOT="${REPO_ROOT}/pkg/apis"
|
|
GEN_ROOT="${REPO_ROOT}/pkg/generated"
|
|
|
|
source "${KUBE_CODEGEN}"
|
|
|
|
kube::codegen::gen_helpers --boilerplate "${BOILERPLATE}" "${API_ROOT}"
|
|
kube::codegen::gen_register --boilerplate "${BOILERPLATE}" "${API_ROOT}"
|
|
|
|
# OpenAPI rule diff: keep a checked-in baseline (see k8s.io/code-generator examples/hack/update-codegen.sh).
|
|
API_VIOLATIONS_DIR="${REPO_ROOT}/hack/api-violations"
|
|
VIOLATIONS_LIST="${API_VIOLATIONS_DIR}/codegen_violation_exceptions.list"
|
|
mkdir -p "${API_VIOLATIONS_DIR}"
|
|
openapi_report_args=(--report-filename "${VIOLATIONS_LIST}")
|
|
if [[ ! -s "${VIOLATIONS_LIST}" ]] || [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then
|
|
openapi_report_args+=(--update-report)
|
|
fi
|
|
|
|
kube::codegen::gen_openapi \
|
|
--output-dir "${GEN_ROOT}/openapi" \
|
|
--output-pkg "${MODULE}/pkg/generated/openapi" \
|
|
--output-model-name-file zz_generated.model_name.go \
|
|
--boilerplate "${BOILERPLATE}" \
|
|
"${openapi_report_args[@]}" \
|
|
"${API_ROOT}"
|
|
|
|
kube::codegen::gen_client \
|
|
--with-watch \
|
|
--with-applyconfig \
|
|
--output-dir "${GEN_ROOT}" \
|
|
--output-pkg "${MODULE}/pkg/generated" \
|
|
--boilerplate "${BOILERPLATE}" \
|
|
"${API_ROOT}"
|