diff --git a/cmd/helm/install.go b/cmd/helm/install.go index d01ee514a..0cce58916 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -206,7 +206,12 @@ func (i *installCmd) run() error { } if req, err := chartutil.LoadRequirements(chartRequested); err == nil { - checkDependencies(chartRequested, req, i.out) + // If checkDependencies returns an error, we have unfullfilled dependencies. + // As of Helm 2.4.0, this is treated as a stopping condition: + // https://github.com/kubernetes/helm/issues/2209 + if err := checkDependencies(chartRequested, req, i.out); err != nil { + return prettyError(err) + } } res, err := i.client.InstallReleaseFromChart( @@ -398,7 +403,9 @@ func defaultNamespace() string { return "default" } -func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements, out io.Writer) { +func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements, out io.Writer) error { + missing := []string{} + deps := ch.GetDependencies() for _, r := range reqs.Dependencies { found := false @@ -409,7 +416,12 @@ func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements, out io.Wri } } if !found { - fmt.Fprintf(out, "Warning: %s is in requirements.yaml but not in the charts/ directory!\n", r.Name) + missing = append(missing, r.Name) } } + + if len(missing) > 0 { + return fmt.Errorf("found in requirements.yaml, but missing in charts/ directory: %s", strings.Join(missing, ", ")) + } + return nil } diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index ee0ffe0e8..7e749afc7 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -134,9 +134,9 @@ func TestInstall(t *testing.T) { }, // Install, chart with missing dependencies in /charts { - name: "install chart with missing dependencies", - args: []string{"testdata/testcharts/chart-missing-deps"}, - expected: "Warning: reqsubchart2 is in requirements.yaml but not in the charts/ directory!", + name: "install chart with missing dependencies", + args: []string{"testdata/testcharts/chart-missing-deps"}, + err: true, }, } diff --git a/cmd/helm/package.go b/cmd/helm/package.go index a2da2c338..8b4e12e55 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -127,7 +127,9 @@ func (p *packageCmd) run(cmd *cobra.Command, args []string) error { } if reqs, err := chartutil.LoadRequirements(ch); err == nil { - checkDependencies(ch, reqs, p.out) + if err := checkDependencies(ch, reqs, p.out); err != nil { + return err + } } var dest string diff --git a/cmd/helm/package_test.go b/cmd/helm/package_test.go index 1d25260d4..683858cd8 100644 --- a/cmd/helm/package_test.go +++ b/cmd/helm/package_test.go @@ -118,8 +118,8 @@ func TestPackage(t *testing.T) { { name: "package testdata/testcharts/chart-missing-deps", args: []string{"testdata/testcharts/chart-missing-deps"}, - expect: "Warning: reqsubchart2 is in requirements.yaml but not in the charts/ directory!\n", hasfile: "chart-missing-deps-0.1.0.tgz", + err: true, }, } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index ea8d667a1..433e5a7f6 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -166,7 +166,9 @@ func (u *upgradeCmd) run() error { // Check chart requirements to make sure all dependencies are present in /charts if ch, err := chartutil.Load(chartPath); err == nil { if req, err := chartutil.LoadRequirements(ch); err == nil { - checkDependencies(ch, req, u.out) + if err := checkDependencies(ch, req, u.out); err != nil { + return err + } } } diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index a913016e2..9ee1ae585 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -138,10 +138,10 @@ func TestUpgradeCmd(t *testing.T) { expected: "Release \"crazy-bunny\" has been upgraded. Happy Helming!\n", }, { - name: "upgrade a release with missing dependencies", - args: []string{"bonkers-bunny", missingDepsPath}, - resp: releaseMock(&releaseOptions{name: "bonkers-bunny", version: 1, chart: ch3}), - expected: "Warning: reqsubchart2 is in requirements.yaml but not in the charts/ directory!", + name: "upgrade a release with missing dependencies", + args: []string{"bonkers-bunny", missingDepsPath}, + resp: releaseMock(&releaseOptions{name: "bonkers-bunny", version: 1, chart: ch3}), + err: true, }, }