update-federation-api-reference-docs.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # Copyright 2016 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Generates updated api-reference docs from the latest swagger spec for
  16. # federation apiserver. The docs are generated at federation/docs/api-reference
  17. # Usage: ./update-federation-api-reference-docs.sh <absolute output path>
  18. set -o errexit
  19. set -o nounset
  20. set -o pipefail
  21. echo "Note: This assumes that swagger spec has been updated. Please run hack/update-federation-swagger-spec.sh to ensure that."
  22. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  23. source "${KUBE_ROOT}/hack/lib/init.sh"
  24. source "${KUBE_ROOT}/hack/lib/swagger.sh"
  25. kube::golang::setup_env
  26. REPO_DIR=${REPO_DIR:-"${KUBE_ROOT}"}
  27. DEFAULT_OUTPUT="${REPO_DIR}/federation/docs/api-reference"
  28. OUTPUT=${1:-${DEFAULT_OUTPUT}}
  29. SWAGGER_SPEC_PATH="${REPO_DIR}/federation/apis/swagger-spec"
  30. GROUP_VERSIONS=("federation/v1beta1" "v1" "extensions/v1beta1")
  31. GV_DIRS=()
  32. for gv in "${GROUP_VERSIONS[@]}"; do
  33. if [[ ${gv} == "federation/v1beta1" ]]; then
  34. GV_DIRS+=("${REPO_DIR}/federation/$(kube::util::group-version-to-pkg-path "${gv}")")
  35. else
  36. GV_DIRS+=("${REPO_DIR}/pkg/$(kube::util::group-version-to-pkg-path "${gv}")")
  37. fi
  38. done
  39. GROUP_VERSIONS="${GROUP_VERSIONS[@]}" GV_DIRS="${GV_DIRS[@]}" kube::swagger::gen_api_ref_docs "${SWAGGER_SPEC_PATH}" "${OUTPUT}"
  40. # ex: ts=2 sw=2 et filetype=sh