mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
fix: unsupported defaults in api (#11021)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
209fd8d90a
commit
02e27ec3d4
5 changed files with 17 additions and 3 deletions
|
@ -108,7 +108,7 @@ type Rule struct {
|
||||||
// generate and mutateExisting rules to those requests.
|
// generate and mutateExisting rules to those requests.
|
||||||
// +kubebuilder:default=true
|
// +kubebuilder:default=true
|
||||||
// +kubebuilder:validation:Optional
|
// +kubebuilder:validation:Optional
|
||||||
SkipBackgroundRequests bool `json:"skipBackgroundRequests,omitempty"`
|
SkipBackgroundRequests *bool `json:"skipBackgroundRequests,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasMutate checks for mutate rule
|
// HasMutate checks for mutate rule
|
||||||
|
|
|
@ -1415,6 +1415,11 @@ func (in *Rule) DeepCopyInto(out *Rule) {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.SkipBackgroundRequests != nil {
|
||||||
|
in, out := &in.SkipBackgroundRequests, &out.SkipBackgroundRequests
|
||||||
|
*out = new(bool)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ type Rule struct {
|
||||||
// generate and mutateExisting rules to those requests.
|
// generate and mutateExisting rules to those requests.
|
||||||
// +kubebuilder:default=true
|
// +kubebuilder:default=true
|
||||||
// +kubebuilder:validation:Optional
|
// +kubebuilder:validation:Optional
|
||||||
SkipBackgroundRequests bool `json:"skipBackgroundRequests,omitempty"`
|
SkipBackgroundRequests *bool `json:"skipBackgroundRequests,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasMutate checks for mutate rule
|
// HasMutate checks for mutate rule
|
||||||
|
|
|
@ -748,6 +748,11 @@ func (in *Rule) DeepCopyInto(out *Rule) {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.SkipBackgroundRequests != nil {
|
||||||
|
in, out := &in.SkipBackgroundRequests, &out.SkipBackgroundRequests
|
||||||
|
*out = new(bool)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,11 @@ func skipBackgroundRequests(policy kyvernov1.PolicyInterface, logger logr.Logger
|
||||||
policyNew := policy.CreateDeepCopy()
|
policyNew := policy.CreateDeepCopy()
|
||||||
policyNew.GetSpec().Rules = nil
|
policyNew.GetSpec().Rules = nil
|
||||||
for _, rule := range policy.GetSpec().Rules {
|
for _, rule := range policy.GetSpec().Rules {
|
||||||
if rule.SkipBackgroundRequests && (bgsaDesired == bgsaActual) {
|
skipBackgroundRequests := true
|
||||||
|
if rule.SkipBackgroundRequests != nil {
|
||||||
|
skipBackgroundRequests = *rule.SkipBackgroundRequests
|
||||||
|
}
|
||||||
|
if skipBackgroundRequests && (bgsaDesired == bgsaActual) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logger.V(4).Info("applying background rule", "rule", rule.Name, "skipBackgroundRequests", rule.SkipBackgroundRequests, "backgroundSaDesired", bgsaDesired, "backgroundSaActual", bgsaActual)
|
logger.V(4).Info("applying background rule", "rule", rule.Name, "skipBackgroundRequests", rule.SkipBackgroundRequests, "backgroundSaDesired", bgsaDesired, "backgroundSaActual", bgsaActual)
|
||||||
|
|
Loading…
Reference in a new issue