diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index f2b4c300e..8d0990e06 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -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. diff --git a/pkg/chartutil/load.go b/pkg/chartutil/load.go index 296b11231..911d883d2 100644 --- a/pkg/chartutil/load.go +++ b/pkg/chartutil/load.go @@ -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 } diff --git a/pkg/chartutil/load_test.go b/pkg/chartutil/load_test.go index fa94acbc3..822e8d078 100644 --- a/pkg/chartutil/load_test.go +++ b/pkg/chartutil/load_test.go @@ -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) } diff --git a/pkg/chartutil/testdata/frobnitz-1.2.3.tgz b/pkg/chartutil/testdata/frobnitz-1.2.3.tgz index 31c855223..50d1ef014 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/.helmignore b/pkg/chartutil/testdata/frobnitz/.helmignore new file mode 100644 index 000000000..9973a57b8 --- /dev/null +++ b/pkg/chartutil/testdata/frobnitz/.helmignore @@ -0,0 +1 @@ +ignore/ 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 90c7979af..27bd51f65 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/frobnitz/ignore/me.txt b/pkg/chartutil/testdata/frobnitz/ignore/me.txt new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/chartutil/testdata/genfrob.sh b/pkg/chartutil/testdata/genfrob.sh index 38fc1b22c..8f2cddec1 100755 --- a/pkg/chartutil/testdata/genfrob.sh +++ b/pkg/chartutil/testdata/genfrob.sh @@ -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 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 3d5b6a242..c35e1b970 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 diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 0251268ba..f5b08a4ee 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -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