improved user-facing error messages to explain the underlying problem (#8731)

Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
pull/8922/head
Matt Butcher 5 years ago committed by GitHub
parent e1d4c67437
commit 5f3e560029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
}

@ -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

Loading…
Cancel
Save