diff --git a/README.md b/README.md index b7d6df1..736f82f 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Pulling value files: --------|---------------|----------- `HELM_GIT_HELM_BIN`|Path to the `helm` binary. If not set, `$HELM_BIN` will be used.|`helm` `HELM_GIT_DEBUG`|Setting this value to `1` increases `helm-git` log level. |`0` -`HELM_GIT_TRACE`|Setting this value to `1` increases `helm-git` log level to the maximum. |`0` +`HELM_GIT_TRACE`|Setting this value to `1` increases `helm-git` log level to the maximum and keeps temporary dirs at shutdown. |`0` `HELM_GIT_REPO_CACHE`|Path to use as a Git repository cache to avoid fetching repos more than once. If empty, caching of Git repositories is disabled.|`""` `HELM_GIT_CHART_CACHE`|Path to use as a Helm chart cache to avoid re-packaging/re-indexing charts. If empty, caching of Helm charts is disabled.|`""` diff --git a/helm-git-plugin.sh b/helm-git-plugin.sh index fa50101..3887b15 100755 --- a/helm-git-plugin.sh +++ b/helm-git-plugin.sh @@ -21,20 +21,23 @@ readonly error_invalid_protocol # Debug & trace output configuration debug=0 -if [ "${HELM_GIT_DEBUG:-}" = "1" ]; then - debug=1 -fi trace=0 +cleanup=1 git_output="/dev/null" git_quiet="--quiet" +if [ "${HELM_GIT_DEBUG:-}" = "1" ]; then + debug=1 +fi if [ "${HELM_GIT_TRACE:-}" = "1" ]; then trace=1 debug=1 + cleanup=0 git_output="/dev/stderr" git_quiet="" fi -readonly trace readonly debug +readonly trace +readonly cleanup readonly git_output readonly git_quiet @@ -396,13 +399,14 @@ main() { fi fi - # Setup cleanup trap + # Setup exit trap # shellcheck disable=SC2317 - cleanup() { + exit_trap() { + [ "$cleanup" = 1 ] || return 0 rm -rf "$git_root_path" "${helm_home_target_path:-}" [ "$cache_charts_enabled" = 1 ] || rm -rf "${helm_target_path:-}" } - trap cleanup EXIT + trap exit_trap EXIT git_root_path="$(mktemp -d "$TMPDIR/helm-git.XXXXXX")" readonly git_root_path="$git_root_path"