mirror of https://github.com/k3s-io/k3s
Fix verify-generated-swagger-docs script
parent
f04ce297d6
commit
1f5dff7e53
|
@ -98,7 +98,6 @@
|
|||
./hack/update-generated-protobuf.sh
|
||||
./hack/update-generated-runtime-dockerized.sh
|
||||
./hack/update-generated-runtime.sh
|
||||
./hack/update-generated-swagger-docs.sh
|
||||
./hack/update-godep-licenses.sh
|
||||
./hack/update-gofmt.sh
|
||||
./hack/update-openapi-spec.sh
|
||||
|
@ -120,7 +119,6 @@
|
|||
./hack/verify-generated-pod-resources.sh
|
||||
./hack/verify-generated-protobuf.sh
|
||||
./hack/verify-generated-runtime.sh
|
||||
./hack/verify-generated-swagger-docs.sh
|
||||
./hack/verify-golint.sh
|
||||
./hack/verify-govet.sh
|
||||
./hack/verify-import-boss.sh
|
||||
|
|
|
@ -23,13 +23,13 @@ set -o errexit
|
|||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
source "${KUBE_ROOT}/hack/lib/swagger.sh"
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
GROUP_VERSIONS=(meta/v1 meta/v1beta1 ${KUBE_AVAILABLE_GROUP_VERSIONS})
|
||||
IFS=" " read -r -a GROUP_VERSIONS <<< "meta/v1 meta/v1beta1 ${KUBE_AVAILABLE_GROUP_VERSIONS}"
|
||||
|
||||
# To avoid compile errors, remove the currently existing files.
|
||||
for group_version in "${GROUP_VERSIONS[@]}"; do
|
||||
|
|
|
@ -18,7 +18,7 @@ set -o errexit
|
|||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
kube::golang::setup_env
|
||||
|
@ -38,29 +38,57 @@ if [[ ! -x "$genswaggertypedocs" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
DIFFROOT="${KUBE_ROOT}/pkg"
|
||||
TMP_DIFFROOT="${KUBE_ROOT}/_tmp/pkg"
|
||||
_tmp="${KUBE_ROOT}/_tmp"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "${_tmp}"
|
||||
_tmpdir="$(kube::realpath "$(mktemp -d -t swagger-docs.XXXXXX)")"
|
||||
function swagger_cleanup {
|
||||
rm -rf "${_tmpdir}"
|
||||
}
|
||||
trap "cleanup" EXIT SIGINT
|
||||
kube::util::trap_add swagger_cleanup EXIT
|
||||
|
||||
cleanup
|
||||
# Copy the contents of the kube directory into the nice clean place
|
||||
_kubetmp="${_tmpdir}/src/k8s.io"
|
||||
mkdir -p "${_kubetmp}"
|
||||
# should create ${_kubetmp}/kubernetes
|
||||
git archive --format=tar --prefix=kubernetes/ "$(git write-tree)" | (cd "${_kubetmp}" && tar xf -)
|
||||
_kubetmp="${_kubetmp}/kubernetes"
|
||||
# Do all our work in the new GOPATH
|
||||
export GOPATH="${_tmpdir}"
|
||||
|
||||
mkdir -p "${TMP_DIFFROOT}"
|
||||
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}/"
|
||||
find_files() {
|
||||
find . -not \( \
|
||||
\( \
|
||||
-wholename './output' \
|
||||
-o -wholename './.git' \
|
||||
-o -wholename './_output' \
|
||||
-o -wholename './_gopath' \
|
||||
-o -wholename './release' \
|
||||
-o -wholename './target' \
|
||||
-o -wholename '*/third_party/*' \
|
||||
-o -wholename '*/vendor/*' \
|
||||
-o -wholename './staging/src/k8s.io/client-go/*vendor/*' \
|
||||
\) -prune \
|
||||
\) -name 'types_swagger_doc_generated.go'
|
||||
}
|
||||
while IFS=$'\n' read -r line; do TARGET_FILES+=("$line"); done < <(find_files)
|
||||
|
||||
pushd "${_kubetmp}" > /dev/null 2>&1
|
||||
# Update the generated swagger docs
|
||||
hack/update-generated-swagger-docs.sh
|
||||
popd > /dev/null 2>&1
|
||||
|
||||
"${KUBE_ROOT}/hack/update-generated-swagger-docs.sh"
|
||||
echo "diffing ${DIFFROOT} against freshly generated swagger type documentation"
|
||||
ret=0
|
||||
diff --exclude=".import-restrictions" -Naupr -I 'Auto generated by' "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
|
||||
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}/"
|
||||
if [[ $ret -eq 0 ]]
|
||||
then
|
||||
echo "${DIFFROOT} up to date."
|
||||
else
|
||||
echo "${DIFFROOT} is out of date. Please run hack/update-generated-swagger-docs.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "${KUBE_ROOT}" > /dev/null 2>&1
|
||||
# Test for diffs
|
||||
_output=""
|
||||
for file in ${TARGET_FILES[*]}; do
|
||||
_output="${_output}$(diff -Naupr -I 'Auto generated by' "${KUBE_ROOT}/${file}" "${_kubetmp}/${file}")" || ret=1
|
||||
done
|
||||
|
||||
if [[ ${ret} -gt 0 ]]; then
|
||||
echo "Generated swagger type documentation is out of date:" >&2
|
||||
echo "${_output}" >&2
|
||||
exit ${ret}
|
||||
fi
|
||||
popd > /dev/null 2>&1
|
||||
|
||||
echo "Generated swagger type documentation up to date."
|
||||
|
|
Loading…
Reference in New Issue