From 263b91854136d4cbb8e4a4a4db2aef5c821f8b24 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Mon, 24 Jul 2017 10:44:42 +0200 Subject: [PATCH] hack/update-staging-godep.sh: check for staging repos in GOPATH --- hack/godep-save.sh | 13 +------------ hack/lib/util.sh | 16 ++++++++++++++++ hack/update-staging-godeps.sh | 2 ++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/hack/godep-save.sh b/hack/godep-save.sh index ef2988ef572..eb7f086f334 100755 --- a/hack/godep-save.sh +++ b/hack/godep-save.sh @@ -24,6 +24,7 @@ source "${KUBE_ROOT}/hack/lib/util.sh" kube::util::ensure_single_dir_gopath kube::util::ensure_godep_version v79 +kube::util::ensure_no_staging_repos_in_gopath if [ -e "${KUBE_ROOT}/vendor" -o -e "${KUBE_ROOT}/Godeps" ]; then echo "The directory vendor/ or Godeps/ exists. Remove them before running godep-save.sh" 1>&2 @@ -40,18 +41,6 @@ REQUIRED_BINS=( ) pushd "${KUBE_ROOT}" > /dev/null - # sanity check that staging directories do not exist in GOPATH - error=0 - for repo in $(ls ${KUBE_ROOT}/staging/src/k8s.io); do - if [ -e "${GOPATH}/src/k8s.io/${repo}" ]; then - echo "k8s.io/${repo} exists in GOPATH. Remove before running godep-save.sh." 1>&2 - error=1 - fi - done - if [ "${error}" = "1" ]; then - exit 1 - fi - echo "Running godep save. This will take around 15 minutes." GOPATH=${GOPATH}:${KUBE_ROOT}/staging godep save "${REQUIRED_BINS[@]}" diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 2c486a01680..80e5545a449 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -513,6 +513,22 @@ kube::util::ensure_godep_version() { godep version } +# Ensure that none of the staging repos is checked out in the GOPATH because this +# easily confused godep. +kube::util::ensure_no_staging_repos_in_gopath() { + kube::util::ensure_single_dir_gopath + local error=0 + for repo in $(ls ${KUBE_ROOT}/staging/src/k8s.io); do + if [ -e "${GOPATH}/src/k8s.io/${repo}" ]; then + echo "k8s.io/${repo} exists in GOPATH. Remove before running godep-save.sh." 1>&2 + error=1 + fi + done + if [ "${error}" = "1" ]; then + exit 1 + fi +} + # Installs the specified go package at a particular commit. kube::util::go_install_from_commit() { local -r pkg=$1 diff --git a/hack/update-staging-godeps.sh b/hack/update-staging-godeps.sh index 18f1ddd51b1..65bcc0bf567 100755 --- a/hack/update-staging-godeps.sh +++ b/hack/update-staging-godeps.sh @@ -56,7 +56,9 @@ if ! kube::util::godep_restored 2>&1 | sed 's/^/ /'; then fi kube::util::ensure-temp-dir +kube::util::ensure_single_dir_gopath kube::util::ensure_godep_version v79 +kube::util::ensure_no_staging_repos_in_gopath TMP_GOPATH="${KUBE_TEMP}/go"