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 03c7ec1be80..553cddb5ca9 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"