generate.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. # Copyright 2020 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. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. GOPATH=${GOPATH:-$(go env GOPATH)}
  19. # "go env" doesn't print anything if GOBIN is the default, so we
  20. # have to manually default it.
  21. GOBIN=${GOBIN:-$(go env GOBIN)}
  22. GOBIN=${GOBIN:-${GOPATH}/bin}
  23. readonly HERE=$(cd $(dirname $0) && pwd)
  24. readonly REPO=$(cd ${HERE}/../.. && pwd)
  25. gendoc::build() {
  26. go install github.com/ahmetb/gen-crd-api-reference-docs
  27. }
  28. # Exec the doc generator.
  29. gendoc::exec() {
  30. local readonly confdir="${REPO}/hack/api-docs"
  31. (
  32. cd "${REPO}/apis"
  33. env GOWORK=off ${GOBIN}/gen-crd-api-reference-docs \
  34. -template-dir ${confdir} \
  35. -config ${confdir}/config.json \
  36. "$@"
  37. )
  38. }
  39. if [ "$#" != "1" ]; then
  40. echo "usage: generate.sh OUTFILE"
  41. exit 2
  42. fi
  43. gendoc::build
  44. gendoc::exec \
  45. -api-dir github.com/external-secrets/external-secrets/apis \
  46. -out-file "$1"