Skip to content

Allow config references by resource name - #4667

Open
OisinJohnston2005 wants to merge 7 commits into
kptdev:mainfrom
Nordix:allow-config-references-by-resource-name
Open

Allow config references by resource name#4667
OisinJohnston2005 wants to merge 7 commits into
kptdev:mainfrom
Nordix:allow-config-references-by-resource-name

Conversation

@OisinJohnston2005

Copy link
Copy Markdown
Contributor

Implements #3515.

This adds a configRef field 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 => ./api line in go.mod. I believe this is correct based on what release/README.md says about local/CI builds using the workspace copy.

But unsure since that doesn't align with the current codebase.

Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 59c5334
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a6b6f7496e3a600086e50ed
😎 Deploy Preview https://deploy-preview-4667--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.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. area/fn-runtime KRM function runtime enhancement New feature or request go Pull requests that update Go code labels Jul 27, 2026
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>
@liamfallon
liamfallon requested a review from Copilot July 28, 2026 16:40

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

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 configRef and enforce mutual exclusivity with configMap/configPath.
  • Resolve configRef at 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.

Comment thread pkg/lib/pkg/pkg.go Outdated
Comment thread pkg/fn/runtime/runner.go
Comment thread pkg/lib/kptops/configref_test.go
Comment thread go.mod
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
@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 enhancement New feature or request go Pull requests that update Go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants