@@ -42,8 +42,16 @@ readonly git_quiet
42
42
export TMPDIR=" ${TMPDIR:-/ tmp} "
43
43
44
44
# Cache repos or charts depending on the cache path existing in the environment variables
45
- CACHE_REPOS=$( [ -n " ${HELM_GIT_REPO_CACHE:- } " ] && echo " true" || echo " false" )
46
- CACHE_CHARTS=$( [ -n " ${HELM_GIT_CHART_CACHE:- } " ] && echo " true" || echo " false" )
45
+ cache_repos_enabled=0
46
+ if [ -n " ${HELM_GIT_REPO_CACHE:- } " ]; then
47
+ cache_repos_enabled=1
48
+ fi
49
+ readonly cache_repos_enabled
50
+ cache_charts_enabled=0
51
+ if [ -n " ${HELM_GIT_CHART_CACHE:- } " ]; then
52
+ cache_charts_enabled=1
53
+ fi
54
+ readonly cache_charts_enabled
47
55
48
56
# # Tooling
49
57
@@ -151,7 +159,7 @@ git_checkout() {
151
159
_git_ref=$4
152
160
_git_path=$5
153
161
154
- if $CACHE_REPOS ; then
162
+ if [ " $cache_repos_enabled " = 1 ] ; then
155
163
_intercepted_repo=$( git_cache_intercept " ${_git_repo} " " ${_git_ref} " ) && _git_repo=" ${_intercepted_repo} "
156
164
fi
157
165
@@ -372,7 +380,7 @@ main() {
372
380
readonly helm_repo_uri=" git+${git_repo} @${helm_dir} ?ref=${git_ref} &sparse=${git_sparse} &depupdate=${helm_depupdate} &package=${helm_package} "
373
381
trace " helm_repo_uri: $helm_repo_uri "
374
382
375
- if ${CACHE_CHARTS} ; then
383
+ if [ " $cache_charts_enabled " = 1 ] ; then
376
384
_request_hash=$( echo " ${_raw_uri} " | md5sum | cut -d " " -f1)
377
385
378
386
_cache_folder=" ${HELM_GIT_CHART_CACHE} /${_request_hash} "
@@ -392,7 +400,7 @@ main() {
392
400
# shellcheck disable=SC2317
393
401
cleanup () {
394
402
rm -rf " $git_root_path " " ${helm_home_target_path:- } "
395
- ${CACHE_CHARTS} || rm -rf " ${helm_target_path:- } "
403
+ [ " $cache_charts_enabled " = 1 ] || rm -rf " ${helm_target_path:- } "
396
404
}
397
405
trap cleanup EXIT
398
406
@@ -412,7 +420,7 @@ main() {
412
420
return
413
421
fi
414
422
415
- if ${CACHE_CHARTS} ; then
423
+ if [ " $cache_charts_enabled " = 1 ] ; then
416
424
helm_target_path=" ${_cache_folder} "
417
425
else
418
426
helm_target_path=" $( mktemp -d " $TMPDIR /helm-git.XXXXXX" ) "
0 commit comments