Proposed solution for sub sub chart alias bug

Signed-off-by: Jonas Lergell <jonaslergell@gmail.com>
pull/10381/head
Jonas Lergell 4 years ago
parent 3721937d74
commit faf84d1fcf

@ -47,6 +47,23 @@ type Dependency struct {
ImportValues []interface{} `json:"import-values,omitempty"`
// Alias usable alias to be used for the chart
Alias string `json:"alias,omitempty"`
originalName string
}
// SetNameFromAlias sets originalName if empty, so can be called multiple times.
// This assumes that the first time SetNameFromAlias is called, d.Name is the name as
// specified in the dependency's Chart.yaml
func (d *Dependency) SetNameFromAlias() {
if d.originalName == "" {
d.originalName = d.Name
}
d.Name = d.Alias
}
// EqualName returns true if the dependency's name or originalName is equal to the given name.
func (d *Dependency) EqualName(name string) bool {
return d.Name == name || d.originalName == name
}
// Validate checks for common problems with the dependency datastructure in

@ -95,7 +95,7 @@ func getAliasDependency(charts []*chart.Chart, dep *chart.Dependency) *chart.Cha
if c == nil {
continue
}
if c.Name() != dep.Name {
if !dep.EqualName(c.Name()) {
continue
}
if !IsCompatibleRange(dep.Version, c.Metadata.Version) {
@ -129,7 +129,7 @@ func processDependencyEnabled(c *chart.Chart, v map[string]interface{}, path str
Loop:
for _, existing := range c.Dependencies() {
for _, req := range c.Metadata.Dependencies {
if existing.Name() == req.Name && IsCompatibleRange(req.Version, existing.Metadata.Version) {
if req.EqualName(existing.Name()) && IsCompatibleRange(req.Version, existing.Metadata.Version) {
continue Loop
}
}
@ -141,7 +141,7 @@ Loop:
chartDependencies = append(chartDependencies, chartDependency)
}
if req.Alias != "" {
req.Name = req.Alias
req.SetNameFromAlias()
}
}
c.SetDependencies(chartDependencies...)

Loading…
Cancel
Save