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

fix: missing autogen rules in status (#4971)

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:
Charles-Edouard Brétéché 2022-10-14 19:02:10 +02:00 committed by GitHub
parent afe9036347
commit 1f3c429cd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@ import (
"github.com/kyverno/kyverno/pkg/config"
"github.com/kyverno/kyverno/pkg/controllers"
"github.com/kyverno/kyverno/pkg/tls"
"github.com/kyverno/kyverno/pkg/toggle"
controllerutils "github.com/kyverno/kyverno/pkg/utils/controller"
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
runtimeutils "github.com/kyverno/kyverno/pkg/utils/runtime"
@ -426,6 +427,17 @@ func (c *controller) updatePolicyStatuses(ctx context.Context) error {
policy = policy.CreateDeepCopy()
status := policy.GetStatus()
status.SetReady(ready)
if toggle.AutogenInternals.Enabled() {
var rules []kyvernov1.Rule
for _, rule := range autogen.ComputeRules(policy) {
if strings.HasPrefix(rule.Name, "autogen-") {
rules = append(rules, rule)
}
}
status.Autogen.Rules = rules
} else {
status.Autogen.Rules = nil
}
if policy.GetNamespace() == "" {
_, err := c.kyvernoClient.KyvernoV1().ClusterPolicies().UpdateStatus(ctx, policy.(*kyvernov1.ClusterPolicy), metav1.UpdateOptions{})
if err != nil {