From 6ca8051beb35795b745bf49ec5ec58de5ea14d60 Mon Sep 17 00:00:00 2001 From: Istio Automation Date: Thu, 18 Jan 2024 13:35:33 -0800 Subject: [PATCH] Automator: update common-files@master in istio/istio.io@master (#14497) --- common/.commonfiles.sha | 2 +- common/scripts/setup_env.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/.commonfiles.sha b/common/.commonfiles.sha index 7f1e104b3e..4a065efa75 100644 --- a/common/.commonfiles.sha +++ b/common/.commonfiles.sha @@ -1 +1 @@ -372be4999661538e00683895441a643f792f965b +531a8c76730d2adb82f0813313971704b1e72442 diff --git a/common/scripts/setup_env.sh b/common/scripts/setup_env.sh index bc58c4a673..b8332cc094 100755 --- a/common/scripts/setup_env.sh +++ b/common/scripts/setup_env.sh @@ -130,12 +130,17 @@ fi # echo ${CONDITIONAL_HOST_MOUNTS} # This function checks if the file exists. If it does, it creates a randomly named host location -# for the file, adds it to the host KUBECONFIG, and creates a mount for it. +# for the file, adds it to the host KUBECONFIG, and creates a mount for it. Note that we use a copy +# of the original file, so that the container can write to it. add_KUBECONFIG_if_exists () { if [[ -f "$1" ]]; then + local local_config + local_config="$(mktemp)" + cp "${1}" "${local_config}" + kubeconfig_random="$(od -vAn -N4 -tx /dev/random | tr -d '[:space:]' | cut -c1-8)" container_kubeconfig+="/config/${kubeconfig_random}:" - CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${1},destination=/config/${kubeconfig_random},readonly " + CONDITIONAL_HOST_MOUNTS+="--mount type=bind,source=${local_config},destination=/config/${kubeconfig_random} " fi }