1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 10:28:36 +00:00

feat: use pointer in rule (generate field) (#11076)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2024-09-10 15:56:00 +02:00 committed by GitHub
parent bcf6075fd1
commit 12edb6d405
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -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
@ -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

View file

@ -744,7 +744,11 @@ func (in *Rule) DeepCopyInto(out *Rule) {
}
in.Mutation.DeepCopyInto(&out.Mutation)
in.Validation.DeepCopyInto(&out.Validation)
in.Generation.DeepCopyInto(&out.Generation)
if in.Generation != nil {
in, out := &in.Generation, &out.Generation
*out = new(v1.Generation)
(*in).DeepCopyInto(*out)
}
if in.VerifyImages != nil {
in, out := &in.VerifyImages, &out.VerifyImages
*out = make([]ImageVerification, len(*in))