mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Fix bug in golint script when no files
The script would get a 1 return code from grep when there are no files in a directory, after filtering generated filenames. This would cause the script to exit unexpectedly.
This commit is contained in:
parent
105e8f8467
commit
1b07b0d648
@ -69,7 +69,13 @@ for p in "${all_packages[@]}"; do
|
|||||||
# completely.
|
# completely.
|
||||||
# Ref: https://github.com/kubernetes/kubernetes/pull/67675
|
# Ref: https://github.com/kubernetes/kubernetes/pull/67675
|
||||||
# Ref: https://github.com/golang/lint/issues/68
|
# Ref: https://github.com/golang/lint/issues/68
|
||||||
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)
|
|
||||||
|
files=$(find "$p"/*.go \
|
||||||
|
| grep -vE "(zz_generated.*.go|generated.pb.go|generated.proto|types_swagger_doc_generated.go)" || true)
|
||||||
|
if [ -z "${files}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
failedLint=$(echo "${files}" | xargs -L1 golint 2>/dev/null)
|
||||||
kube::util::array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
|
kube::util::array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
|
||||||
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
|
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
|
||||||
errors+=( "${failedLint}" )
|
errors+=( "${failedLint}" )
|
||||||
|
Loading…
Reference in New Issue
Block a user