Add check-file-in-alphabetical-order for cleanup

Both verify-golint.sh and verify-shellcheck.sh have the same logic
which checks failure_file in alphabetical order.
In addition, we'd like to add another script which requires the
same logic. So this add a common function for cleanup.
This commit is contained in:
Kenichi Omichi
2019-01-26 02:04:00 +00:00
parent 5673506540
commit c32d1acbb9
3 changed files with 21 additions and 20 deletions

View File

@@ -20,6 +20,7 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/util.sh"
kube::golang::verify_go_version
@@ -49,16 +50,7 @@ array_contains () {
# Check that the file is in alphabetical order
failure_file="${KUBE_ROOT}/hack/.golint_failures"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
{
echo
echo "hack/.golint_failures is not in alphabetical order. Please sort it:"
echo
echo " LC_ALL=C sort -o hack/.golint_failures hack/.golint_failures"
echo
} >&2
false
fi
kube::util::check-file-in-alphabetical-order "${failure_file}"
export IFS=$'\n'
# NOTE: when "go list -e ./..." is run within GOPATH, it turns the k8s.io/kubernetes