Skip to content

Commit

Permalink
fix list of autogen rules
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
Frank Jogeleit committed Mar 25, 2024
1 parent a6ae859 commit d9b3925
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions plugins/kyverno/pkg/server/v1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,19 @@ func (h *APIHandler) Exception(ctx *gin.Context) {
kinds = append(kinds, "Pod")

for i, policy := range request.Policies {
if len(policy.Rules) == 1 && strings.HasPrefix(policy.Rules[0], "autogen-cronjob-") {
request.Policies[i].Rules = append(
policy.Rules,
strings.Replace(policy.Rules[0], "autogen-cronjob-", "autogen-", 1),
strings.TrimPrefix(policy.Rules[0], "autogen-cronjob-"),
)
} else if len(policy.Rules) == 1 && strings.HasPrefix(policy.Rules[0], "autogen-") {
request.Policies[i].Rules = append(
policy.Rules,
strings.TrimPrefix(policy.Rules[0], "autogen-"),
)
for _, rule := range policy.Rules {
if strings.HasPrefix(rule, "autogen-cronjob-") {
request.Policies[i].Rules = append(
policy.Rules,
strings.Replace(rule, "autogen-cronjob-", "autogen-", 1),
strings.TrimPrefix(rule, "autogen-cronjob-"),
)
} else if strings.HasPrefix(rule, "autogen-") {
request.Policies[i].Rules = append(
policy.Rules,
strings.TrimPrefix(rule, "autogen-"),
)
}
}
}
}
Expand Down

0 comments on commit d9b3925

Please sign in to comment.