Skip to content

Commit

Permalink
generate-values: add fix for uninstalled helmfile releases
Browse files Browse the repository at this point in the history
  • Loading branch information
deer-wmde committed Aug 2, 2024
1 parent 556b186 commit 6181459
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions bin/generate-values
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#!/bin/bash

set -x

function usage() {
echo
echo "usage: $(basename $0) <environment> <release-name> [output-file-template]"
echo
}

# absolute path of the wbaas-deploy repository
ROOT=$(realpath $(dirname $(realpath $BASH_SOURCE))/..)

ENVIRONMENT="$1"
RELEASE="$2"

OUTPUT="${ROOT}/k8s/argocd/${ENVIRONMENT}/${RELEASE}.values.yaml"
# absolute path of the wbaas-deploy repository
ROOT=$(realpath $(dirname $(realpath $BASH_SOURCE))/..)
OUTPUT_TEMPLATE="${ROOT}/k8s/argocd/${ENVIRONMENT}/${RELEASE}.values.yaml"
HELMFILE="k8s/helmfile/helmfile.yaml"
TMP_HELMFILE="$(dirname ${HELMFILE})/.tmp_helmfile.$(mktemp -u XXXXXX).yaml"

if [[ -n "$3" ]]; then
OUTPUT="$3"
OUTPUT_TEMPLATE="$3"
fi

if [[ ! -e "${HELMFILE}" ]]; then
Expand All @@ -39,13 +37,22 @@ if [[ -z "${RELEASE}" ]]; then
exit 3
fi

echo "environment: ${ENVIRONMENT}"
echo "release: ${RELEASE}"

# modify tmp helmfile by setting each release as "installed", so it always gets processed
cp "${HELMFILE}" "${TMP_HELMFILE}"
sed -i 's/installed: .*$/installed: true/g' "${TMP_HELMFILE}"

helmfile \
--file "${HELMFILE}" \
--file "${TMP_HELMFILE}" \
--environment "${ENVIRONMENT}" \
--selector name="${RELEASE}" \
--output-file-template "${OUTPUT}" \
--output-file-template "${OUTPUT_TEMPLATE}" \
--skip-deps \
write-values

# fix indentation for yamllint action
yq -I 2 -i "${OUTPUT}"
rm "${TMP_HELMFILE}"

# fix indentation in output file for yamllint action
yq -I 2 -i "${OUTPUT_TEMPLATE}"

0 comments on commit 6181459

Please sign in to comment.