From ee42b6a0d8e660e98eca8bac6592e93dc29697b7 Mon Sep 17 00:00:00 2001 From: Maartje Eyskens Date: Wed, 4 Mar 2020 15:06:07 +0100 Subject: [PATCH] Try to make code more clear Signed-off-by: Maartje Eyskens --- hack/filter-crd/main.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/hack/filter-crd/main.go b/hack/filter-crd/main.go index 87c0c33f9..2f4fe4e55 100644 --- a/hack/filter-crd/main.go +++ b/hack/filter-crd/main.go @@ -28,7 +28,7 @@ import ( ) var removeKeys = []string{} -var removeSliceElemForValue = map[string]string{} +var removeElementForValue = map[string]string{} var checkValidationLocation = false func main() { @@ -103,11 +103,6 @@ func checkChain(d map[interface{}]interface{}, chain []string) { } } - // checks if keys need to be removed when a value is set - if value, ok := removeSliceElemForValue[strings.Join(chain, "/")]; ok && value == v.(string) { - // TODO - } - if value, ok := v.(map[interface{}]interface{}); ok { checkChain(value, chain) } @@ -133,7 +128,7 @@ func checkSliceChain(s []interface{}, chain []string) []interface{} { } } - if value, ok := removeSliceElemForValue[strings.Join(chain, "/")]; ok && value == v.(string) { + if value, ok := removeElementForValue[strings.Join(chain, "/")]; ok && value == v.(string) { s = removeFromSlice(s, d) } @@ -172,7 +167,7 @@ func loadVariant() { flag.Parse() if variant == "cert-manager-legacy" { - // These are the keys that the script will remove for OpenShift compatibility + // These are the keys that the script will remove for OpenShift 3 and older Kubernetes compatibility removeKeys = []string{ "spec/preserveUnknownFields", "spec/validation/openAPIV3Schema/type", @@ -180,7 +175,8 @@ func loadVariant() { "spec/conversion", } - removeSliceElemForValue = map[string]string{ + // this removed the whole version slice element if version name is `v1alpha3` + removeElementForValue = map[string]string{ "spec/versions/[]/name": "v1alpha3", }