Skip to content

Commit

Permalink
Merge pull request #66 from sule26/master
Browse files Browse the repository at this point in the history
feat: enable use helmfile.yaml.gotmpl
  • Loading branch information
travisghansen authored Oct 3, 2024
2 parents 2d3579c + 327e328 commit e74dfec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
20 changes: 18 additions & 2 deletions src/argo-cd-helmfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e74dfec

Please sign in to comment.