Commit 0440b54b authored by llsheldon's avatar llsheldon

fix(helm):Fix dependency aliaes not working

The alias functionality only works when a hardcoded version
is used. Any use of semver logic causes unexpected behavior.
I use version.IsCompatibleRange to check the dependency version.

Closes #2794
parent 4c1a4748
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/version"
) )
const ( const (
...@@ -230,7 +231,7 @@ func getAliasDependency(charts []*chart.Chart, aliasChart *Dependency) *chart.Ch ...@@ -230,7 +231,7 @@ func getAliasDependency(charts []*chart.Chart, aliasChart *Dependency) *chart.Ch
if existingChart.Metadata.Name != aliasChart.Name { if existingChart.Metadata.Name != aliasChart.Name {
continue continue
} }
if existingChart.Metadata.Version != aliasChart.Version { if !version.IsCompatibleRange(aliasChart.Version, existingChart.Metadata.Version) {
continue continue
} }
chartFound = *existingChart chartFound = *existingChart
...@@ -266,7 +267,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error { ...@@ -266,7 +267,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error {
for _, existingDependency := range c.Dependencies { for _, existingDependency := range c.Dependencies {
var dependencyFound bool var dependencyFound bool
for _, req := range reqs.Dependencies { for _, req := range reqs.Dependencies {
if existingDependency.Metadata.Name == req.Name && existingDependency.Metadata.Version == req.Version { if existingDependency.Metadata.Name == req.Name && version.IsCompatibleRange(req.Version, existingDependency.Metadata.Version) {
dependencyFound = true dependencyFound = true
break break
} }
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"strconv" "strconv"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/version"
) )
func TestLoadRequirements(t *testing.T) { func TestLoadRequirements(t *testing.T) {
...@@ -347,11 +348,24 @@ func TestGetAliasDependency(t *testing.T) { ...@@ -347,11 +348,24 @@ func TestGetAliasDependency(t *testing.T) {
t.Fatalf("Dependency chart name should be %s but got %s", req.Dependencies[0].Name, aliasChart.Metadata.Name) t.Fatalf("Dependency chart name should be %s but got %s", req.Dependencies[0].Name, aliasChart.Metadata.Name)
} }
if req.Dependencies[0].Version != "" {
if !version.IsCompatibleRange(req.Dependencies[0].Version, aliasChart.Metadata.Version) {
t.Fatalf("Dependency chart version is not in the compatible range")
}
}
// Failure case // Failure case
req.Dependencies[0].Name = "something-else" req.Dependencies[0].Name = "something-else"
if aliasChart := getAliasDependency(c.Dependencies, req.Dependencies[0]); aliasChart != nil { if aliasChart := getAliasDependency(c.Dependencies, req.Dependencies[0]); aliasChart != nil {
t.Fatalf("expected no chart but got %s", aliasChart.Metadata.Name) t.Fatalf("expected no chart but got %s", aliasChart.Metadata.Name)
} }
req.Dependencies[0].Version = "something else which is not in the compatible range"
if version.IsCompatibleRange(req.Dependencies[0].Version, aliasChart.Metadata.Version) {
t.Fatalf("Dependency chart version which is not in the compatible range should cause a failure other than a success ")
}
} }
func TestDependentChartAliases(t *testing.T) { func TestDependentChartAliases(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment