File tree Expand file tree Collapse file tree 7 files changed +30
-100
lines changed Expand file tree Collapse file tree 7 files changed +30
-100
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ MYGOBIN = $(shell go env GOBIN)
55ifeq ($(MYGOBIN ) ,)
66MYGOBIN = $(shell go env GOPATH) /bin
77endif
8- API_VERSION := "v1.21.2"
98KIND_VERSION := "v0.11.1"
109
1110.PHONY : all
@@ -46,10 +45,6 @@ kustomizationapi/swagger.go: $(MYGOBIN)/go-bindata kustomizationapi/swagger.json
4645 -o kustomizationapi/swagger.go \
4746 kustomizationapi/swagger.json
4847
49- .PHONY : kubernetesapi/openapiinfo.go
50- kubernetesapi/openapiinfo.go :
51- ./scripts/makeOpenApiInfoDotGo.sh
52-
5348.PHONY : kubernetesapi/swagger.json
5449kubernetesapi/swagger.json : $(MYGOBIN ) /kind $(MYGOBIN ) /kustomize
5550 ./scripts/fetchSchemaFromCluster.sh $(API_VERSION )
Original file line number Diff line number Diff line change @@ -67,11 +67,25 @@ make kubernetesapi/swagger.go API_VERSION=v1.21.2
6767While the above commands generate the swagger.go files, they
6868do not make them available for use nor do they update the
6969info field reported by ` kustomize openapi info ` . To make the
70- newly fetched schema and swagger.go available:
70+ newly fetched schema and swagger.go available, update the
71+ file [ ` kubernetesapi/openapiinfo.go ` ] ( https://github.com/kubernetes-sigs/kustomize/blob/master/kyaml/openapi/kubernetesapi/openapiinfo.go ) .
72+
73+ Here is an example of what it looks like with v1.21.2. The version number needs to be updated in all five places that it appears:
7174
7275```
73- rm kubernetesapi/openapiinfo.go
74- make kubernetesapi/openapiinfo.go
76+ package kubernetesapi
77+
78+ import (
79+ "sigs.k8s.io/kustomize/kyaml/openapi/kubernetesapi/v1212"
80+ )
81+
82+ const Info = "{title:Kubernetes,version:v1.21.2}"
83+
84+ var OpenAPIMustAsset = map[string]func(string) []byte{
85+ "v1212": v1212.MustAsset,
86+ }
87+
88+ const DefaultOpenAPI = "v1212"
7589```
7690
7791## Partial regeneration
Original file line number Diff line number Diff line change 11// Copyright 2020 The Kubernetes Authors.
22// SPDX-License-Identifier: Apache-2.0
33
4- // Code generated by ./scripts/makeOpenApiInfoDotGo.sh; DO NOT EDIT.
5-
64package kubernetesapi
75
86import (
Original file line number Diff line number Diff line change @@ -9,16 +9,19 @@ import (
99
1010 openapi_v2 "github.com/google/gnostic/openapiv2"
1111 "google.golang.org/protobuf/proto"
12- v1212 "sigs.k8s.io/kustomize/kyaml/openapi/kubernetesapi/v1212 "
12+ "sigs.k8s.io/kustomize/kyaml/openapi/kubernetesapi"
1313)
1414
1515func BenchmarkProtoUnmarshal (t * testing.B ) {
16+ version := kubernetesOpenAPIDefaultVersion
17+
18+ // parse the swagger, this should never fail
1619 assetName := filepath .Join (
1720 "kubernetesapi" ,
18- "v1212" ,
21+ version ,
1922 "swagger.pb" )
2023
21- b := v1212 . MustAsset (assetName )
24+ b := kubernetesapi. OpenAPIMustAsset [ version ] (assetName )
2225
2326 for i := 0 ; i < t .N ; i ++ {
2427 // We parse protobuf and get an openapiv2.Document here.
Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ VERSION=$1
88
99cp $HOME /.kube/config /tmp/kubeconfig.txt | true
1010$MYGOBIN /kind create cluster --image kindest/node:$VERSION --name=getopenapidata
11- $MYGOBIN /kustomize openapi fetch > /tmp/new_swagger.json
11+
12+ # TODO (natasha41575) Add a `kustomize openapi fetch --proto` option
13+ kubectl proxy &
14+ curl -k -H " Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf" http://localhost:8001/openapi/v2 > /tmp/new_swagger.pb
15+
1216$MYGOBIN /kind delete cluster --name=getopenapidata
1317cp /tmp/kubeconfig.txt $HOME /.kube/config | true
1418mkdir -p kubernetesapi/" ${VERSION// .} "
15- cp /tmp/new_swagger.json kubernetesapi/" ${VERSION// .} " /swagger.json
19+ cp /tmp/new_swagger.pb kubernetesapi/" ${VERSION// .} " /swagger.pb
Original file line number Diff line number Diff line change @@ -9,4 +9,4 @@ VERSION=$1
99$MYGOBIN /go-bindata \
1010 --pkg " ${VERSION// .} " \
1111 -o kubernetesapi/" ${VERSION// .} " /swagger.go \
12- kubernetesapi/" ${VERSION// .} " /swagger.json
12+ kubernetesapi/" ${VERSION// .} " /swagger.pb
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments