Skip to content

fix(kyverno): count template-form GeneratingPolicy targets - #1572

Open
hisco wants to merge 1 commit into
mainfrom
eyal/rad-403-kyverno-generatingpolicy-count
Open

fix(kyverno): count template-form GeneratingPolicy targets#1572
hisco wants to merge 1 commit into
mainfrom
eyal/rad-403-kyverno-generatingpolicy-count

Conversation

@hisco

@hisco hisco commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Problem

A modern Kyverno GeneratingPolicy (policies.kyverno.io) declares each spec.generate[] target as exactly one of a CEL expression or a template.value (YAML). Radar's getKyvernoGenerations read only expression, 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 by getKyvernoMutations in 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 GeneratingPolicy resources in the k8s UI. Each spec.generate[] entry can declare what gets created via a CEL expression or a YAML template.value; getKyvernoGenerations only read expression, so template-only policies showed Generates (0) and hid the list in KyvernoGeneratingPolicyRenderer.

The accessor now returns g?.expression || g?.template?.value (same alternate-key pattern as getKyvernoMutations). Tests cover expression, template, mixed, and empty/absent generate blocks.

Reviewed by Cursor Bugbot for commit e0af129. Bugbot is set up for automated code reviews on this repo. Configure here.

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
@hisco
hisco requested a review from nadaverell as a code owner August 31, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant