Use kube::util::array_contains() in hack

The common kube::util::array_contains() is already there, so this
makes both scripts use it.
This commit is contained in:
Kenichi Omichi
2019-02-08 23:13:48 +00:00
parent 5bedff6625
commit 4a91b593ba
2 changed files with 4 additions and 30 deletions

View File

@@ -88,20 +88,6 @@ while IFS=$'\n' read -r script;
do failing_files+=("$script");
done < <(cat "${failure_file}")
# TODO(bentheelder): we should probably move this and the copy in verify-golint.sh
# to one of the bash libs
array_contains () {
local seeking=$1; shift # shift will iterate through the array
local in=1 # in holds the exit status for the function
for element; do
if [[ "$element" == "$seeking" ]]; then
in=0 # set in to 0 since we found it
break
fi
done
return $in
}
# detect if the host machine has the required shellcheck version installed
# if so, we will use that instead.
HAVE_SHELLCHECK=false
@@ -143,7 +129,7 @@ for f in "${all_shell_scripts[@]}"; do
shellcheck --exclude="${SHELLCHECK_DISABLED}" "${f}")
fi
set -o errexit
array_contains "${f}" "${failing_files[@]}" && in_failing=$? || in_failing=$?
kube::util::array_contains "${f}" "${failing_files[@]}" && in_failing=$? || in_failing=$?
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
errors+=( "${failedLint}" )
fi
@@ -185,7 +171,7 @@ fi
# Check that all failing_packages actually still exist
gone=()
for f in "${failing_files[@]}"; do
array_contains "$f" "${all_shell_scripts[@]}" || gone+=( "$f" )
kube::util::array_contains "$f" "${all_shell_scripts[@]}" || gone+=( "$f" )
done
if [[ ${#gone[@]} -gt 0 ]]; then