From 95e610b55a807f9a082e336cc35620be995806e9 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 | 6 ++++++ kyaml/openapi/openapi.go | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kyaml/openapi/README.md b/kyaml/openapi/README.md index 52e053a8420..0ac38523cfb 100644 --- a/kyaml/openapi/README.md +++ b/kyaml/openapi/README.md @@ -31,6 +31,12 @@ 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 +``` + +You can run the steps individually with the following commands: + ``` make kustomizationapi/swagger.go make kubernetesapi/swagger.go diff --git a/kyaml/openapi/openapi.go b/kyaml/openapi/openapi.go index 8c6422b18ed..7621499c152 100644 --- a/kyaml/openapi/openapi.go +++ b/kyaml/openapi/openapi.go @@ -573,13 +573,12 @@ func SetSchema(openAPIField map[string]string, schema []byte, reset bool) error // use builtin version kubernetesOpenAPIVersion = version - if version == "" { - version = kubernetesapi.DefaultOpenAPI + if kubernetesOpenAPIVersion != "" { + if _, ok := kubernetesapi.OpenAPIMustAsset[kubernetesOpenAPIVersion]; !ok { + return fmt.Errorf("the specified OpenAPI version is not built in") + } } - if _, ok := kubernetesapi.OpenAPIMustAsset[version]; !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