Skip to content

Simplify ImageResolveFunc#4431

Open
mozesl-nokia wants to merge 2 commits intokptdev:mainfrom
nokia:simple-resolve-func
Open

Simplify ImageResolveFunc#4431
mozesl-nokia wants to merge 2 commits intokptdev:mainfrom
nokia:simple-resolve-func

Conversation

@mozesl-nokia
Copy link
Contributor

ImageResolveFunc and ResolveToImageForCLIFunc were overly complicated and unnecessary had RunnerOptions as a receiver.

Removed the context arg, the error from the return value and the receiver.

Copilot AI review requested due to automatic review settings March 13, 2026 15:35
@netlify
Copy link

netlify bot commented Mar 13, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 571beaf
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69b4368828f7380007e06ea6
😎 Deploy Preview https://deploy-preview-4431--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.

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Copy link
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.

Pull request overview

This PR simplifies image resolution by refactoring ImageResolveFunc/ResolveToImageForCLIFunc to remove the context.Context parameter, error return, and unnecessary RunnerOptions receiver, and then updates call sites accordingly.

Changes:

  • Refactor ImageResolveFunc to func(image string) string and update ResolveToImageForCLIFunc accordingly.
  • Update various runners/commands to call ResolveToImage(...) without context/error handling.
  • Adjust tests and small formatting accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
thirdparty/kyaml/runfn/runfn.go Update function image resolution call site to new ResolveToImage(image) signature.
thirdparty/cmdconfig/commands/cmdeval/cmdeval.go Remove ctx plumbing for CLI function config image resolution and update call site(s).
pkg/test/runner/runner.go Minor formatting (blank line removal).
pkg/lib/runneroptions/runneroptions.go Core API change: simplify resolver function type and factory; remove context/error/receiver.
internal/fnruntime/runner_test.go Update test to reflect resolver no longer returns an error.
internal/fnruntime/runner.go Update runner initialization to use new resolver signature without context/error.
commands/fn/doc/cmdfndoc.go Update doc command to use new resolver factory and signature; remove use of cobra context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.


// ImageResolveFunc is the type for a function that can resolve a partial image to a (more) fully-qualified name
type ImageResolveFunc func(ctx context.Context, image string) (string, error)
type ImageResolveFunc func(image string) string
Copy link
Contributor Author

@mozesl-nokia mozesl-nokia Mar 13, 2026

Choose a reason for hiding this comment

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

Are we expecting any users other than Porch (where the need for this change comes from)?
@liamfallon @efiacor

// If the function is a catalog function, it prepends `prefix`, e.g. "set-namespace:v0.1" --> prefix + "set-namespace:v0.1".
// A "/" is appended to `prefix` if it is not an empty string and does not end with a "/".
func (opts *RunnerOptions) ResolveToImageForCLIFunc(prefix string) func(_ context.Context, image string) (string, error) {
func ResolveToImageForCLIFunc(prefix string) func(image string) string {
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. area/fn-runtime KRM function runtime labels Mar 13, 2026
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
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 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