From 35ba0d7836beade49dc0f6dd04d839e99293d11c Mon Sep 17 00:00:00 2001 From: natasha41575 Date: Fri, 5 Aug 2022 15:23:07 -0500 Subject: [PATCH] code review --- kyaml/openapi/README.md | 9 +++++++-- kyaml/openapi/openapi.go | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kyaml/openapi/README.md b/kyaml/openapi/README.md index 52e053a842..3bffb952ca 100644 --- a/kyaml/openapi/README.md +++ b/kyaml/openapi/README.md @@ -31,14 +31,19 @@ You may need to update the version of Kind these scripts use by changing `KIND_V In this directory, fetch the openapi schema, generate the corresponding swagger.go for the kubernetes api, and update `kubernetesapi/openapiinfo.go`: +``` +make all +``` + +If you want to run the steps individually instead of using `make all`, you can run +the following commands: + ``` make kustomizationapi/swagger.go make kubernetesapi/swagger.go make kubernetesapi/openapiinfo.go ``` -Then, follow the instructions in the next section to make the newly generated schema available for use. - You can optionally delete the old `swagger.pb` and `swagger.go` files if we no longer need to support that kubernetes version of openapi data. Make sure you rerun `make kubernetesapi/openapiinfo.go` after deleting any old schemas. diff --git a/kyaml/openapi/openapi.go b/kyaml/openapi/openapi.go index 8c6422b18e..9b302070d0 100644 --- a/kyaml/openapi/openapi.go +++ b/kyaml/openapi/openapi.go @@ -573,13 +573,13 @@ func SetSchema(openAPIField map[string]string, schema []byte, reset bool) error // use builtin version kubernetesOpenAPIVersion = version - if version == "" { - version = kubernetesapi.DefaultOpenAPI + if kubernetesOpenAPIVersion == "" { + return nil } - - if _, ok := kubernetesapi.OpenAPIMustAsset[version]; !ok { + if _, ok := kubernetesapi.OpenAPIMustAsset[kubernetesOpenAPIVersion]; !ok { return fmt.Errorf("the specified OpenAPI version is not built in") } + customSchema = nil // if the schema is changed, initSchema should parse the new schema globalSchema.schemaInit = false