From 0ade8a5cf419d4fb5a0952b3d2977c1c9e004a14 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 27 Aug 2014 20:45:39 -0700 Subject: [PATCH] Do not leak undocumented variables from config-go.sh Run the snippet that creates the output/go/ tree in a subshell. Tested: - Built it with hack/build-go.sh - Ran release/build-release.sh successfully. - Moved away the git tree to confirm no regression in PR #1073. - Sourced hack/config-go.sh in the shell, confirmed no variable or function other than the expected ones leaked into the environment. - Used `git grep` to confirm the no longer exported variables were not in use by any script other than config-go.sh. Signed-off-by: Filipe Brandenburger --- hack/config-go.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hack/config-go.sh b/hack/config-go.sh index 719b5e0b25b..aedebed4b38 100644 --- a/hack/config-go.sh +++ b/hack/config-go.sh @@ -121,10 +121,17 @@ export KUBE_TARGET KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes export KUBE_GO_PACKAGE -KUBE_GO_PACKAGE_DIR="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}" +( + # Create symlink named ${KUBE_GO_PACKAGE} under output/go/src. + # So that Go knows how to import Kubernetes sources by full path. + # Use a subshell to avoid leaking these variables. -KUBE_GO_PACKAGE_BASEDIR=$(dirname "${KUBE_GO_PACKAGE_DIR}") -mkdir -p "${KUBE_GO_PACKAGE_BASEDIR}" + set -eu + go_pkg_dir="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}" + go_pkg_basedir=$(dirname "${go_pkg_dir}") + mkdir -p "${go_pkg_basedir}" + rm -f "${go_pkg_dir}" + # TODO: This symlink should be relative. + ln -s "${KUBE_REPO_ROOT}" "${go_pkg_dir}" +) -# Create symlink under output/go/src. -ln -snf "${KUBE_REPO_ROOT}" "${KUBE_GO_PACKAGE_DIR}"