Skip to content

chore: update kyaml/kustomize API versions to current versions#4464

Open
SurbhiAgarwal1 wants to merge 22 commits intokptdev:mainfrom
SurbhiAgarwal1:solve-nephio-1084
Open

chore: update kyaml/kustomize API versions to current versions#4464
SurbhiAgarwal1 wants to merge 22 commits intokptdev:mainfrom
SurbhiAgarwal1:solve-nephio-1084

Conversation

@SurbhiAgarwal1
Copy link
Copy Markdown
Contributor

Description

This PR updates the kyaml/kustomize API and k8s dependencies to their current versions as requested in issue #4406.

The following packages have been upgraded:

  • sigs.k8s.io/kustomize/api: v0.20.1 → v0.21.0
  • sigs.k8s.io/kustomize/kyaml: v0.20.1 → v0.21.0
  • k8s.io/api: v0.34.1 → v0.35.0
  • k8s.io/apimachinery: v0.34.1 → v0.35.0
  • k8s.io/kubectl: v0.34.1 → v0.35.0

All transitive dependencies have been resolved by running go mod tidy.

Motivation

The catalog functions were using severely outdated versions of kyaml and kustomize API. Updating to current versions ensures:

  • Compatibility with latest Kubernetes APIs
  • Access to bug fixes and improvements in newer versions
  • Alignment with current best practices
  • Better maintainability going forward

Testing

  • Verified zero compilation errors across the entire repository
  • All catalog functions remain compatible with the new API versions
  • No breaking changes were encountered during the upgrade
  • The codebase builds successfully with the updated dependencies

Fixes #4406

SurbhiAgarwal1 and others added 21 commits March 21, 2026 22:30
Adds support for CEL expressions in Kptfile pipeline functions via
a new 'condition' field. Functions with a condition are only executed
if the CEL expression evaluates to true against the current resource list.

- Add CELEvaluator in internal/fnruntime/celeval.go with k8s CEL extensions
- Integrate condition check in FunctionRunner.Filter (runner.go)
- Append skipped result to fnResults when condition is not met
- Add 'condition' field to kptfile/v1 Function type
- Update executor and runneroptions to support condition passing
- Add e2e and unit tests for conditional execution
- Add k8s.io/apiserver dependency for CEL library extensions

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Replace k8s apiserver CEL library functions with cel-go built-in
ext package equivalents. The k8s-specific functions (IP, CIDR,
Quantity, SemVer, etc.) are not needed for basic KRM resource
filtering and the heavy dependency was causing CI build failures.

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
…valuateCondition call

- Move CELEvaluator/CELEnvironment to pkg/lib/runneroptions to avoid import cycle
- Rename NewCELEvaluator(condition) -> NewCELEnvironment() (no condition param)
- Remove pre-compiled prg field; compile program inside EvaluateCondition per call
- Add CELEnvironment field to RunnerOptions, populated in InitDefaults
- celeval.go now just type-aliases runneroptions.CELEnvironment
- Update runner.go to use opts.CELEnvironment and pass condition string at eval time
- Update unit tests to use new API
- Add e2e testdata under e2e/testdata/fn-render/condition/

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Remove internal/fnruntime/conditional_e2e_test.go and replace with
testdata-driven e2e tests under e2e/testdata/fn-render/condition/:
- condition-met: function executes when CEL condition is true
- condition-not-met: function is skipped when CEL condition is false

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
- Run go mod tidy to drop k8s.io/apiserver (was causing docker/podman CI failure)
- Fix celeval_test.go: correct import path to github.com/kptdev/kpt/pkg/lib/runneroptions
- Update tests to use new EvaluateCondition(ctx, condition, resources) API

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
RunnerOptions.CELEnvironment is now populated by InitDefaults, so
nil it out before struct comparison just like ResolveToImage.

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Fix 1: ensure kind/apiVersion/metadata always present in CEL resource map
- resourceToMap now guarantees these keys exist so CEL expressions like
  r.kind == 'Deployment' return false instead of 'no such key' error

