diff --git a/pkg/chartutil/chartfile.go b/pkg/chartutil/chartfile.go index 4850c2f81..802960d07 100644 --- a/pkg/chartutil/chartfile.go +++ b/pkg/chartutil/chartfile.go @@ -59,14 +59,14 @@ func IsChartDir(dirName string) (bool, error) { return false, errors.Errorf("%q is not a directory", dirName) } - chartYaml := filepath.Join(dirName, "Chart.yaml") + chartYaml := filepath.Join(dirName, ChartfileName) if _, err := os.Stat(chartYaml); os.IsNotExist(err) { - return false, errors.Errorf("no Chart.yaml exists in directory %q", dirName) + return false, errors.Errorf("no %s exists in directory %q", ChartfileName, dirName) } chartYamlContent, err := ioutil.ReadFile(chartYaml) if err != nil { - return false, errors.Errorf("cannot read Chart.Yaml in directory %q", dirName) + return false, errors.Errorf("cannot read %s in directory %q", ChartfileName, dirName) } chartContent := new(chart.Metadata) @@ -74,10 +74,10 @@ func IsChartDir(dirName string) (bool, error) { return false, err } if chartContent == nil { - return false, errors.New("chart metadata (Chart.yaml) missing") + return false, errors.Errorf("chart metadata (%s) missing", ChartfileName) } if chartContent.Name == "" { - return false, errors.New("invalid chart (Chart.yaml): name must not be empty") + return false, errors.Errorf("invalid chart (%s): name must not be empty", ChartfileName) } return true, nil diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index 1ea99bbd7..83d95cc5a 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -136,7 +136,7 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { if err != nil { return err } - if err := writeToTar(out, base+"/Chart.yaml", cdata); err != nil { + if err := writeToTar(out, filepath.Join(base, ChartfileName), cdata); err != nil { return err } @@ -145,7 +145,7 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { if err != nil { return err } - if err := writeToTar(out, base+"/values.yaml", ydata); err != nil { + if err := writeToTar(out, filepath.Join(base, ValuesfileName), ydata); err != nil { return err } @@ -167,7 +167,7 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { // Save dependencies for _, dep := range c.Dependencies() { - if err := writeTarContents(out, dep, base+"/charts"); err != nil { + if err := writeTarContents(out, dep, filepath.Join(base, ChartsDir)); err != nil { return err } } diff --git a/pkg/chartutil/save_test.go b/pkg/chartutil/save_test.go index bab37e1a9..54e7fef79 100644 --- a/pkg/chartutil/save_test.go +++ b/pkg/chartutil/save_test.go @@ -19,6 +19,7 @@ package chartutil import ( "io/ioutil" "os" + "path/filepath" "strings" "testing" @@ -84,7 +85,7 @@ func TestSaveDir(t *testing.T) { {Name: "scheherazade/shahryar.txt", Data: []byte("1,001 Nights")}, }, Templates: []*chart.File{ - {Name: "templates/nested/dir/thing.yaml", Data: []byte("abc: {{ .Values.abc }}")}, + {Name: filepath.Join(TemplatesDir, "nested", "dir", "thing.yaml"), Data: []byte("abc: {{ .Values.abc }}")}, }, } @@ -101,7 +102,7 @@ func TestSaveDir(t *testing.T) { t.Fatalf("Expected chart archive to have %q, got %q", c.Name(), c2.Name()) } - if len(c2.Templates) != 1 || c2.Templates[0].Name != "templates/nested/dir/thing.yaml" { + if len(c2.Templates) != 1 || c2.Templates[0].Name != filepath.Join(TemplatesDir, "nested", "dir", "thing.yaml") { t.Fatal("Templates data did not match") }