Speed up update-swagger-docs

Only build genswaggertypedocs once per run instead of per-package

Speeds up the script from ~1:10 to ~0:18
This commit is contained in:
Jordan Liggitt 2020-08-02 00:10:01 -04:00
parent f411880c73
commit 4d1b34a582
2 changed files with 8 additions and 1 deletions

View File

@ -51,7 +51,12 @@ kube::swagger::gen_types_swagger_doc() {
EOF
} > "${TMPFILE}"
go run cmd/genswaggertypedocs/swagger_type_docs.go -s \
if ! which genswaggertypedocs >/dev/null; then
# build if needed
go install k8s.io/kubernetes/cmd/genswaggertypedocs
fi
genswaggertypedocs -s \
"${gv_dir}/types.go" \
-f - \
>> "${TMPFILE}"

View File

@ -35,6 +35,8 @@ IFS=" " read -r -a GROUP_VERSIONS <<< "meta/v1 meta/v1beta1 ${KUBE_AVAILABLE_GRO
for group_version in "${GROUP_VERSIONS[@]}"; do
rm -f "$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go"
done
# ensure we have the latest genswaggertypedocs built
go install k8s.io/kubernetes/cmd/genswaggertypedocs
for group_version in "${GROUP_VERSIONS[@]}"; do
kube::swagger::gen_types_swagger_doc "${group_version}" "$(kube::util::group-version-to-pkg-path "${group_version}")"
done