generate.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. ${GOBIN}/gen-crd-api-reference-docs \
  32. -template-dir ${confdir} \
  33. -config ${confdir}/config.json \
  34. "$@"
  35. }
  36. if [ "$#" != "1" ]; then
  37. echo "usage: generate.sh OUTFILE"
  38. exit 2
  39. fi
  40. gendoc::build
  41. gendoc::exec \
  42. -api-dir github.com/external-secrets/external-secrets/apis \
  43. -out-file "$1"