diff --git a/pkg/chartutil/requirements.go b/pkg/chartutil/requirements.go index fbd686b91..db77ecf50 100644 --- a/pkg/chartutil/requirements.go +++ b/pkg/chartutil/requirements.go @@ -258,6 +258,24 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error { } var chartDependencies []*chart.Chart + // If any dependency is not a part of requirements.yaml + // then this should be added to chartDependencies. + // However, if the dependency is already specified in requirements.yaml + // we should not add it, as it would be anyways processed from requirements.yaml + + for _, existingDependency := range c.Dependencies { + var dependencyFound bool + for _, req := range reqs.Dependencies { + if existingDependency.Metadata.Name == req.Name && existingDependency.Metadata.Version == req.Version { + dependencyFound = true + break + } + } + if !dependencyFound { + chartDependencies = append(chartDependencies, existingDependency) + } + } + for _, req := range reqs.Dependencies { if chartDependency := getAliasDependency(c.Dependencies, req); chartDependency != nil { chartDependencies = append(chartDependencies, chartDependency) diff --git a/pkg/chartutil/requirements_test.go b/pkg/chartutil/requirements_test.go index 65d59e52f..8e25504c4 100644 --- a/pkg/chartutil/requirements_test.go +++ b/pkg/chartutil/requirements_test.go @@ -378,13 +378,6 @@ func TestDependentChartAliases(t *testing.T) { t.Fatalf("Cannot load requirements for test chart, %v", err) } - // var expectedDependencyCharts int - // for _, reqmt := range reqmts.Dependencies { - // expectedDependencyCharts++ - // if len(reqmt.Alias) >= 0 { - // expectedDependencyCharts += len(reqmt.Alias) - // } - // } if len(c.Dependencies) != len(reqmts.Dependencies) { t.Fatalf("Expected number of chart dependencies %d, but got %d", len(reqmts.Dependencies), len(c.Dependencies)) }