diff --git a/hack/.shellcheck_failures b/hack/.shellcheck_failures index 06f051c65f..1e9e6d2272 100644 --- a/hack/.shellcheck_failures +++ b/hack/.shellcheck_failures @@ -29,7 +29,6 @@ ./hack/pin-dependency.sh ./hack/test-integration.sh ./hack/update-vendor.sh -./hack/verify-golint.sh ./hack/verify-test-featuregates.sh ./test/cmd/apply.sh ./test/cmd/apps.sh diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh index 79508a9adb..10aaf9bafc 100755 --- a/hack/verify-golint.sh +++ b/hack/verify-golint.sh @@ -18,7 +18,7 @@ set -o errexit set -o nounset set -o pipefail -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/util.sh" @@ -44,12 +44,10 @@ 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/src/k8s.io/client-go/pkg|generated|clientset_generated)" | sed -e 's|^k8s.io/kubernetes/||' -e "s|^_\(${KUBE_ROOT}/\)\{0,1\}||") -) -failing_packages=( - $(cat $failure_file) -) +all_packages=() +while IFS='' read -r line; do all_packages+=("$line"); done < <(go list -e ./... | grep -vE "/(third_party|vendor|staging/src/k8s.io/client-go/pkg|generated|clientset_generated)" | sed -e 's|^k8s.io/kubernetes/||' -e "s|^_\(${KUBE_ROOT}/\)\{0,1\}||") +failing_packages=() +while IFS='' read -r line; do failing_packages+=("$line"); done < <(cat "$failure_file") unset IFS errors=() not_failing=() @@ -63,13 +61,13 @@ for p in "${all_packages[@]}"; do # completely. # Ref: https://github.com/kubernetes/kubernetes/pull/67675 # Ref: https://github.com/golang/lint/issues/68 - failedLint=$(ls "$p"/*.go | egrep -v "(zz_generated.*.go|generated.pb.go|generated.proto|types_swagger_doc_generated.go)" | xargs -L1 golint 2>/dev/null) + failedLint=$(find "$p"/*.go | grep -vE "(zz_generated.*.go|generated.pb.go|generated.proto|types_swagger_doc_generated.go)" | xargs -L1 golint 2>/dev/null) kube::util::array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$? if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then errors+=( "${failedLint}" ) fi if [[ -z "${failedLint}" ]] && [[ "${in_failing}" -eq "0" ]]; then - not_failing+=( $p ) + not_failing+=( "$p" ) fi done