fix(helm): fix helmignore evaluation of dirs

This adds a few extra settings to the default .helmignore file. In
doing this, I found a bug that some directory patterns are not
evaluated correctly. Fixed that and added tests.

Closes #989
Closes #1027
pull/1028/head
Matt Butcher 8 years ago
parent 7800a3c81e
commit 2e95230b30

@ -48,7 +48,23 @@ const defaultIgnore = `# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
.git
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
`
// Create creates a new chart in a directory.

@ -218,6 +218,11 @@ func LoadDir(dir string) (*chart.Chart, error) {
return err
}
if fi.IsDir() {
// Directory-based ignore rules should involve skipping the entire
// contents of that directory.
if rules.Ignore(n, fi) {
return filepath.SkipDir
}
return nil
}

@ -49,8 +49,9 @@ func verifyChart(t *testing.T, c *chart.Chart) {
t.Errorf("Expected 1 template, got %d", len(c.Templates))
}
if len(c.Files) != 5 {
t.Errorf("Expected 5 extra files, got %d", len(c.Files))
numfiles := 6
if len(c.Files) != numfiles {
t.Errorf("Expected %d extra files, got %d", numfiles, len(c.Files))
for _, n := range c.Files {
t.Logf("\t%s", n.TypeUrl)
}

Binary file not shown.

@ -9,4 +9,4 @@ tar -zcvf frobnitz/charts/mariner-4.3.2.tgz mariner
# Pack the frobnitz chart.
echo "Packing frobnitz"
tar -zcvf frobnitz-1.2.3.tgz frobnitz
tar --exclude=ignore/* -zcvf frobnitz-1.2.3.tgz frobnitz

@ -65,7 +65,6 @@ func Parse(file io.Reader) (*Rules, error) {
if err := s.Err(); err != nil {
return r, err
}
return r, nil
}
@ -97,8 +96,10 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool {
continue
}
// If the rule is looking for directories, and this is not a directory,
// skip it.
if p.mustDir && !fi.IsDir() {
return false
continue
}
if p.match(path, fi) {
return true

Loading…
Cancel
Save