mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Merge pull request #10578 from sabre1041/oci-tag-evaluation
Limits need to call tag API when explicit version specified
This commit is contained in:
commit
86a94f2f53
1 changed files with 25 additions and 15 deletions
|
|
@ -23,6 +23,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"helm.sh/helm/v3/internal/fileutil"
|
||||
|
|
@ -141,22 +142,31 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven
|
|||
}
|
||||
|
||||
func (c *ChartDownloader) getOciURI(ref, version string, u *url.URL) (*url.URL, error) {
|
||||
// Retrieve list of repository tags
|
||||
tags, err := c.RegistryClient.Tags(strings.TrimPrefix(ref, fmt.Sprintf("%s://", registry.OCIScheme)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(tags) == 0 {
|
||||
return nil, errors.Errorf("Unable to locate any tags in provided repository: %s", ref)
|
||||
}
|
||||
var tag string
|
||||
var err error
|
||||
|
||||
// Determine if version provided
|
||||
// If empty, try to get the highest available tag
|
||||
// If exact version, try to find it
|
||||
// If semver constraint string, try to find a match
|
||||
tag, err := registry.GetTagMatchingVersionOrConstraint(tags, version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// Evaluate whether an explicit version has been provided. Otherwise, determine version to use
|
||||
_, errSemVer := semver.NewVersion(version)
|
||||
if errSemVer == nil {
|
||||
tag = version
|
||||
} else {
|
||||
// Retrieve list of repository tags
|
||||
tags, err := c.RegistryClient.Tags(strings.TrimPrefix(ref, fmt.Sprintf("%s://", registry.OCIScheme)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(tags) == 0 {
|
||||
return nil, errors.Errorf("Unable to locate any tags in provided repository: %s", ref)
|
||||
}
|
||||
|
||||
// Determine if version provided
|
||||
// If empty, try to get the highest available tag
|
||||
// If exact version, try to find it
|
||||
// If semver constraint string, try to find a match
|
||||
tag, err = registry.GetTagMatchingVersionOrConstraint(tags, version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
u.Path = fmt.Sprintf("%s:%s", u.Path, tag)
|
||||
|
|
|
|||
Loading…
Reference in a new issue