Merge pull request #1345 from technosophos/fix/1342-ignore-charts-dotfiles

fix(helm): ignore dotfiles in charts/ directories
pull/1352/head
Matt Butcher 9 years ago committed by GitHub
commit cbe7a2a993

@ -173,6 +173,17 @@ func (m *Manager) downloadAll(deps []*chartutil.Dependency) error {
HelmHome: m.HelmHome, 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)) fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps))
for _, dep := range deps { for _, dep := range deps {
fmt.Fprintf(m.Out, "Downloading %s from repo %s\n", dep.Name, dep.Repository) 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 continue
} }
dest := filepath.Join(m.ChartPath, "charts") if _, _, err := dl.DownloadTo(churl, "", destPath); err != nil {
if _, _, err := dl.DownloadTo(churl, "", dest); err != nil {
fmt.Fprintf(m.Out, "WARNING: Could not download %s: %s (skipped)", churl, err) fmt.Fprintf(m.Out, "WARNING: Could not download %s: %s (skipped)", churl, err)
continue continue
} }
@ -257,6 +267,8 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) {
} }
// urlsAreEqual normalizes two URLs and then compares for equality. // 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 { func urlsAreEqual(a, b string) bool {
au, err := url.Parse(a) au, err := url.Parse(a)
if err != nil { if err != nil {

@ -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 dependencies are expressed explicitly by copying the dependency charts
into the `charts/` directory. 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 **Note:** The `dependencies:` section of the `Chart.yaml` from Helm
Classic has been completely removed. Classic has been completely removed.
@ -141,7 +145,7 @@ on Apache and MySQL by including those charts inside of its `charts/`
directory. directory.
**TIP:** _To drop a dependency into your `charts/` directory, use the **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` ### Managing Dependencies with `requirements.yaml`

@ -125,6 +125,10 @@ func loadFiles(files []*afile) (*chart.Chart, error) {
continue continue
} }
cname := strings.TrimPrefix(f.name, "charts/") cname := strings.TrimPrefix(f.name, "charts/")
if strings.IndexAny(cname, "._") == 0 {
// Ignore charts/ that start with . or _.
continue
}
parts := strings.SplitN(cname, "/", 2) parts := strings.SplitN(cname, "/", 2)
scname := parts[0] scname := parts[0]
subcharts[scname] = append(subcharts[scname], &afile{name: cname, data: f.data}) 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 { for n, files := range subcharts {
var sc *chart.Chart var sc *chart.Chart
var err error var err error
if filepath.Ext(n) == ".tgz" { if strings.IndexAny(n, "_.") == 0 {
continue
} else if filepath.Ext(n) == ".tgz" {
file := files[0] file := files[0]
if file.name != n { if file.name != n {
return c, fmt.Errorf("error unpacking tar in %s: expected %s, got %s", c.Metadata.Name, n, file.name) return c, fmt.Errorf("error unpacking tar in %s: expected %s, got %s", c.Metadata.Name, n, file.name)

Binary file not shown.

@ -0,0 +1 @@
This should be ignored by the loader, but may be included in a chart.
Loading…
Cancel
Save