chore: update kyaml/kustomize API versions to current versions#4464
Open
SurbhiAgarwal1 wants to merge 22 commits intokptdev:mainfrom
Open
chore: update kyaml/kustomize API versions to current versions#4464SurbhiAgarwal1 wants to merge 22 commits intokptdev:mainfrom
SurbhiAgarwal1 wants to merge 22 commits intokptdev:mainfrom
Conversation
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>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
af3afe9 to
8092aaf
Compare
- 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>
8092aaf to
c396947
Compare
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.
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.0sigs.k8s.io/kustomize/kyaml: v0.20.1 → v0.21.0k8s.io/api: v0.34.1 → v0.35.0k8s.io/apimachinery: v0.34.1 → v0.35.0k8s.io/kubectl: v0.34.1 → v0.35.0All 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:
Testing
Fixes #4406