Skip to content

Commit

Permalink
feat: use pointer in rule (generate field) (kyverno#11076)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Sep 10, 2024
1 parent bcf6075 commit 12edb6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/kyverno/v2beta1/rule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Rule struct {

// Generation is used to create new resources.
// +optional
Generation kyvernov1.Generation `json:"generate,omitempty"`
Generation *kyvernov1.Generation `json:"generate,omitempty"`

// VerifyImages is used to verify image signatures and mutate them to add a digest
// +optional
Expand Down Expand Up @@ -134,7 +134,7 @@ func (r *Rule) HasValidate() bool {

// HasGenerate checks for generate rule
func (r *Rule) HasGenerate() bool {
return !datautils.DeepEqual(r.Generation, kyvernov1.Generation{})
return r.Generation != nil && !datautils.DeepEqual(*r.Generation, kyvernov1.Generation{})
}

// ValidateRuleType checks only one type of rule is defined per rule
Expand Down
6 changes: 5 additions & 1 deletion api/kyverno/v2beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12edb6d

Please sign in to comment.