From 2388e71528f782c430f876a0858a19d7a2896a54 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 11 Oct 2016 18:59:45 -0600 Subject: [PATCH] fix(helm): ignore dotfiles in charts/ directories This causes 'helm dep [up|install]' to ignore files in charts/ that start with either a dot or an underscore. It also changes the chartloader to ignore those files. Also, if a 'helm dep up' does not find a charts/ directory, it creates one. Closes #1342 --- cmd/helm/downloader/manager.go | 16 ++++++++++++++-- docs/charts.md | 6 +++++- pkg/chartutil/load.go | 8 +++++++- pkg/chartutil/testdata/frobnitz-1.2.3.tgz | Bin 4025 -> 4105 bytes .../testdata/frobnitz/charts/_ignore_me | 1 + .../frobnitz/charts/mariner-4.3.2.tgz | Bin 1031 -> 1034 bytes .../mariner/charts/albatross-0.1.0.tgz | Bin 347 -> 347 bytes 7 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 pkg/chartutil/testdata/frobnitz/charts/_ignore_me 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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qp<8JVK&#$Md7xitr`ibAN2ksocW%|kC#@@hJ6FY?;tF70T z*UlV$)p^SKA?S9Va^Qy(Ef2@PoPBek`fx|jABV>mjI3Wc;lTGBr~fh|)bPQM?i0Oj zXx|GX;nAl3*MEIv;1O%iD-Dxx=N@NlTJZ9vb%EP2mKmT727|$1Fc=I5gTY{&hd%+A K!&6THC;$N4ss1zo delta 986 zcmV<0110>52!{v^ABzY8+wAjK00ZrpkqjVzVhEaa?r!dG>prftbA|KOm{^rrNTLt`YB?{eK*}W$(@U`> zAR*xti6js{XFu947Wf4`Koxybdmp@l*q zKMS}hawFJC62q}WU;$W&ObbN3nE_%B2FtjFOIP5C^A2AVEmd4F!W}CA5+z;v(cWXHvO4)QWzAi z$QwVGMm7FnEJI4q+5S(P2ue6+luiJWEQK3PSO0=6p6>sWNI$IpE5XzXpQ=17wTpu@ z-v5is{(67a&Xf3~fB$}r>FQsV<=p$fu4yve79>H_L{|Tmpt|d_z|j+94+bt7{o+{b zyI@w;x3h=qHeL7W6SdhpKe=a7RfaowWOGZaxOpJcZ#2)?IPv0$Hh#w~eXBp)d3;M- z@0vY3M*lb#UA?e*-?LjoZ$96(jx$m-?ei?64 z&19&5+x+L6v*~QZ!7qER%7EpE+piy-cDzSWg+d9*Q5Gdt;#bP)E=2hb9({tY19ozz-T{{yZzx@Zt9EvEDYc z_l1%0Xw$xHzdk(hur=?MhN+Kpw=+H?cvnE(I) 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 5fb374a789567b5f1518f1b00c3d4b75c29f7e4a..0b66d27fe1bb83cde374420591ce39b5ee58543f 100644 GIT binary patch delta 16 Xcmcc3beoA?zMF$#Ufth~>>-Q*F$x8m delta 16 Xcmcc3beoA?zMF&L_M6We*+UosH5Udu