|
|
|
@ -59,21 +59,28 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
|
|
|
|
|
locked := make([]*chart.Dependency, len(reqs))
|
|
|
|
|
missing := []string{}
|
|
|
|
|
for i, d := range reqs {
|
|
|
|
|
var constraint *semver.Constraints
|
|
|
|
|
|
|
|
|
|
// Validate version early if set, regardless of local or remote
|
|
|
|
|
if d.Version != "" {
|
|
|
|
|
var err error
|
|
|
|
|
constraint, err = semver.NewConstraint(d.Version)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("dependency %q has an invalid version/constraint format: %w", d.Name, err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle local chart dependencies (empty repository)
|
|
|
|
|
if d.Repository == "" {
|
|
|
|
|
// Local chart subfolder - maintain backward compatibility
|
|
|
|
|
if _, err := GetLocalPath(filepath.Join("charts", d.Name), r.chartpath); err != nil {
|
|
|
|
|
chartpath, err := GetLocalPath(filepath.Join("charts", d.Name), r.chartpath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For empty repository, determine version from local chart if not specified
|
|
|
|
|
version := d.Version
|
|
|
|
|
if version == "" {
|
|
|
|
|
chartpath, err := GetLocalPath(filepath.Join("charts", d.Name), r.chartpath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine version from local chart if not specified
|
|
|
|
|
if version == "" {
|
|
|
|
|
ch, err := loader.LoadDir(chartpath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -113,11 +120,6 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
|
|
|
|
|
|
|
|
|
|
// If version is specified, validate it against the local chart
|
|
|
|
|
if d.Version != "" {
|
|
|
|
|
constraint, err := semver.NewConstraint(d.Version)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("dependency %q has an invalid version/constraint format: %w", d.Name, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !constraint.Check(v) {
|
|
|
|
|
missing = append(missing, fmt.Sprintf("%q (repository %q, version %q)", d.Name, d.Repository, d.Version))
|
|
|
|
|
continue
|
|
|
|
@ -132,16 +134,6 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle remote repository dependencies
|
|
|
|
|
var constraint *semver.Constraints
|
|
|
|
|
if d.Version != "" {
|
|
|
|
|
var err error
|
|
|
|
|
constraint, err = semver.NewConstraint(d.Version)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("dependency %q has an invalid version/constraint format: %w", d.Name, err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
repoName := repoNames[d.Name]
|
|
|
|
|
// if the repository was not defined, but the dependency defines a repository url, bypass the cache
|
|
|
|
|
if repoName == "" && d.Repository != "" {
|
|
|
|
@ -216,7 +208,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
|
|
|
|
|
// Not a legit entry.
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if constraint == nil || constraint.Check(v) {
|
|
|
|
|
if constraint.Check(v) {
|
|
|
|
|
found = true
|
|
|
|
|
locked[i].Version = v.Original()
|
|
|
|
|
break
|
|
|
|
|