Allow config references by resource name - #4667
Conversation
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds configRef support so Kptfile pipeline functions can reference an in-package resource (by kind/name, optionally apiVersion/namespace) as function config.
Changes:
- Extend Kptfile Function schema + validation to include
configRefand enforce mutual exclusivity withconfigMap/configPath. - Resolve
configRefat execution time for mutators/validators; explicitly reject it for lifecycle hooks. - Add unit/integration coverage and update e2e expected stderr for new validation messaging.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/lib/pkg/pkg.go | Validates configRef existence in package resources during pipeline validation. |
| pkg/lib/kptops/render_executor.go | Resolves configRef before running mutators/validators and injects as fn config. |
| pkg/lib/kptops/hook_executor.go | Rejects configRef usage in lifecycle hooks. |
| pkg/lib/kptops/configref_test.go | Adds renderer-level tests exercising configRef behavior. |
| pkg/fn/runtime/runner.go | Introduces ResolveConfigRef to find a referenced resource in the live input set. |
| pkg/fn/runtime/runner_test.go | Adds unit tests for ResolveConfigRef, including ambiguity handling. |
| api/kptfile/v1/types.go | Adds ResourceReference type and Function.ConfigRef field + matching helper. |
| api/kptfile/v1/validation.go | Validates configRef required fields and mutual exclusivity with other config sources. |
| api/kptfile/v1/validation_test.go | Adds validation tests for configRef (required fields, exclusivity, validators). |
| api/schema/v1/group_version.go | Refactors group parsing to use strings.Cut. |
| e2e/testdata/fn-render/multiple-fnconfig/.expected/config.yaml | Updates expected error output for new exclusivity validation message. |
| go.mod | Enables local replace for github.com/kptdev/kpt/api => ./api. |
| go.sum | Removes checksums for github.com/kptdev/kpt/api v0.0.2 due to local replace. |
Files not reviewed (1)
- api/kptfile/v1/zz_generated.deepcopy.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
|



Implements #3515.
This adds a
configReffield to the Kptfile Function spec so pipeline functions can reference config resources by kind and name (with optional apiVersion and namespace to narrow things down).Since this touches both the API module and the main module, I uncommented the
replace github.com/kptdev/kpt/api => ./apiline ingo.mod. I believe this is correct based on whatrelease/README.mdsays about local/CI builds using the workspace copy.But unsure since that doesn't align with the current codebase.