Skip to content

Commit

Permalink
fix: avoid setting DELETE_AT_EXIT multiple times (#2619)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyardley authored Sep 26, 2024
1 parent cce4a74 commit ac6615a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion infra/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ OPA_VERSION := 0.52.0
# Updated by Update Tooling Workflow
GCRANE_VERSION := 0.20.2

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.22.12
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.22.13
DOCKER_TAG_MAJOR_VERSION_DEVELOPER_TOOLS := $(firstword $(subst ., , $(DOCKER_TAG_VERSION_DEVELOPER_TOOLS)))
DOCKER_TAG_MINOR_VERSION_DEVELOPER_TOOLS := $(shell echo "${DOCKER_TAG_VERSION_DEVELOPER_TOOLS}" | awk -F. '{print $$1"."$$2}')

Expand Down
17 changes: 10 additions & 7 deletions infra/build/developer-tools/build/scripts/task_helper_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# setup_trap_handler() and used by maketemp()
finish() {
if [[ -n "${DELETE_AT_EXIT:-}" ]]; then
rm -rf "${DELETE_AT_EXIT}"
rm -rf "$DELETE_AT_EXIT"
fi
}

Expand All @@ -27,7 +27,10 @@ finish() {
# for use with maketemp() to automatically clean up temporary files, especially
# those used to store credentials.
setup_trap_handler() {
readonly DELETE_AT_EXIT="$(mktemp -d)"
if [[ -z "${DELETE_AT_EXIT+x}" ]]; then
DELETE_AT_EXIT="$(mktemp -d)"
readonly DELETE_AT_EXIT
fi
trap finish EXIT
}

Expand Down Expand Up @@ -152,8 +155,8 @@ function lint_docker() {

# This function creates TF_PLUGIN_CACHE_DIR if TF_PLUGIN_CACHE_DIR envvar is set
function init_tf_plugin_cache() {
if [[ ! -z "${TF_PLUGIN_CACHE_DIR}" ]]; then
mkdir -p ${TF_PLUGIN_CACHE_DIR}
if [[ -n "$TF_PLUGIN_CACHE_DIR" ]]; then
mkdir -p "$TF_PLUGIN_CACHE_DIR"
fi
}

Expand Down Expand Up @@ -237,7 +240,7 @@ check_whitespace() {
local rc
echo "Checking for trailing whitespace"
find_files . -print \
| grep -v -E '\.(pyc|png|gz|tfvars|mp4|zip|ico|jar|parquet|pb|index)$' \
| grep -v -E '\.(pyc|png|gz|swp|tfvars|mp4|zip|ico|jar|parquet|pb|index)$' \
| compat_xargs grep -H -n '[[:blank:]]$'
rc=$?
if [[ ${rc} -eq 0 ]]; then
Expand Down Expand Up @@ -519,9 +522,9 @@ function fix_headers() {
YEAR=$(date +'%Y')
if [ $# -eq 0 ]
then
find_files . for_header_check -type f -print0 | compat_xargs -0 addlicense -y $YEAR
find_files . for_header_check -type f -print0 | compat_xargs -0 addlicense -y "$YEAR"
else
addlicense -y $YEAR "$@"
addlicense -y "$YEAR" "$@"
fi
}

Expand Down

0 comments on commit ac6615a

Please sign in to comment.