Merge pull request #522 from jackgr/deployment

Fix chart directory relative path bug
pull/526/head
Jack Greenfield 9 years ago
commit 007b300dcc

@ -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 := ""

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

Loading…
Cancel
Save