@@ -13,7 +13,6 @@ import (
1313 "os/exec"
1414 "path"
1515 "path/filepath"
16- "regexp"
1716 "sort"
1817 "strings"
1918 "sync"
@@ -54,12 +53,7 @@ func buildParams(payload *v1alpha1.Application, ignoreValueFile string) (string,
5453
5554 }
5655 for i := 0 ; i < len (helmFiles ); i ++ {
57- isExplicitlyIgnored := ignoreValueFile != "" && strings .Contains (helmFiles [i ], ignoreValueFile )
58- isMissingAndShouldBeIgnored :=
59- ! fileExists (path .Join (payload .Spec .Source .Path , helmFiles [i ])) &&
60- payload .Spec .Source .Helm .IgnoreMissingValueFiles
61-
62- if ! isExplicitlyIgnored && ! isMissingAndShouldBeIgnored {
56+ if ! ignoredValueFile (payload , helmFiles [i ], ignoreValueFile ) {
6357 fileValues += fmt .Sprintf ("%s," , helmFiles [i ])
6458 }
6559 }
@@ -219,11 +213,9 @@ func GenerateHash(crd *v1alpha1.Application, ignoreValueFile string) (string, er
219213 if crd .Spec .Source .Helm != nil && len (crd .Spec .Source .Helm .ValueFiles ) > 0 {
220214 oHash := sha256 .New ()
221215 overrideFiles := crd .Spec .Source .Helm .ValueFiles
222- matchDots := regexp .MustCompile (`\.\.\/` )
223216 for i := 0 ; i < len (overrideFiles ); i ++ {
224- if ignoreValueFile == "" || ! strings .Contains (overrideFiles [i ], ignoreValueFile ) {
225- trimmedFilename := matchDots .ReplaceAllString (overrideFiles [i ], "" )
226- oHashReturned , err := generalHashFunction (trimmedFilename )
217+ if ! ignoredValueFile (crd , overrideFiles [i ], ignoreValueFile ) {
218+ oHashReturned , err := generalHashFunction (path .Join (crd .Spec .Source .Path , overrideFiles [i ]))
227219 if err != nil {
228220 return "" , err
229221 }
@@ -437,6 +429,15 @@ func Read(inputCRD string) ([]*v1alpha1.Application, error) {
437429 return crdSpecs , nil
438430}
439431
432+ func ignoredValueFile (crd * v1alpha1.Application , f string , ignoreValueFile string ) bool {
433+ isExplicitlyIgnored := ignoreValueFile != "" && strings .Contains (f , ignoreValueFile )
434+ isMissingAndShouldBeIgnored :=
435+ ! fileExists (path .Join (crd .Spec .Source .Path , f )) &&
436+ crd .Spec .Source .Helm .IgnoreMissingValueFiles
437+
438+ return isExplicitlyIgnored || isMissingAndShouldBeIgnored
439+ }
440+
440441func fileExists (path string ) bool {
441442 _ , err := os .Stat (path )
442443 return ! os .IsNotExist (err )
0 commit comments