diff --git a/examples/charts/replicatedservice-3.tgz b/examples/charts/replicatedservice-3.tgz deleted file mode 100644 index ebbcc1802..000000000 Binary files a/examples/charts/replicatedservice-3.tgz and /dev/null differ diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index d36c15f1e..8367bd83a 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -220,20 +220,25 @@ func fname(name string) string { // If you are just reading the Chart.yaml file, it is substantially more // performant to use LoadChartfile. func LoadDir(chart string) (*Chart, error) { - if fi, err := os.Stat(chart); err != nil { + dir, err := filepath.Abs(chart) + if err != nil { + return nil, fmt.Errorf("%s is not a valid path", chart) + } + + if fi, err := os.Stat(dir); err != nil { return nil, err } else if !fi.IsDir() { - return nil, fmt.Errorf("Chart %s is not a directory.", chart) + return nil, fmt.Errorf("%s is not a directory", chart) } - cf, err := LoadChartfile(filepath.Join(chart, "Chart.yaml")) + cf, err := LoadChartfile(filepath.Join(dir, "Chart.yaml")) if err != nil { return nil, err } cl := &dirChart{ chartyaml: cf, - chartdir: chart, + chartdir: dir, } return &Chart{ @@ -293,9 +298,16 @@ func loadTar(r *tar.Reader) (*tarChart, error) { if err != nil { return nil, err } + + // ioutil.TempDir uses Getenv("TMPDIR"), so there are no guarantees + dir, err := filepath.Abs(td) + if err != nil { + return nil, fmt.Errorf("%s is not a valid path", td) + } + c := &tarChart{ chartyaml: &Chartfile{}, - tmpDir: td, + tmpDir: dir, } firstDir := "" diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go index 6aea61033..e0da71ac6 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -141,18 +141,19 @@ func TestChart(t *testing.T) { t.Errorf("Unexpected chart file name: %s", c.Chartfile().Name) } + dir := c.Dir() d := c.DocsDir() - if d != filepath.Join(testdir, preDocs) { + if d != filepath.Join(dir, preDocs) { t.Errorf("Unexpectedly, docs are in %s", d) } d = c.TemplatesDir() - if d != filepath.Join(testdir, preTemplates) { + if d != filepath.Join(dir, preTemplates) { t.Errorf("Unexpectedly, templates are in %s", d) } d = c.HooksDir() - if d != filepath.Join(testdir, preHooks) { + if d != filepath.Join(dir, preHooks) { t.Errorf("Unexpectedly, hooks are in %s", d) } @@ -160,7 +161,7 @@ func TestChart(t *testing.T) { if err != nil { t.Errorf("No icon found in test chart: %s", err) } - if i != filepath.Join(testdir, preIcon) { + if i != filepath.Join(dir, preIcon) { t.Errorf("Unexpectedly, icon is in %s", i) } }