Skip to content

fix: tighten Generation exclusivity rule and clarify template namespace docs - #116

Closed
realshuting wants to merge 1 commit into
kyverno:mainfrom
realshuting:fix/16331-template-crd-followups
Closed

realshuting wants to merge 1 commit into
kyverno:mainfrom
realshuting:fix/16331-template-crd-followups

Conversation

@realshuting

Copy link
Copy Markdown
Member

Explanation

Follow-up to #115, addressing review comments raised on kyverno/kyverno#16699.

Proposed Changes

  • Tighten the generate[] XValidation rule: has(self.expression) treated an explicitly empty expression: "" as set, so it passed CRD validation while Kyverno's compiler rejects it. The rule now requires a non-empty expression for expression mode, and treats an empty string as unset — consistent with compiler/runtime semantics.

    (has(self.expression) && self.expression != '' && !has(self.template)) ||
    ((!has(self.expression) || self.expression == '') && has(self.template))
    
  • Clarify GenerationTemplate.Value docs: the previous description said documents without metadata.namespace are treated as cluster-scoped, which is only true for cluster-scoped policies. Namespaced policies default missing namespaces to the policy namespace and reject cross-namespace targets. The field description now states both behaviors.

  • Regenerated CRDs, helm chart CRDs, and API docs.

Once merged, kyverno/kyverno#16699 will bump its dependency to pick up the corrected CRDs.

…ce docs

- The XValidation rule treated an explicitly empty expression as set,
  allowing 'expression: ""' alone to pass CRD validation while the
  compiler rejects it. Require a non-empty expression for expression
  mode; an empty string now counts as unset, matching compiler
  semantics.
- Clarify the GenerationTemplate.Value description: documents without
  metadata.namespace are cluster-scoped only for cluster-scoped
  policies; namespaced policies default them to the policy namespace
  and reject any other namespace.

Follow-up to kyverno#115 review comments on kyverno/kyverno#16699.

Signed-off-by: realshuting <shuting@nirmata.com>
@realshuting
realshuting deleted the fix/16331-template-crd-followups branch July 22, 2026 09:44
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