diff --git a/README.md b/README.md index 55dcfbb..ffcde50 100644 --- a/README.md +++ b/README.md @@ -113,8 +113,8 @@ repoServer: Configure your `argo-cd` app to use a repo/directory which holds a valid `helmfile` configuration. This can be a directory which contains a -`helmfile.yaml` file **OR** a `helmfile.d` directory containing any number of -`*.yaml` files. You cannot have both configurations. +`helmfile.yaml` **OR** `helmfile.yaml.gotmpl` file **OR** a `helmfile.d` directory containing any number of +`*.yaml` or `*.yaml.gotmpl` files. You cannot have both configurations. There are a number of specially handled `ENV` variables which can be set (all optional): @@ -130,7 +130,7 @@ optional): - `HELMFILE_TEMPLATE_OPTIONS` - pass-through options for the templating operation `helmfile template --help` - `HELMFILE_INIT_SCRIPT_FILE` - path to script to execute during init phase -- `HELMFILE_HELMFILE` - a complete `helmfile.yaml` content +- `HELMFILE_HELMFILE` - a complete `helmfile.yaml` or `helmfile.yaml.gotmpl` content - `HELMFILE_HELMFILE_STRATEGY` - one of `REPLACE` or `INCLUDE` - `REPLACE` - the default option, only the content of `HELMFILE_HELMFILE` is rendered, if any valid files exist in the repo they are ignored diff --git a/src/argo-cd-helmfile.sh b/src/argo-cd-helmfile.sh index 2d148c3..ee786f2 100755 --- a/src/argo-cd-helmfile.sh +++ b/src/argo-cd-helmfile.sh @@ -313,14 +313,25 @@ case $phase in case "${HELMFILE_HELMFILE_STRATEGY}" in "INCLUDE") - if [[ -f "helmfile.yaml" && -d "helmfile.d" ]]; then - echoerr "configuration conlict error: you can have either helmfile.yaml or helmfile.d, but not both" + + count=0 + + [[ -f "helmfile.yaml" ]] && ((count++)) + [[ -f "helmfile.yaml.gotmpl" ]] && ((count++)) + [[ -d "helmfile.d" ]] && ((count++)) + + if [[ $count -gt 1 ]]; then + echoerr "You can have either helmfile.yaml, helmfile.yaml.gotmpl, or helmfile.d, but not more than one" fi if [[ -f "helmfile.yaml" ]]; then cp -a "helmfile.yaml" "${HELMFILE_HELMFILE_HELMFILED}/" fi + if [[ -f "helmfile.yaml.gotmpl" ]]; then + cp -a "helmfile.yaml.gotmpl" "${HELMFILE_HELMFILE_HELMFILED}/" + fi + if [[ -d "helmfile.d" ]]; then cp -ar "helmfile.d/"* "${HELMFILE_HELMFILE_HELMFILED}/" fi @@ -442,6 +453,11 @@ case $phase in exit 0 fi + if [[ -f "helmfile.yaml.gotmpl" ]]; then + echo "valid helmfile content discovered" + exit 0 + fi + if [[ -d "helmfile.d" ]]; then echo "valid helmfile content discovered" exit 0