Automator: update common-files@master in istio/istio.io@master (#7495)

This commit is contained in:
Istio Automation 2020-06-06 09:57:40 -07:00 committed by GitHub
parent 8421ae1ce3
commit 4ade2faeca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 7 deletions

View File

@ -1 +1 @@
e0feb0045df4693dbf1c2dd91345fd8bc140c15a
8497584411805aa0684098f837c3e364886e92d7

View File

@ -92,6 +92,7 @@ done
# Set conditional host mounts
export CONDITIONAL_HOST_MOUNTS=${CONDITIONAL_HOST_MOUNTS:-}
container_kubeconfig=''
# docker conditional host mount (needed for make docker push)
if [[ -d "${HOME}/.docker" ]]; then
@ -103,12 +104,45 @@ if [[ -d "${HOME}/.config/gcloud" ]]; then
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${HOME}/.config/gcloud,destination=/config/.config/gcloud,readonly,consistency=delegated "
fi
# Conditional host mount if KUBECONFIG is set
if [[ -n "${KUBECONFIG}" ]]; then
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=$(dirname "${KUBECONFIG}"),destination=/home/.kube,readonly,consistency=delegated "
elif [[ -f "${HOME}/.kube/config" ]]; then
# otherwise execute a conditional host mount if $HOME/.kube/config is set
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${HOME}/.kube,destination=/home/.kube,readonly,consistency=delegated "
# This function is designed for maximum compatibility with various platforms. This runs on
# any Mac or Linux platform with bash 4.2+. Please take care not to modify this function
# without testing properly.
#
# This function will properly handle any type of path including those with spaces using the
# loading pattern specified by *kubectl config*.
#
# testcase: "a:b c:d"
# testcase: "a b:c d:e f"
# testcase: "a b:c:d e"
parse_KUBECONFIG () {
TMPDIR=""
if [[ "$1" =~ ([^:]*):(.*) ]]; then
while true; do
rematch=${BASH_REMATCH[1]}
kubeconfig_random="$(od -vAn -N4 -tx /dev/random | tr -d '[:space:]' | cut -c1-8)"
container_kubeconfig+="/home/${kubeconfig_random}:"
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${rematch},destination=/config/${kubeconfig_random},readonly,consistency=delegated "
remainder="${BASH_REMATCH[2]}"
if [[ ! "$remainder" =~ ([^:]*):(.*) ]]; then
if [[ -n "$remainder" ]]; then
kubeconfig_random="$(od -vAn -N4 -tx /dev/random | tr -d '[:space:]' | cut -c1-8)"
container_kubeconfig+="/home/${kubeconfig_random}:"
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${remainder},destination=/config/${kubeconfig_random},readonly,consistency=delegated "
break
fi
fi
done
else
kubeconfig_random="$(od -vAn -N4 -tx /dev/random | tr -d '[:space:]' | cut -c1-8)"
container_kubeconfig+="/home/${kubeconfig_random}:"
CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${1},destination=/config/${kubeconfig_random},readonly,consistency=delegated "
fi
}
KUBECONFIG=${KUBECONFIG:="$HOME/.kube/config"}
parse_KUBECONFIG "${KUBECONFIG}"
if [[ "$BUILD_WITH_CONTAINER" -eq "1" ]]; then
export KUBECONFIG="${container_kubeconfig%?}"
fi
# Avoid recursive calls to make from attempting to start an additional container