Make verify-openapi-spec use verify::generated

Tested by injecting an API change, generating openapi, then watching
this fail.
This commit is contained in:
Tim Hockin
2024-03-05 17:13:40 -08:00
parent 546f7c3086
commit 813787489b
2 changed files with 3 additions and 47 deletions

View File

@@ -631,6 +631,7 @@ kube::golang::place_bins() {
if [[ "${platform}" == "${host_platform}" ]]; then
platform_src=""
rm -f "${THIS_PLATFORM_BIN}"
mkdir -p "$(dirname "${THIS_PLATFORM_BIN}")"
ln -s "${KUBE_OUTPUT_BIN}/${platform}" "${THIS_PLATFORM_BIN}"
fi

View File

@@ -24,52 +24,7 @@ set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env
kube::etcd::install
source "${KUBE_ROOT}/hack/lib/verify-generated.sh"
# We use `make` here intead of `go install` to ensure that all of the
# linker-defined values are set.
make -C "${KUBE_ROOT}" WHAT=./cmd/kube-apiserver
SPECROOT="${KUBE_ROOT}/api/openapi-spec"
SPECV3PATH="${SPECROOT}/v3"
DISCOVERYROOT="${KUBE_ROOT}/api/discovery"
TMP_SPECROOT="${KUBE_ROOT}/_tmp/openapi-spec"
TMP_DISCOVERYROOT="${KUBE_ROOT}/_tmp/discovery"
_tmp="${KUBE_ROOT}/_tmp"
mkdir -p "${_tmp}"
cp -a "${SPECROOT}" "${TMP_SPECROOT}"
cp -a "${DISCOVERYROOT}" "${TMP_DISCOVERYROOT}"
trap 'cp -a ${TMP_SPECROOT} ${SPECROOT}/..; cp -a ${TMP_DISCOVERYROOT} ${DISCOVERYROOT}/..; rm -rf ${_tmp}' EXIT SIGINT
rm -r "${SPECROOT:?}"/*
rm -r "${DISCOVERYROOT:?}"/*
mkdir -p "${SPECV3PATH}"
cp "${TMP_SPECROOT}/README.md" "${SPECROOT}/README.md"
"${KUBE_ROOT}/hack/update-openapi-spec.sh"
echo "diffing ${SPECROOT} against freshly generated openapi spec"
ret=0
diff -Naupr -I 'Auto generated by' "${SPECROOT}" "${TMP_SPECROOT}" || ret=$?
if [[ $ret -eq 0 ]]
then
echo "${SPECROOT} up to date."
else
echo "${SPECROOT} is out of date. Please run hack/update-openapi-spec.sh" >&2
exit 1
fi
echo "diffing ${DISCOVERYROOT} against freshly generated discovery"
ret=0
diff -Naupr "${DISCOVERYROOT}" "${TMP_DISCOVERYROOT}" || ret=$?
if [[ $ret -eq 0 ]]
then
echo "${DISCOVERYROOT} up to date."
else
echo "${DISCOVERYROOT} is out of date. Please run hack/update-openapi-spec.sh" >&2
exit 1
fi
# ex: ts=2 sw=2 et filetype=sh
kube::verify::generated "Generated files need to be updated" "Please run 'hack/update-openapi-spec.sh'" hack/update-openapi-spec.sh "$@"