Skip to content

Commit

Permalink
feat: disable cleanup on debug/trace (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslafy-z authored Jul 9, 2024
1 parent a89443e commit 71b3614
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.|`""`

Expand Down
18 changes: 11 additions & 7 deletions helm-git-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 71b3614

Please sign in to comment.