Debian Codegraph @

kyaml/openapi/scripts/makeOpenApiInfoDotGo.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Copyright 2020 The Kubernetes Authors.
3 # SPDX-License-Identifier: Apache-2.0
4
5 # This will read from the directory kubernetesapi
6 # and use subdirectory names to generate
7 # kubernetesapi/openapiinfo.go
8 #
9 # This script should only be run after the
10 # swagger.json and swagger.go files are generated.
11
12 set -e
13
14 if ! command -v jq &> /dev/nullscip-shell filesystem . . `/dev/null`. ; then
15 echoscip-shell system . . echo. Please install jq
16 echoscip-shell system . . echo. on ubuntu: sudo apt-get install jq
17 exit 1
18 fi
19
20 info_list=()
21 version_list=()
22
23 V=`lsscip-shell system . . ls. kubernetesapi | grepscip-shell system . . grep. v.*`
24 for VERSION in $V
25 do
26 openapiinfo="{title:Kubernetes,version:${VERSION//_/.}}"
27 info_list+=( $openapiinfo )
28 version_list+=( ${VERSION} )
29 done
30
31
32 # add imports to openapiinfo.go
33 catscip-shell system . . cat. <<EOF >kubernetesapi/openapiinfo.go
34 // Copyright 2020 The Kubernetes Authors.
35 // SPDX-License-Identifier: Apache-2.0
36
37 // Code generated by $0; DO NOT EDIT.
38
39 package kubernetesapi
40
41 import (
42 EOF
43
44 for version in ${version_list[@]}
45 do
46 catscip-shell system . . cat. <<EOF >>kubernetesapi/openapiinfo.go
47 "sigs.k8s.io/kustomize/kyaml/openapi/kubernetesapi/$version"
48 EOF
49 done
50
51 # add info string for `kustomize openapi info` command
52 OPEN_API_INFO=`echoscip-shell system . . echo. ${info_list[@]} | sedscip-shell system . . sed. 's/ /\\\n/g'`
53 catscip-shell system . . cat. <<EOF >>kubernetesapi/openapiinfo.go
54 )
55
56 const Info = "$OPEN_API_INFO"
57 EOF
58
59 # add map for `initSchema` in openapi.go to use
60 catscip-shell system . . cat. <<EOF >>kubernetesapi/openapiinfo.go
61
62 var OpenAPIMustAsset = map[string]func(string)[]byte{
63 EOF
64
65 latest=""
66 for version in ${version_list[@]}
67 do
68 latest=$version
69 catscip-shell system . . cat. <<EOF >>kubernetesapi/openapiinfo.go
70 "${version//_/.}": $version.MustAsset,
71 EOF
72 done
73
74 # add latest version to be used as a default
75 catscip-shell system . . cat. <<EOF >>kubernetesapi/openapiinfo.go
76 }
77
78 const DefaultOpenAPI = "${latest//_/.}"
79 EOF
80
81 gofmtscip-shell system . . gofmt. -s -w kubernetesapi/openapiinfo.go