Use ensure-temp-dir in the common.sh script

Instead of having an ensure-temp-dir function in multiple
places, add it to the common.sh script which is sourced by
all the providers.
This commit is contained in:
Ryan Hallisey
2017-01-19 09:30:50 -05:00
parent 5e4625cad7
commit dbb92f9836
6 changed files with 11 additions and 57 deletions

View File

@@ -308,6 +308,17 @@ function load-or-gen-kube-bearertoken() {
fi
}
# Create a temp dir that'll be deleted at the end of this bash session.
#
# Vars set:
# KUBE_TEMP
function ensure-temp-dir {
if [[ -z ${KUBE_TEMP-} ]]; then
KUBE_TEMP=$(mktemp -d -t kubernetes.XXXXXX)
trap 'rm -rf "${KUBE_TEMP}"' EXIT
fi
}
# Get the master IP for the current-context in kubeconfig if one exists.
#
# Assumed vars: