Skip to content

Commit bf592ab

Browse files
authored
Merge pull request #31 from chime/vy-respect-ignore-missing-value-files
Respect ignoreMissingValueFiles
2 parents cbbd154 + fe2320d commit bf592ab

14 files changed

+376
-322
lines changed

pkg/helm/helm.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"log"
1212
"os"
1313
"os/exec"
14+
"path"
1415
"path/filepath"
1516
"regexp"
1617
"sort"
@@ -53,7 +54,12 @@ func buildParams(payload *v1alpha1.Application, ignoreValueFile string) (string,
5354

5455
}
5556
for i := 0; i < len(helmFiles); i++ {
56-
if ignoreValueFile == "" || !strings.Contains(helmFiles[i], ignoreValueFile) {
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 {
5763
fileValues += fmt.Sprintf("%s,", helmFiles[i])
5864
}
5965
}
@@ -430,3 +436,8 @@ func Read(inputCRD string) ([]*v1alpha1.Application, error) {
430436

431437
return crdSpecs, nil
432438
}
439+
440+
func fileExists(path string) bool {
441+
_, err := os.Stat(path)
442+
return !os.IsNotExist(err)
443+
}

0 commit comments

Comments
 (0)