Skip to content

Commit

Permalink
feat: use dedicated helm home
Browse files Browse the repository at this point in the history
  • Loading branch information
fredleger committed Apr 5, 2023
1 parent 1c42c0a commit 7888e3b
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion helm-ct.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
#!/bin/bash

# shellcheck disable=SC2034

set -eu -o pipefail

CT_ARGS=("$@")

echo "+ setting a clean helm environment"
HELM_HOME="$(mktemp -d)"

HELM_CACHE_HOME="$HELM_HOME/cache"
HELM_CONFIG_HOME="$HELM_HOME/config"
HELM_DATA_HOME="$HELM_HOME/data"

KUBECONFIG="$(mktemp -d)/kubeconfig"
touch "$KUBECONFIG" && chmod 600 "$KUBECONFIG"

echo "+ building helm dependencies"
INITIAL_DIR="$(realpath .)"
find . -name Chart.yaml -exec dirname {} \; | while read -r chartdir; do
echo "+ building dependencies for $chartdir"
cd "$chartdir" || exit 1
i=0; for url in $(yq '.dependencies' Chart.yaml -o=json | jq -r '.[].repository'); do
echo "${url}" | grep -qE '^(https?|git)://' || continue
i=$((i+1)); helm repo add repo-${i} "${url}"
helm repo update repo-${i}
done
cd - || exit 1
done
cd "$INITIAL_DIR" || exit 1

echo "+ running helm chart testing (ct) linter"

find . -name ct.yaml -exec dirname {} \; | while read -r ctdir; do
echo "+ running ct lint from $ctdir"
cd "$ctdir" || exit 1
ct lint "${CT_ARGS}"
set -x
ct lint "${CT_ARGS[@]}"
done

echo "+ cleaning helm environment"
rm -rf "$HELM_HOME"

echo "+ helm chart testing (ct) linter completed"
exit 0

0 comments on commit 7888e3b

Please sign in to comment.