From 9a210e24d9f5eb3997540022ffdf77fbda4ce1e4 Mon Sep 17 00:00:00 2001 From: shuting Date: Tue, 1 Sep 2020 17:23:54 -0700 Subject: [PATCH] bug fix - nil pointer (#1093) * add watch policy to clusterrole kyverno:customresources * fix build * fix nil pointer --- pkg/policymutation/cronjob.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/policymutation/cronjob.go b/pkg/policymutation/cronjob.go index bd88cbce5d..a08ee2084c 100644 --- a/pkg/policymutation/cronjob.go +++ b/pkg/policymutation/cronjob.go @@ -2,6 +2,7 @@ package policymutation import ( "fmt" + "reflect" "strings" "github.com/go-logr/logr" @@ -20,6 +21,10 @@ func generateCronJobRule(rule kyverno.Rule, controllers string, log logr.Logger) logger.V(3).Info("") jobRule := generateRuleForControllers(rule, "Job", logger) + if reflect.DeepEqual(jobRule, kyvernoRule{}) { + return kyvernoRule{} + } + cronJobRule := &jobRule cronJobRule.Name = fmt.Sprintf("autogen-cronjob-%s", rule.Name) cronJobRule.MatchResources.Kinds = []string{engine.PodControllerCronJob}