fix(helm): add descriptive error if dependency has blank "repository" (#5152)

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
pull/5275/head
adshmh 7 years ago committed by Matthew Fisher
parent 1984f436af
commit d8bdf484cc

@ -371,6 +371,9 @@ func (m *Manager) getRepoNames(deps []*chartutil.Dependency) (map[string]string,
// by Helm.
missing := []string{}
for _, dd := range deps {
if dd.Repository == "" {
return nil, fmt.Errorf("no 'repository' field specified for dependency: %q", dd.Name)
}
// if dep chart is from local path, verify the path is valid
if strings.HasPrefix(dd.Repository, "file://") {
if _, err := resolver.GetLocalPath(dd.Repository, m.ChartPath); err != nil {

@ -18,6 +18,7 @@ package downloader
import (
"bytes"
"reflect"
"strings"
"testing"
"k8s.io/helm/pkg/chartutil"
@ -99,10 +100,11 @@ func TestGetRepoNames(t *testing.T) {
HelmHome: helmpath.Home("testdata/helmhome"),
}
tests := []struct {
name string
req []*chartutil.Dependency
expect map[string]string
err bool
name string
req []*chartutil.Dependency
expect map[string]string
err bool
expectedErr string
}{
{
name: "no repo definition failure",
@ -118,6 +120,14 @@ func TestGetRepoNames(t *testing.T) {
},
err: true,
},
{
name: "dependency entry missing 'repository' field -- e.g. spelled 'repo'",
req: []*chartutil.Dependency{
{Name: "dependency-missing-repository-field"},
},
err: true,
expectedErr: "no 'repository' field specified for dependency: \"dependency-missing-repository-field\"",
},
{
name: "no repo definition failure",
req: []*chartutil.Dependency{
@ -152,6 +162,9 @@ func TestGetRepoNames(t *testing.T) {
l, err := m.getRepoNames(tt.req)
if err != nil {
if tt.err {
if !strings.Contains(err.Error(), tt.expectedErr) {
t.Fatalf("%s: expected error: %s, got: %s", tt.name, tt.expectedErr, err.Error())
}
continue
}
t.Fatal(err)

Loading…
Cancel
Save