Skip to content

Commit

Permalink
Support helm template
Browse files Browse the repository at this point in the history
In order to make this work, two changes were needed:

1. Add template to the list of helm commands that trigger this.
2. Make sure all helm-secrets output goes to stderr, so when helm
   template runs (and sends the contents to stdout) the output streams
   don't intermix.
  • Loading branch information
novas0x2a committed Dec 12, 2017
1 parent a77aaa4 commit 4bcb370
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -ueo pipefail

# Redirect fds so that output to &3 is real stdout, and &1 goes to stderr
# instead; this prevents accidentially intermixing with what helm sends to
# stdout.
exec 3>&1
exec 1>&2

# colors
RED='\033[0;31m'
#GREEN='\033[0;32m'
Expand Down Expand Up @@ -70,7 +76,7 @@ decrypt_helm_vars() {

function cleanup {
case "${CURRENT_COMMAND}" in
install|upgrade|rollback)
install|upgrade|rollback|template)
echo -e "${YELLOW}>>>>>>${NOC} ${BLUE}Cleanup${NOC}"
for file in "${@}";
do
Expand All @@ -84,7 +90,7 @@ function cleanup {

function helm_cmd {
echo ""
$(echo "${HELM_CMD} $*" | sed -e 's/secrets.yaml/secrets.yaml.dec/g')
$(echo "${HELM_CMD} $*" | sed -e 's/secrets.yaml/secrets.yaml.dec/g') >&3
local status=$?
if [ "$status" -ne 0 ]; then
echo ""
Expand All @@ -98,7 +104,7 @@ function helm_cmd {
}

case "${CURRENT_COMMAND}" in
install|upgrade|rollback)
install|upgrade|rollback|template)
for file in "$@"
do
decrypt_helm_vars "$file"
Expand Down

0 comments on commit 4bcb370

Please sign in to comment.