fix(kyverno): count template-form GeneratingPolicy targets - #1572
Open
hisco wants to merge 1 commit into
Open
Conversation
A modern GeneratingPolicy declares each generated target as exactly one of a CEL expression or a YAML template. getKyvernoGenerations read only the expression form, so a template-form policy rendered Generates (0) and its target list was empty. Read template.value as well, mirroring how getKyvernoMutations reads its alternate-shaped key. Claude-Session: https://claude.ai/code/session_01KxZ3xt2G4KpexrKSoXQ91S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A modern Kyverno
GeneratingPolicy(policies.kyverno.io) declares eachspec.generate[]target as exactly one of a CELexpressionor atemplate.value(YAML). Radar'sgetKyvernoGenerationsread onlyexpression, so a GeneratingPolicy written in the template form rendered "Generates (0)" with an empty target list.Fix
Read the template form too —
g?.expression || g?.template?.value— mirroring the existing alternate-key accessor pattern used bygetKyvernoMutationsin the same file. Upstream forbids both keys in one entry, so entry count stays one-per-target.Tests
Added coverage: expression-form (regression), template-form (now counted), mixed (=2), empty/absent (=[]) — the template and mixed assertions fail against the pre-fix code. Full k8s-ui suite passes with no regressions.
Ticket: RAD-403 (Velero/CNPG/Kyverno review).
https://claude.ai/code/session_01KxZ3xt2G4KpexrKSoXQ91S
Note
Low Risk
Localized Kyverno modern policy display logic with regression tests; no auth, data, or API changes.
Overview
Fixes under-counted generation targets for modern Kyverno
GeneratingPolicyresources in the k8s UI. Eachspec.generate[]entry can declare what gets created via a CELexpressionor a YAMLtemplate.value;getKyvernoGenerationsonly readexpression, so template-only policies showed Generates (0) and hid the list inKyvernoGeneratingPolicyRenderer.The accessor now returns
g?.expression || g?.template?.value(same alternate-key pattern asgetKyvernoMutations). Tests cover expression, template, mixed, and empty/absentgenerateblocks.Reviewed by Cursor Bugbot for commit e0af129. Bugbot is set up for automated code reviews on this repo. Configure here.