From 800eb9b92d2c64b1ef3b4a931c7e80c37ca72705 Mon Sep 17 00:00:00 2001 From: Maxim Goncharenko Date: Wed, 15 May 2019 16:15:16 +0300 Subject: [PATCH] Removed excess validation --- pkg/engine/generation.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pkg/engine/generation.go b/pkg/engine/generation.go index e5cb259942..9785487347 100644 --- a/pkg/engine/generation.go +++ b/pkg/engine/generation.go @@ -1,11 +1,9 @@ package engine import ( - "fmt" "log" kubepolicy "github.com/nirmata/kube-policy/pkg/apis/policy/v1alpha1" - "github.com/nirmata/kube-policy/pkg/engine/mutation" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -37,7 +35,7 @@ func Generate(policy kubepolicy.Policy, rawResource []byte, gvk metav1.GroupVers continue } - ok, err := mutation.ResourceMeetsRules(rawResource, rule.ResourceDescription, gvk) + ok, err := ResourceMeetsRules(rawResource, rule.ResourceDescription, gvk) if err != nil { log.Printf("Rule has invalid data: rule number = %d, rule name = %s in policy %s, err: %v\n", i, rule.Name, policy.ObjectMeta.Name, err) continue @@ -62,17 +60,12 @@ func Generate(policy kubepolicy.Policy, rawResource []byte, gvk metav1.GroupVers // Applies "configMapGenerator" and "secretGenerator" described in PolicyRule // TODO: plan to support all kinds of generator func applyRuleGenerator(rawResource []byte, generator *kubepolicy.Generation) ([]GenerationResponse, error) { - var generateResps []GenerationResponse + var generationResponse []GenerationResponse if generator == nil { return nil, nil } - err := generator.Validate() - if err != nil { - return nil, fmt.Errorf("Generator for '%s' is invalid: %s", generator.Kind, err) - } - - namespaceName := mutation.ParseNameFromObject(rawResource) - generateResps = append(generateResps, GenerationResponse{generator, namespaceName}) - return generateResps, nil + namespaceName := ParseNameFromObject(rawResource) + generationResponse = append(generationResponse, GenerationResponse{generator, namespaceName}) + return generationResponse, nil }