From 773e1c7f93149d3477a1155af3c493eaf7c7a22f Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Thu, 1 Sep 2016 16:36:24 -0400 Subject: [PATCH] fix hack/verify-golint.sh to work outside of GOPATH "go list -e ./..." returns different results when run from the usual GOPATH location (returns k8s.io/kubernetes as prefix) and when run outside of it (returns _ followed by full path of the file). We need to support both scenarios. Fixes #31905 --- hack/verify-golint.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh index fe994cc9a5d..eb1ebe8c395 100755 --- a/hack/verify-golint.sh +++ b/hack/verify-golint.sh @@ -51,8 +51,11 @@ if ! diff -u "${linted_file}" <(LANG=C sort "${linted_file}"); then fi export IFS=$'\n' +# NOTE: when "go list -e ./..." is run within GOPATH, it turns the k8s.io/kubernetes +# as the prefix, however if we run it outside it returns the full path of the file +# with a leading underscore. We'll need to support both scenarios for all_packages. all_packages=( - $(go list -e ./... | egrep -v "/(third_party|vendor|staging|generated|clientset_generated)" | sed 's/k8s.io\/kubernetes\///g') + $(go list -e ./... | egrep -v "/(third_party|vendor|staging|generated|clientset_generated)" | sed -e 's|^k8s.io/kubernetes/||' -e "s|^_${KUBE_ROOT}/\?||") ) linted_packages=( $(cat $linted_file)