fixes #1171 so `helm install` will accept chart.tgz files with the Chart.yaml in the root folder but give a warning to indicate that charts should put the yaml file in a directory

pull/1172/head
James Strachan 9 years ago
parent 976e0ba519
commit 7748092710

@ -84,14 +84,11 @@ func LoadArchive(in io.Reader) (*chart.Chart, error) {
continue
}
parts := strings.Split(hd.Name, "/")
n := strings.Join(parts[1:], "/")
if _, err := io.Copy(b, tr); err != nil {
return &chart.Chart{}, err
}
files = append(files, &afile{name: n, data: b.Bytes()})
files = append(files, &afile{name: hd.Name, data: b.Bytes()})
b.Reset()
}
@ -99,6 +96,22 @@ func LoadArchive(in io.Reader) (*chart.Chart, error) {
return nil, errors.New("no files in chart archive")
}
// usually files in chart.tgz are inside a folder
// but lets accept tarballs where the Chart.yaml is in the root folder too
root := false
for _, f := range files {
if f.name == "Chart.yaml" {
root = true
fmt.Println("Warning: this chart file contains `Chart.yaml` in the root of the tgz file. Chart tgz files should include the Chart.yaml inside a child directory")
break
}
}
if !root {
for _, f := range files {
parts := strings.Split(f.name, "/")
f.name = strings.Join(parts[1:], "/")
}
}
return loadFiles(files)
}

Loading…
Cancel
Save