Merge 314c1039ab into eb1ff724ea
This commit is contained in:
commit
6c5be940a7
|
|
@ -906,7 +906,11 @@ func (r *OCIRepositoryReconciler) getTagBySemver(repo name.Repository, exp strin
|
||||||
|
|
||||||
var matchingVersions []*semver.Version
|
var matchingVersions []*semver.Version
|
||||||
for _, t := range validTags {
|
for _, t := range validTags {
|
||||||
v, err := version.ParseVersion(t)
|
// Helm translates `+` to `_` in OCI tags, because `+` is not a valid tag character.
|
||||||
|
versionStr := strings.Replace(t, "_", "+", 1)
|
||||||
|
// It would be even better to use `org.opencontainers.image.version` annotation
|
||||||
|
// if present, but that adds a fetch for each tag.
|
||||||
|
v, err := version.ParseVersion(versionStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -921,7 +925,8 @@ func (r *OCIRepositoryReconciler) getTagBySemver(repo name.Repository, exp strin
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(sort.Reverse(semver.Collection(matchingVersions)))
|
sort.Sort(sort.Reverse(semver.Collection(matchingVersions)))
|
||||||
return repo.Tag(matchingVersions[0].Original()), nil
|
asTag := strings.Replace(matchingVersions[0].Original(), "+", "_", 1)
|
||||||
|
return repo.Tag(asTag), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// keychain generates the credential keychain based on the resource
|
// keychain generates the credential keychain based on the resource
|
||||||
|
|
|
||||||
|
|
@ -2867,6 +2867,7 @@ func TestOCIRepository_getArtifactRef(t *testing.T) {
|
||||||
"6.1.5",
|
"6.1.5",
|
||||||
"6.1.6-rc.1",
|
"6.1.6-rc.1",
|
||||||
"6.1.6",
|
"6.1.6",
|
||||||
|
"6.1.7_ref.1234567", // Version 6.1.7+ref.1234567, encoded as a tag
|
||||||
)
|
)
|
||||||
g.Expect(err).ToNot(HaveOccurred())
|
g.Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
|
@ -2899,12 +2900,12 @@ func TestOCIRepository_getArtifactRef(t *testing.T) {
|
||||||
want: "ghcr.io/stefanprodan/charts@" + imgs["6.1.6"].digest.String(),
|
want: "ghcr.io/stefanprodan/charts@" + imgs["6.1.6"].digest.String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid url with semver reference",
|
name: "valid url with semver reference and build identifier",
|
||||||
url: fmt.Sprintf("oci://%s/podinfo", server.registryHost),
|
url: fmt.Sprintf("oci://%s/podinfo", server.registryHost),
|
||||||
reference: &sourcev1.OCIRepositoryRef{
|
reference: &sourcev1.OCIRepositoryRef{
|
||||||
SemVer: ">= 6.1.6",
|
SemVer: ">= 6.1.6",
|
||||||
},
|
},
|
||||||
want: server.registryHost + "/podinfo:6.1.6",
|
want: server.registryHost + "/podinfo:6.1.7_ref.1234567",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid url without oci prefix",
|
name: "invalid url without oci prefix",
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue