mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 02:18:15 +00:00
fix: don't process non background policies in background scan (#5008)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
02e832a771
commit
a89fbac333
2 changed files with 11 additions and 1 deletions
|
@ -203,7 +203,7 @@ func (c *controller) updateReport(ctx context.Context, meta metav1.Object, gvk s
|
|||
policies = append(policies, pols...)
|
||||
}
|
||||
// load background policies
|
||||
backgroundPolicies := utils.RemoveNonValidationPolicies(logger, policies...)
|
||||
backgroundPolicies := utils.RemoveNonBackgroundPolicies(logger, policies...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -30,6 +30,16 @@ func BuildKindSet(logger logr.Logger, policies ...kyvernov1.PolicyInterface) set
|
|||
return kinds
|
||||
}
|
||||
|
||||
func RemoveNonBackgroundPolicies(logger logr.Logger, policies ...kyvernov1.PolicyInterface) []kyvernov1.PolicyInterface {
|
||||
var backgroundPolicies []kyvernov1.PolicyInterface
|
||||
for _, pol := range policies {
|
||||
if CanBackgroundProcess(logger, pol) {
|
||||
backgroundPolicies = append(backgroundPolicies, pol)
|
||||
}
|
||||
}
|
||||
return backgroundPolicies
|
||||
}
|
||||
|
||||
func RemoveNonValidationPolicies(logger logr.Logger, policies ...kyvernov1.PolicyInterface) []kyvernov1.PolicyInterface {
|
||||
var validationPolicies []kyvernov1.PolicyInterface
|
||||
for _, pol := range policies {
|
||||
|
|
Loading…
Add table
Reference in a new issue