Skip to content

fix: Improve CEL conditional execution consistency and test coverage - #4713

Open
aravindtga wants to merge 2 commits into
kptdev:mainfrom
Nordix:cel-condition-consistency
Open

fix: Improve CEL conditional execution consistency and test coverage#4713
aravindtga wants to merge 2 commits into
kptdev:mainfrom
Nordix:cel-condition-consistency

Conversation

@aravindtga

Copy link
Copy Markdown
Contributor

Description

  • What changed: Aligned CLI flag naming with YAML field (--when), fixed documentation output examples, refactored internal CEL utilities to use existing kyaml APIs, and added E2E test coverage for kpt fn eval --when and validator fn-config exclusion.
  • Why it's needed: The kpt fn eval CLI flag was named --condition while the Kptfile field is when, creating a user-facing inconsistency. The eval path lacked E2E test coverage, and there was no E2E test verifying that validators don't receive their own
    fn-config in the input resource list.
  • How it works: Renamed the CLI flag to --when, updated documentation to match actual output, refactored resourceToMap to delegate to RNode.Map(), corrected stale comments, and added E2E tests for eval/render condition scenarios and validator fn-config exclusion.

Type of Change

  • Bug fix
  • Enhancement
  • Tests

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:
- Kiro CLI to review, implement fixes, create E2E tests, and perform black-box validation of the CEL condition feature.

Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@netlify

netlify Bot commented Aug 20, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 14e0389
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a8718fdd1a6d8000829cd9a
😎 Deploy Preview https://deploy-preview-4713--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@aravindtga
aravindtga requested a balanced review from Copilot August 20, 2026 14:52
@aravindtga aravindtga self-assigned this Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns CEL conditional execution terminology across CLI and YAML, simplifies resource conversion, and expands E2E coverage.

Changes:

  • Renames fn eval --condition to --when.
  • Refactors CEL and GVK handling using existing APIs.
  • Adds render/eval condition and validator-exclusion tests.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
thirdparty/cmdconfig/commands/cmdeval/cmdeval.go Adds the --when flag.
pkg/test/runner/runner.go Passes conditions to eval tests.
pkg/test/runner/config.go Adds eval when configuration.
pkg/live/rgstream.go Simplifies GroupKind construction.
pkg/live/load.go Uses direct GVK comparisons.
pkg/lib/runneroptions/celenv.go Uses RNode.Map() and clarifies CEL documentation.
pkg/fn/runtime/condition_test.go Renames condition test fields.
e2e/testdata/fn-render/validator-excludes-own-fnconfig/starlark-val.yaml Defines validator exclusion assertion.
e2e/testdata/fn-render/validator-excludes-own-fnconfig/Kptfile Configures the validator test.
e2e/testdata/fn-render/validator-excludes-own-fnconfig/deployment.yaml Supplies validator test input.
e2e/testdata/fn-render/validator-excludes-own-fnconfig/.expected/diff.patch Records expected render status.
e2e/testdata/fn-render/condition/condition-mixed/resources.yaml Supplies mixed-condition input.
e2e/testdata/fn-render/condition/condition-mixed/Kptfile Defines matching and nonmatching conditions.
e2e/testdata/fn-render/condition/condition-mixed/.krmignore Excludes expected fixtures.
e2e/testdata/fn-render/condition/condition-mixed/.expected/diff.patch Verifies run and skipped statuses.
e2e/testdata/fn-render/condition/condition-mixed/.expected/config.yaml Verifies mixed-condition output.
e2e/testdata/fn-eval/condition-not-met/resources.yaml Supplies nonmatching eval input.
e2e/testdata/fn-eval/condition-not-met/.krmignore Excludes expected fixtures.
e2e/testdata/fn-eval/condition-not-met/.expected/config.yaml Verifies skipped eval behavior.
e2e/testdata/fn-eval/condition-met/resources.yaml Supplies matching eval input.
e2e/testdata/fn-eval/condition-met/.krmignore Excludes expected fixtures.
e2e/testdata/fn-eval/condition-met/.expected/config.yaml Verifies successful conditional eval.
e2e/testdata/fn-eval/condition-invalid-cel/resources.yaml Supplies invalid-CEL test input.
e2e/testdata/fn-eval/condition-invalid-cel/.krmignore Excludes expected fixtures.
e2e/testdata/fn-eval/condition-invalid-cel/.expected/config.yaml Verifies CEL compilation failure.
documentation/content/en/book/04-using-functions/_index.md Updates documented skipped output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread thirdparty/cmdconfig/commands/cmdeval/cmdeval.go
Comment thread thirdparty/cmdconfig/commands/cmdeval/cmdeval.go
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga
aravindtga force-pushed the cel-condition-consistency branch from 7eec6ae to 14e0389 Compare August 20, 2026 15:10
@aravindtga
aravindtga marked this pull request as ready for review August 20, 2026 15:23
@aravindtga
aravindtga requested review from a team August 20, 2026 15:23
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. area/fn-runtime KRM function runtime bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Aug 20, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/fn-runtime KRM function runtime bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants