@@ -13,7 +13,6 @@ import (
13
13
"os/exec"
14
14
"path"
15
15
"path/filepath"
16
- "regexp"
17
16
"sort"
18
17
"strings"
19
18
"sync"
@@ -54,12 +53,7 @@ func buildParams(payload *v1alpha1.Application, ignoreValueFile string) (string,
54
53
55
54
}
56
55
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 ) {
63
57
fileValues += fmt .Sprintf ("%s," , helmFiles [i ])
64
58
}
65
59
}
@@ -219,11 +213,9 @@ func GenerateHash(crd *v1alpha1.Application, ignoreValueFile string) (string, er
219
213
if crd .Spec .Source .Helm != nil && len (crd .Spec .Source .Helm .ValueFiles ) > 0 {
220
214
oHash := sha256 .New ()
221
215
overrideFiles := crd .Spec .Source .Helm .ValueFiles
222
- matchDots := regexp .MustCompile (`\.\.\/` )
223
216
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 ]))
227
219
if err != nil {
228
220
return "" , err
229
221
}
@@ -437,6 +429,15 @@ func Read(inputCRD string) ([]*v1alpha1.Application, error) {
437
429
return crdSpecs , nil
438
430
}
439
431
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
+
440
441
func fileExists (path string ) bool {
441
442
_ , err := os .Stat (path )
442
443
return ! os .IsNotExist (err )
0 commit comments