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 <filbranden@google.com>
This commit is contained in:
Filipe Brandenburger 2014-08-27 20:45:39 -07:00
parent 391cd856c1
commit 0ade8a5cf4

View File

@ -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}"