forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-generated-openapi.sh
executable file
·74 lines (64 loc) · 2.7 KB
/
update-generated-openapi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/kube-openapi 2>/dev/null || echo ../../../k8s.io/kube-openapi)}
go install ./${CODEGEN_PKG}/cmd/openapi-gen
function codegen::join() { local IFS="$1"; shift; echo "$*"; }
ORIGIN_PREFIX="${OS_GO_PACKAGE}/"
KUBE_INPUT_DIRS=(
$(
grep --color=never -rl '+k8s:openapi-gen=' vendor/k8s.io/kubernetes | \
xargs -n1 dirname | \
sed "s,^vendor/,," | \
sort -u | \
sed '/^k8s\.io\/kubernetes\/build\/root$/d' | \
sed '/^k8s\.io\/kubernetes$/d' | \
sed '/^k8s\.io\/kubernetes\/staging$/d' | \
sed 's,k8s\.io/kubernetes/staging/src/,,'
)
)
ORIGIN_INPUT_DIRS=(
$(
grep --color=never -rl '+k8s:openapi-gen=' vendor/github.com/openshift/api | \
xargs -n1 dirname | \
sed "s,^vendor/,," | \
sort -u
)
)
APIEXTENSIONS_INPUT_DIRS=(
k8s.io/apimachinery/pkg/apis/meta/v1
k8s.io/api/autoscaling/v1
)
KUBE_INPUT_DIRS=$(IFS=,; echo "${KUBE_INPUT_DIRS[*]}")
ORIGIN_INPUT_DIRS=$(IFS=,; echo "${ORIGIN_INPUT_DIRS[*]}")
function join { local IFS="$1"; shift; echo "$*"; }
echo "Generating origin openapi"
${GOPATH}/bin/openapi-gen \
--build-tag=ignore_autogenerated_openshift \
--output-file-base zz_generated.openapi \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.txt \
--output-base="${GOPATH}/src" \
--input-dirs $(join , "${KUBE_INPUT_DIRS[@]}" "${ORIGIN_INPUT_DIRS[@]}") \
--output-package "${ORIGIN_PREFIX}pkg/openapi" \
--report-filename "${SCRIPT_ROOT}/hack/openapi-violation.list" \
"$@"
echo "Generating kubernetes openapi"
${GOPATH}/bin/openapi-gen \
--build-tag=ignore_autogenerated_openshift \
--output-file-base zz_generated.openapi \
--go-header-file ${SCRIPT_ROOT}/vendor/k8s.io/kubernetes/hack/boilerplate/boilerplate.generatego.txt \
--output-base="${GOPATH}/src" \
--input-dirs $(join , "${KUBE_INPUT_DIRS[@]}") \
--output-package "${ORIGIN_PREFIX}/vendor/k8s.io/kubernetes/pkg/generated/openapi" \
--report-filename "${SCRIPT_ROOT}/vendor/k8s.io/kubernetes/hack/openapi-violation.list" \
"$@"
echo "Generating apiextensions-apiserver openapi"
${GOPATH}/bin/openapi-gen \
--build-tag=ignore_autogenerated_openshift \
--output-file-base zz_generated.openapi \
--go-header-file ${SCRIPT_ROOT}/vendor/k8s.io/kubernetes/hack/boilerplate/boilerplate.generatego.txt \
--output-base="${GOPATH}/src" \
--input-dirs $(join , "${APIEXTENSIONS_INPUT_DIRS[@]}") \
--output-package "${ORIGIN_PREFIX}/vendor/k8s.io/apiextensions-apiserver/pkg/generated/openapi" \
--report-filename "${SCRIPT_ROOT}/vendor/k8s.io/apiextensions-apiserver/hack/openapi-violation.list" \
"$@"