feat(oci): allow host-less repos complemented by the KPM_REG envvar#346
Open
cjuega wants to merge 1 commit into
Open
feat(oci): allow host-less repos complemented by the KPM_REG envvar#346cjuega wants to merge 1 commit into
cjuega wants to merge 1 commit into
Conversation
Author
|
Be aware we need the changes in this PR before merging this. So we still have to bump |
Signed-off-by: Carlos Juega <carlosjuegasi@gmail.com>
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.
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
KPM_REGkpm#739)2. What is the scope of this PR (e.g. component or file name):
cmd/kcl/commands/args.go,cmd/kcl/commands/mod_add.go,cmd/kcl/commands/args_test.go3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
Allow
--ocito accept a bare repository path with no scheme and no host(e.g.
myorg/kcl-templates/utils). Whenurl.Parsereturns an empty schemethe argument is now treated as a host-less reference and an
Ocisource isbuilt with
RegFromEnv: true, so KPM resolves the registry at runtime from theKPM_REGenvironment variable orDefaultOciRegistry.Previously, the same input would fall into the scheme-rewriting branch, which
prepended
oci://to an already schemeless string and produced a malformed URL.This is useful for multi-account or air-gapped deployments where the same
kcl.modmust work against different registries without being modified:export KPM_REG=123456789012.dkr.ecr.eu-west-1.amazonaws.com kcl mod add --oci myorg/kcl-templates/utils --tag 0.2.0Full OCI URLs (
oci://ghcr.io/...,https://ghcr.io/...) are unaffected.4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
The existing behaviour for fully-qualified OCI URLs is preserved unchanged.
The new code path is only reached when
url.Parsereturns an empty scheme,which previously produced a malformed URL and would have errored downstream.
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:
Four unit tests added in
cmd/kcl/commands/args_test.go:TestParseSourceFromArgs_HostlessOciRegFromEnv=true, registry emptyTestParseSourceFromArgs_HostnameWithoutSchemeghcr.io/…without scheme → treated as bare path (Go'surl.Parsecannot detect a host without://); documents the edge-case behaviour explicitlyTestParseSourceFromArgs_FullOciUrloci://host/repoURL →Regpopulated,RegFromEnv=false(regression guard)TestParseSourceFromArgs_HostlessOciWithModSpecname:version+ host-less--oci→ bothOciandModSpecfields populated correctly