Make the image prefix configurable#4616
Conversation
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📄 Knowledge review✏️ Suggested updates3 page suggestions need review.
|
There was a problem hiding this comment.
Pull request overview
This PR addresses #4595 by making the default prefix used to expand short KRM function image names configurable at runtime, via a new KPT_IMAGE_PREFIX environment variable and (for relevant commands) a --image-prefix CLI flag. It refactors the image-resolution logic so Cobra can update the configured prefix at execution time rather than relying on a curried function stored in options.
Changes:
- Added
DefaultImagePrefix()(env var fallback) and refactoredRunnerOptionsto carryImagePrefixplus aResolveToImagemethod. - Added
--image-prefixflag wiring forfn renderandfn eval. - Updated command/test code to align with the
RunnerOptionsrefactor and adjusted behavior forfn doc.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| thirdparty/cmdconfig/commands/cmdeval/cmdeval.go | Adds --image-prefix flag for fn eval and uses RunnerOptions.ResolveToImage method. |
| thirdparty/cmdconfig/commands/cmdeval/cmdeval_test.go | Updates expected RunnerOptions shape due to refactor (now includes ImagePrefix). |
| pkg/lib/runneroptions/runneroptions.go | Introduces env-var-based defaulting and replaces ResolveToImage function field with ImagePrefix + method. |
| pkg/fn/runtime/wasmtime_unsupported.go | Tweaks unsupported-wasmtime error message and adds linter suppression (needs follow-up). |
| commands/fn/render/cmdrender.go | Adds --image-prefix flag for fn render. |
| commands/fn/doc/cmdfndoc.go | Switches to using DefaultImagePrefix() when resolving images for fn doc. |
💡 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>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
…al as well as render 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>
* Adding rules to CONTRIBUTING.md - Current CODEOWNER.md based rules for pr approvals. This will be changed ot the maintainer and contributor groups based rules once we agreed to apply them to all the repos. - Rules for stale prs Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> * Apply suggestions from code review Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Assisted-by: GitHub Copilot: Claude Haiku 4.5 Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
…ptdev#4605) Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Michael Greaves <michael.greaves@nokia.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com> Assisted-by: GitHub Copilot: Claude Haiku 4.5 Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Co-authored-by: Catalin Stratulat <159934629+Catalin-Stratulat-Ericsson@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Catalin-Stratulat-Ericsson <catalin.stratulat@ericsson.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
…es file overwrite (kptdev#4604) Signed-off-by: tar <gabor.tar.ext@nokia.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
* Specifying allowed alert types Signed-off-by: Dominika Schweier <dominika.schweier@nokia.com> * Specifying allowed alert types Signed-off-by: Dominika Schweier <dominika.schweier@nokia.com> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: Dominika Schweier <dominika.schweier@nokia.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
…4597) Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
2dcb9ae to
87be303
Compare
|
@OisinJohnston2005 Can you resolve the copilot comments please? |
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
This PR is resolving issue #4595, which requests the ability to configure the default prefix used when resolving image names into fully qualified urls, it asks for the ability to do so either by environment variable or command line argument, this PR implements both prioritising cli args and falling back to the environment variable and then the hard coded prefix.
In order to implement this I removed the
ResolveToImageForCLIfunction since its approach of currying the default image prefix into theResolveToImagefunction attribute on theRunnerOptionsstruct didn't allow Cobra to update the ImagePrefix on runtime.Instead I opted to implement
ResolveToImageas a method and added theImagePrefixattribute which is updated by cobra whenever a command is run, if no prefix is provided it first checks for the environment variableKPT_IMAGE_PREFIXif set it will use that as the image prefix if not it will useghcr.io/kptdev/krm-functions-catalog/