|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2015 The Kubernetes Authors All rights reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +set -o errexit |
| 18 | +set -o nounset |
| 19 | +set -o pipefail |
| 20 | + |
| 21 | +KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. |
| 22 | +source "${KUBE_ROOT}/hack/lib/init.sh" |
| 23 | + |
| 24 | +kube::golang::setup_env |
| 25 | + |
| 26 | +function generate_version() { |
| 27 | + local version=$1 |
| 28 | + local TMPFILE="/tmp/types_swagger_doc_generated.$(date +%s).go" |
| 29 | + |
| 30 | + echo "Generating swagger type docs for version ${version}" |
| 31 | + |
| 32 | + sed 's/YEAR/2015/' hack/boilerplate/boilerplate.go.txt > $TMPFILE |
| 33 | + echo "package ${version}" >> $TMPFILE |
| 34 | + cat >> $TMPFILE <<EOF |
| 35 | +
|
| 36 | +// This file contains a collection of methods that can be used from go-resful to |
| 37 | +// generate Swagger API documentation for its models. Please read this PR for more |
| 38 | +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 |
| 39 | +// |
| 40 | +// TODOs are ignored from the parser. (e.g. TODO(andronat):... || TODO:...) iff |
| 41 | +// are on one line! For multiple line or blocks that you want to ignore use ---. |
| 42 | +// Any context after a --- is ignored. |
| 43 | +// |
| 44 | +// Those methods can be generated by using hack/update-generated-swagger-docs.sh |
| 45 | +
|
| 46 | +// AUTO-GENERATED FUNCTIONS START HERE |
| 47 | +EOF |
| 48 | + |
| 49 | + GOPATH=$(godep path):$GOPATH go run cmd/genswaggertypedocs/swagger_type_docs.go -s "pkg/api/${version}/types.go" -f - >> $TMPFILE |
| 50 | + |
| 51 | + echo "// AUTO-GENERATED FUNCTIONS END HERE" >> $TMPFILE |
| 52 | + |
| 53 | + gofmt -w -s $TMPFILE |
| 54 | + mv $TMPFILE "pkg/api/${version}/types_swagger_doc_generated.go" |
| 55 | +} |
| 56 | + |
| 57 | +VERSIONS="v1" |
| 58 | +# To avoid compile errors, remove the currently existing files. |
| 59 | +for ver in $VERSIONS; do |
| 60 | + rm -f "pkg/api/${ver}/types_swagger_doc_generated.go" |
| 61 | +done |
| 62 | +for ver in $VERSIONS; do |
| 63 | + generate_version "${ver}" |
| 64 | +done |
| 65 | + |
| 66 | +"${KUBE_ROOT}/hack/update-swagger-spec.sh" |
0 commit comments