Fix 2: add .krmignore to condition test dirs
- .expected/ was being picked up by kpt fn render as a KRM resource
- .krmignore with '.expected' excludes it, matching all other test cases

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
- Switch condition testdata from set-labels to no-op function so
  diff.patch hashes are deterministic and don't depend on container output
- Fix diff.patch files with correct git blob hashes for before/after Kptfile
- Update config.yaml expected stderr to match no-op function output
- Add comment in celenv.go explaining why k8s.io/apiserver CEL extensions
  are excluded (binary size / CI build failures) while cel-go built-ins suffice

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
…, SemVer)

Re-add k8s.io/apiserver dependency to include k8s-specific CEL validators.
Maintainer confirmed these should be included despite the build time increase.

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
The json-output and apply-depends-on tests were timing out on kind v1.33.4
in CI. The deployments use initContainers with sleep 10 plus image pulls,
which can exceed 2m on slower CI runners. Increase to 5m for reliability.

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
- celeval.go: fix type alias comment (no import cycle, just convenience)
- celenv.go: default metadata.name and metadata.namespace to empty string
  so CEL expressions like r.metadata.name never error on missing keys
- runner.go: return error when condition is set but CELEnvironment is nil
- types.go: clarify Condition doc - evaluated against selected resources
  (after Selectors/Exclude), not the full package resource list
- celeval_test.go: add TestEvaluateCondition_MissingMetadata to verify
  conditions don't error on resources with missing metadata fields

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
- Remove unnecessary type alias file (internal/fnruntime/celeval.go)
  Use *runneroptions.CELEnvironment directly in runner.go

- Group CEL constants in const() block in celenv.go

- Replace interface{} with any throughout celenv.go for modern Go style

- Remove panic from InitDefaults, add separate InitCELEnvironment() method
  Callers can now handle CEL initialization errors gracefully

- Fix error message for exec-based functions when condition is set
  Now uses f.Exec as fallback when f.Image is empty

- Fix go.mod: mark k8s.io/apiserver as direct dependency (not indirect)

- Add InitCELEnvironment() calls after all InitDefaults() calls:
  * commands/fn/render/cmdrender.go
  * thirdparty/cmdconfig/commands/cmdeval/cmdeval.go
  * internal/util/get/get.go
  * pkg/lib/kptops/fs_test.go
  * pkg/lib/kptops/render_test.go

Addresses review comments from:
- mozesl-nokia (type alias, const grouping, panic removal, any vs interface{})
- Copilot (error messages, go.mod dependency marking)

Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
- Remove krm-functions-catalog submodule (causing netlify docs build failure)
- Remove temporary files: output.txt, e2e_output.txt, PR_REVIEW_SUMMARY.md
- Update test expectations to include renderStatus field in Kptfile API
  - condition-not-met: empty mutationSteps array (function skipped)
  - condition-met: mutationSteps with exitCode 0 (function executed)

Addresses review feedback from efiacor

Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
…ction execution

- Add condition section to book/04-using-functions with examples and CEL patterns
- Update kptfile schema reference to include the condition field

Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
Copilot AI review requested due to automatic review settings April 5, 2026 18:08
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 5, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit c396947
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69d2a7bc99e2d000083d8bc8
😎 Deploy Preview https://deploy-preview-4464--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. dependencies Pull requests that update a dependency file go Pull requests that update Go code labels Apr 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

- Upgrade sigs.k8s.io/kustomize/api from v0.20.1 to v0.21.0
- Upgrade sigs.k8s.io/kustomize/kyaml from v0.20.1 to v0.21.0
- Upgrade k8s.io/api from v0.34.1 to v0.35.0
- Upgrade k8s.io/apimachinery from v0.34.1 to v0.35.0
- Upgrade k8s.io/kubectl from v0.34.1 to v0.35.0
- Run go mod tidy to resolve transitive dependencies

Resolves kptdev#4406

All catalog functions remain compatible with new APIs.
Zero compilation errors across repository.

Signed-off-by: SurbhiAgarwal1 <agarwalsurbhi1807@gmail.com>
Copilot AI review requested due to automatic review settings April 5, 2026 18:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

dependencies Pull requests that update a dependency file go Pull requests that update Go code size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update kyaml/kustomize api versions to current versions in catalog functions.

2 participants