From 2e95230b304eed9016c7473af684c13f565a96da Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 5 Aug 2016 15:50:02 -0600 Subject: [PATCH] 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 --- pkg/chartutil/create.go | 18 +++++++++++++++++- pkg/chartutil/load.go | 5 +++++ pkg/chartutil/load_test.go | 5 +++-- pkg/chartutil/testdata/frobnitz-1.2.3.tgz | Bin 3333 -> 3775 bytes pkg/chartutil/testdata/frobnitz/.helmignore | 1 + .../frobnitz/charts/mariner-4.3.2.tgz | Bin 896 -> 936 bytes pkg/chartutil/testdata/frobnitz/ignore/me.txt | 0 pkg/chartutil/testdata/genfrob.sh | 2 +- .../mariner/charts/albatross-0.1.0.tgz | Bin 322 -> 347 bytes pkg/ignore/rules.go | 5 +++-- 10 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 pkg/chartutil/testdata/frobnitz/.helmignore create mode 100644 pkg/chartutil/testdata/frobnitz/ignore/me.txt 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 31c855223046ed3bba9abb2a7ca707195ad6daa4..50d1ef01484094a445c867e612e363f4f527d604 100644 GIT binary patch literal 3775 zcmV;w4nXlAiwFR;38hy61MQs&d=teQz!L-t5wHp>hswD4-V>#pO|nU7ZK0(th(Ljs zLP4e7CYxkola0HZwy{7FFF-{pB0fYwP%Z%#L6M{7DGH*9ic}C06>Sx0xs;ps%^pqL zNKKJ8qR#)vGMmh`o7wN1Z)SGBI(RPI!-x;+HBARW5LUAp$e~3E2_vb5D!^d0nhi#R zG?@*6FpwlcXn?s1uPJ~}5GfvBiklL}Y@cXz(fmcz!DJ4{@06q7MD`8x0yjH1>sDjDL9hD=n_q{n^)n_;U!zf1-=xMchxh z*+#D;l>C#VRg!-rX|h^LGbzbGR0BxDbU$z!NxOQk>NZsV3>;$0Q^S< z;&ELL%?olQX26ZO3Db?G{ka@(7h-e(MAZ}|eGt4nXB$h4@&`L-r|dd6#dt(`z*3Y9 zO8vuJG`Jh~KVTS5x#9N!&@d$%1EfwVp3bA(UY5pfoV!+@G|o+P9vURG0$n?chs);d z{yLci&d1wmwMLgHdW9IhzE%RggX8qs6t8n}Qpr+^x(WWi>Me?H>*T?a$aa4=&_5o1l(R{lD2_ z3GV+1s}=SC;UKnmo|^?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jes@7ZV3dblnEx>t9&@=Ch0c zmOlNx*kxJWlOis|Hk`Fxctu^hqZ@KSzkIi`om2n`CY4va%=k^#9w@> zx}v80k%FS71t0XNa3{b1L!RZaU5n@B%nPg5){ao`cZX%w4m>gR^qM<=s$TErGM3f2 z53DuZbSH0J^~kyR-@h%*2Al5;lSZG8ZusE#%y+ff^=_AI4?_~?0nilv|DegBK=Kd0 zeLwq8Ny<_DFDUSsDk7g7r+*SW|By#~5yXgEvM-Nw@6->5e8t}&nj-%Xnha{H{YMCu zK!jXa|1|`v{|XA4!v6;i2LF8iD^dP0NN5WGA2b*oX#H0ZNS*F9F91orO-IFTlip$a+9PKtMo1KtMo1KtMo1KtMo1KtMo1KtMo1KtMo1KtMo1 P_}Ta$fGYPr0C)fZ@}|9H 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 90c7979afe88fb36ef00f6fe09041217b874323f..27bd51f654f64fa50e431c35bd69c9e7d509a5c1 100644 GIT binary patch literal 936 zcmV;Z16TYXiwFR;38hy61MQZ3XcI{s$Abq|bQ#8S10ibbrZ?k1_k zXBC@>IG+S&LS|=X=llEq=BGeS@*&M;i6b;k+XVrHTQSnoEFWp30EV@*0?!E?ZwEBP zvkY$mLOeIsMnK0~>z@4gE!i=PZEk_^o`%Pp-cYD#!t%QDDtSx=WM%SW$)+YnztOmmSC#XP0Koo^$Oi5CpXQi%^FPZNAL9Q+5bN+* z<%!jP4&JN(q3ncMQ*}LqrWlH*uxIYKuhE|W1&%ZQFEA`^)cvOajqxJ!eo;buAkj#pY4J zRW3cd=Rx(Xie(4tnqJ??UpgV@*otkA|NkzXJn!(F?cLI+9N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ae@9r+U^I8|#W=mW0rfC=5GZWvUM=y3U z{hbTyi&ES3lk-Z*?w5mQ#0Gc8aDP#prf+mb)zI~{uR`@o*M z%7&edw#^PUw8u^~=X1(x-;Xn!Wk0%GbA5)&B41Dtb&pGEL74_#ol>prTw=m`( zZL@bK9qp@cfp6q5bA|kGVa)$vTxZ)U9snQJf0Fvu`%medQ2%dX$UhbD7&<%4vW@eV tab?Ds>0<3e$rj$(uw88|syhGx0000000000006*m_5v>lStDd~pD z<)$?0d@wFfr8XgCUC2x8ZuX1aisF-TuIm`vJ7LEBA4}sx`fBQG?svrRp@jH2f5zF6 zzu0Llq=@+|p?4cX=bp$d|2+T3)OJtCU68z3pS$BJ9NT734&=#JHOc#(L5kLq=Pt9Z zvBCP}Y@HuE(Uhe$DcgRW?Kb)A1;LL@=YL3fkuvbz`=2pJrK0`$k0k*2{~D(JgRM`M ziAQ_(E%1x{C0EFQ4O9MSQ+3ua@dNNx{imG2`~Oq%0rh_kWB##t2iI8?Z~y=R00000 U000000D$}T2EDQLp8zNT06#;d{Qv*} 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