From d01d5226a6accfdf49b776f2e45db93c21e04fc9 Mon Sep 17 00:00:00 2001 From: NoSkillGirl Date: Tue, 7 Jul 2020 17:40:54 +0530 Subject: [PATCH] small fix --- pkg/kyverno/validate/command.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/kyverno/validate/command.go b/pkg/kyverno/validate/command.go index b0d83d9129..2693681ee6 100644 --- a/pkg/kyverno/validate/command.go +++ b/pkg/kyverno/validate/command.go @@ -40,16 +40,17 @@ func Command() *cobra.Command { invalidPolicyFound := false for _, policy := range policies { - // err = policyvalidate.Validate(utils.MarshalPolicy(*policy), nil, true, openAPIController) + if common.PolicyHasVariables(*policy) { + invalidPolicyFound = true + fmt.Printf("Policy %s is invalid.\n", policy.Name) + log.Log.Error(errors.New("'validate' does not support policies with variables"), "Policy "+policy.Name+" is invalid") + continue + } err := policy2.Validate(utils.MarshalPolicy(*policy), nil, true, openAPIController) if err != nil { - fmt.Printf("Policy %s is invalid.\n\n", policy.Name) + fmt.Printf("Policy %s is invalid.\n", policy.Name) log.Log.Error(err, "policy "+policy.Name+" is invalid") invalidPolicyFound = true - } else if common.PolicyHasVariables(*policy) { - invalidPolicyFound = true - fmt.Printf("Policy %s is invalid.\n\n", policy.Name) - log.Log.Error(errors.New("'validate' does not support policies with variables"), "Policy "+policy.Name+" is invalid") } else { fmt.Printf("Policy %s is valid.\n\n", policy.Name) }