From e16d77395748439c8386e8836b2eb78f693dce46 Mon Sep 17 00:00:00 2001 From: Sachin <57769917+slayer321@users.noreply.github.com> Date: Mon, 11 Oct 2021 12:46:28 -0700 Subject: [PATCH] Remove unused function (#2517) --- pkg/engine/mutate/overlay.go | 4 ++-- pkg/engine/validate/validate.go | 9 --------- pkg/engine/variables/evaluate_test.go | 2 +- pkg/leaderelection/leaderelection.go | 1 - scripts/create-e2e-infrastruture.sh | 1 - test/e2e/validate/validate_test.go | 2 -- 6 files changed, 3 insertions(+), 16 deletions(-) diff --git a/pkg/engine/mutate/overlay.go b/pkg/engine/mutate/overlay.go index d103705eab..025523f1a2 100644 --- a/pkg/engine/mutate/overlay.go +++ b/pkg/engine/mutate/overlay.go @@ -227,11 +227,11 @@ func applyOverlayToMap(resourceMap, overlayMap map[string]interface{}, path stri func applyOverlayToArray(resource, overlay []interface{}, path string) ([][]byte, error) { var appliedPatches [][]byte - if 0 == len(overlay) { + if len(overlay) == 0 { return nil, errors.New("Empty array detected in the overlay") } - if 0 == len(resource) { + if len(resource) == 0 { // If array resource is empty, insert part from overlay patch, err := insertSubtree(overlay, path) if err != nil { diff --git a/pkg/engine/validate/validate.go b/pkg/engine/validate/validate.go index 45b7d5957a..d0b1b96bef 100644 --- a/pkg/engine/validate/validate.go +++ b/pkg/engine/validate/validate.go @@ -8,7 +8,6 @@ import ( "github.com/go-logr/logr" "github.com/kyverno/kyverno/pkg/engine/anchor" "github.com/kyverno/kyverno/pkg/engine/common" - "github.com/kyverno/kyverno/pkg/engine/operator" "github.com/kyverno/kyverno/pkg/engine/wildcards" ) @@ -241,11 +240,3 @@ func validateArrayOfMaps(log logr.Logger, resourceMapArray []interface{}, patter } return "", nil } - -func isStringIsReference(str string) bool { - if len(str) < len(operator.ReferenceSign) { - return false - } - - return str[0] == '$' && str[1] == '(' && str[len(str)-1] == ')' -} diff --git a/pkg/engine/variables/evaluate_test.go b/pkg/engine/variables/evaluate_test.go index d4823d7874..33d992576f 100644 --- a/pkg/engine/variables/evaluate_test.go +++ b/pkg/engine/variables/evaluate_test.go @@ -1562,7 +1562,7 @@ func Test_Eval_Equal_Var_Pass(t *testing.T) { err = json.Unmarshal(conditionJSON, &conditionMap) assert.Nil(t, err) - conditionWithResolvedVars, err := SubstituteAllInPreconditions(log.Log, ctx, conditionMap) + conditionWithResolvedVars, _ := SubstituteAllInPreconditions(log.Log, ctx, conditionMap) conditionJSON, err = json.Marshal(conditionWithResolvedVars) assert.Nil(t, err) diff --git a/pkg/leaderelection/leaderelection.go b/pkg/leaderelection/leaderelection.go index afd0f86b85..19ddcaebeb 100644 --- a/pkg/leaderelection/leaderelection.go +++ b/pkg/leaderelection/leaderelection.go @@ -38,7 +38,6 @@ type Interface interface { type Config struct { name string namespace string - id string startWork func() stopWork func() kubeClient kubernetes.Interface diff --git a/scripts/create-e2e-infrastruture.sh b/scripts/create-e2e-infrastruture.sh index 9151f5d32a..3af22ad56f 100755 --- a/scripts/create-e2e-infrastruture.sh +++ b/scripts/create-e2e-infrastruture.sh @@ -1,4 +1,3 @@ - #!/bin/sh set -e diff --git a/test/e2e/validate/validate_test.go b/test/e2e/validate/validate_test.go index 52bffe3f30..d581d66304 100644 --- a/test/e2e/validate/validate_test.go +++ b/test/e2e/validate/validate_test.go @@ -19,8 +19,6 @@ var ( policyGVR = e2e.GetGVR("kyverno.io", "v1", "clusterpolicies") // Namespace GVR namespaceGVR = e2e.GetGVR("", "v1", "namespaces") - // ConfigMap GVR - cmGVR = e2e.GetGVR("", "v1", "configmaps") crdGVR = e2e.GetGVR("apiextensions.k8s.io", "v1", "customresourcedefinitions")