diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index dd4fd2dff..c9d57234e 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -143,6 +143,10 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { } } + if c.Metadata == nil { + return c, errors.New("Chart.yaml file is missing") + } + if err := c.Validate(); err != nil { return c, err } diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index 16a94d4eb..f3456b9f6 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -275,7 +275,7 @@ icon: https://example.com/64x64.png if _, err = LoadFiles([]*BufferedFile{}); err == nil { t.Fatal("Expected err to be non-nil") } - if err.Error() != "validation: chart.metadata is required" { + if err.Error() != "Chart.yaml file is missing" { t.Errorf("Expected chart metadata missing error, got '%s'", err.Error()) } } @@ -349,7 +349,7 @@ func TestLoadInvalidArchive(t *testing.T) { {"illegal-name.tgz", "./.", "chart illegally contains content outside the base directory"}, {"illegal-name2.tgz", "/./.", "chart illegally contains content outside the base directory"}, {"illegal-name3.tgz", "missing-leading-slash", "chart illegally contains content outside the base directory"}, - {"illegal-name4.tgz", "/missing-leading-slash", "validation: chart.metadata is required"}, + {"illegal-name4.tgz", "/missing-leading-slash", "Chart.yaml file is missing"}, {"illegal-abspath.tgz", "//foo", "chart illegally contains absolute paths"}, {"illegal-abspath2.tgz", "///foo", "chart illegally contains absolute paths"}, {"illegal-abspath3.tgz", "\\\\foo", "chart illegally contains absolute paths"}, @@ -383,8 +383,8 @@ func TestLoadInvalidArchive(t *testing.T) { illegalChart = filepath.Join(tmpdir, "abs-path2.tgz") writeTar(illegalChart, "files/whatever.yaml", []byte("hello: world")) _, err = Load(illegalChart) - if err.Error() != "validation: chart.metadata is required" { - t.Error(err) + if err.Error() != "Chart.yaml file is missing" { + t.Errorf("Unexpected error message: %s", err) } // Finally, test that drive letter gets stripped off on Windows