From 7748092710dece390b1876b5a96d2a1cec5e2818 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Fri, 9 Sep 2016 12:18:55 +0100 Subject: [PATCH] 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 --- pkg/chartutil/load.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/chartutil/load.go b/pkg/chartutil/load.go index 20212f241..7ac9e81c5 100644 --- a/pkg/chartutil/load.go +++ b/pkg/chartutil/load.go @@ -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) }