diff --git a/cmd/helm/downloader/manager.go b/cmd/helm/downloader/manager.go index c140504fc..4e4ddebf2 100644 --- a/cmd/helm/downloader/manager.go +++ b/cmd/helm/downloader/manager.go @@ -173,6 +173,17 @@ func (m *Manager) downloadAll(deps []*chartutil.Dependency) error { HelmHome: m.HelmHome, } + destPath := filepath.Join(m.ChartPath, "charts") + + // Create 'charts' directory if it doesn't already exist. + if fi, err := os.Stat(destPath); err != nil { + if err := os.MkdirAll(destPath, 0755); err != nil { + return err + } + } else if !fi.IsDir() { + return fmt.Errorf("%q is not a directory", destPath) + } + fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps)) for _, dep := range deps { fmt.Fprintf(m.Out, "Downloading %s from repo %s\n", dep.Name, dep.Repository) @@ -183,8 +194,7 @@ func (m *Manager) downloadAll(deps []*chartutil.Dependency) error { continue } - dest := filepath.Join(m.ChartPath, "charts") - if _, _, err := dl.DownloadTo(churl, "", dest); err != nil { + if _, _, err := dl.DownloadTo(churl, "", destPath); err != nil { fmt.Fprintf(m.Out, "WARNING: Could not download %s: %s (skipped)", churl, err) continue } @@ -257,6 +267,8 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) { } // urlsAreEqual normalizes two URLs and then compares for equality. +// +// TODO: This and the urlJoin functions should really be moved to a 'urlutil' package. func urlsAreEqual(a, b string) bool { au, err := url.Parse(a) if err != nil { diff --git a/docs/charts.md b/docs/charts.md index 1ee1cebe9..f94fdb22d 100644 --- a/docs/charts.md +++ b/docs/charts.md @@ -115,6 +115,10 @@ In Helm, one chart may depend on any number of other charts. These dependencies are expressed explicitly by copying the dependency charts into the `charts/` directory. +A dependency can be either a chart archive (`foo-1.2.3.tgz`) or an +unpacked chart directory. But its name cannot start with `_` or `.`. +Such files are ignored by the chart loader. + **Note:** The `dependencies:` section of the `Chart.yaml` from Helm Classic has been completely removed. @@ -141,7 +145,7 @@ on Apache and MySQL by including those charts inside of its `charts/` directory. **TIP:** _To drop a dependency into your `charts/` directory, use the -`helm fetch` command._ +`helm fetch` command or use a `requirements.yaml` file_ ### Managing Dependencies with `requirements.yaml` diff --git a/pkg/chartutil/load.go b/pkg/chartutil/load.go index 05bc1187b..dba1100e1 100644 --- a/pkg/chartutil/load.go +++ b/pkg/chartutil/load.go @@ -125,6 +125,10 @@ func loadFiles(files []*afile) (*chart.Chart, error) { continue } cname := strings.TrimPrefix(f.name, "charts/") + if strings.IndexAny(cname, "._") == 0 { + // Ignore charts/ that start with . or _. + continue + } parts := strings.SplitN(cname, "/", 2) scname := parts[0] subcharts[scname] = append(subcharts[scname], &afile{name: cname, data: f.data}) @@ -141,7 +145,9 @@ func loadFiles(files []*afile) (*chart.Chart, error) { for n, files := range subcharts { var sc *chart.Chart var err error - if filepath.Ext(n) == ".tgz" { + if strings.IndexAny(n, "_.") == 0 { + continue + } else if filepath.Ext(n) == ".tgz" { file := files[0] if file.name != n { return c, fmt.Errorf("error unpacking tar in %s: expected %s, got %s", c.Metadata.Name, n, file.name) diff --git a/pkg/chartutil/testdata/frobnitz-1.2.3.tgz b/pkg/chartutil/testdata/frobnitz-1.2.3.tgz index 07b111364..aaf443dba 100644 Binary files a/pkg/chartutil/testdata/frobnitz-1.2.3.tgz and b/pkg/chartutil/testdata/frobnitz-1.2.3.tgz differ diff --git a/pkg/chartutil/testdata/frobnitz/charts/_ignore_me b/pkg/chartutil/testdata/frobnitz/charts/_ignore_me new file mode 100644 index 000000000..2cecca682 --- /dev/null +++ b/pkg/chartutil/testdata/frobnitz/charts/_ignore_me @@ -0,0 +1 @@ +This should be ignored by the loader, but may be included in a chart. diff --git a/pkg/chartutil/testdata/frobnitz/charts/mariner-4.3.2.tgz b/pkg/chartutil/testdata/frobnitz/charts/mariner-4.3.2.tgz index 88f255c23..3af333e76 100644 Binary files a/pkg/chartutil/testdata/frobnitz/charts/mariner-4.3.2.tgz and b/pkg/chartutil/testdata/frobnitz/charts/mariner-4.3.2.tgz differ diff --git a/pkg/chartutil/testdata/mariner/charts/albatross-0.1.0.tgz b/pkg/chartutil/testdata/mariner/charts/albatross-0.1.0.tgz index 5fb374a78..0b66d27fe 100644 Binary files a/pkg/chartutil/testdata/mariner/charts/albatross-0.1.0.tgz and b/pkg/chartutil/testdata/mariner/charts/albatross-0.1.0.tgz differ