Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: disable cleanup on trace #293

Merged
merged 6 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -388,13 +391,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} || 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
Loading