Merge pull request #99905 from BenTheElder/shellchecked

update verify-shellcheck to v0.7.1, fix nits, multi-arch digest pinning, fix new lint errors
This commit is contained in:
Kubernetes Prow Robot 2021-03-06 22:17:53 -08:00 committed by GitHub
commit 90851a0fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 10 deletions

View File

@ -874,7 +874,7 @@ kube::golang::build_binaries() {
cat "/tmp//${platform//\//_}.build" cat "/tmp//${platform//\//_}.build"
done done
exit ${fails} exit "${fails}"
else else
for platform in "${platforms[@]}"; do for platform in "${platforms[@]}"; do
kube::log::status "Building go targets for ${platform}:" "${targets[@]}" kube::log::status "Building go targets for ${platform}:" "${targets[@]}"

View File

@ -25,11 +25,14 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/util.sh" source "${KUBE_ROOT}/hack/lib/util.sh"
# allow overriding docker cli, which should work fine for this script
DOCKER="${DOCKER:-docker}"
# required version for this script, if not installed on the host we will # required version for this script, if not installed on the host we will
# use the official docker image instead. keep this in sync with SHELLCHECK_IMAGE # use the official docker image instead. keep this in sync with SHELLCHECK_IMAGE
SHELLCHECK_VERSION="0.7.0" SHELLCHECK_VERSION="0.7.1"
# upstream shellcheck latest stable image as of October 23rd, 2019 # upstream shellcheck latest stable image as of October 23rd, 2019
SHELLCHECK_IMAGE="koalaman/shellcheck-alpine:v0.7.0@sha256:24bbf52aae6eaa27accc9f61de32d30a1498555e6ef452966d0702ff06f38ecb" SHELLCHECK_IMAGE="docker.io/koalaman/shellcheck-alpine:v0.7.1@sha256:d6147f30864ddb7c9cf983fc277d345bc315e798e309ddf70062b194843ee252"
# disabled lints # disabled lints
disabled=( disabled=(
@ -105,7 +108,7 @@ if ${HAVE_SHELLCHECK}; then
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" || res=$? shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" || res=$?
else else
echo "Using shellcheck ${SHELLCHECK_VERSION} docker image." echo "Using shellcheck ${SHELLCHECK_VERSION} docker image."
docker run \ "${DOCKER}" run \
--rm -v "${KUBE_ROOT}:${KUBE_ROOT}" -w "${KUBE_ROOT}" \ --rm -v "${KUBE_ROOT}:${KUBE_ROOT}" -w "${KUBE_ROOT}" \
"${SHELLCHECK_IMAGE}" \ "${SHELLCHECK_IMAGE}" \
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" || res=$? shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" || res=$?
@ -113,7 +116,7 @@ fi
# print a message based on the result # print a message based on the result
if [ $res -eq 0 ]; then if [ $res -eq 0 ]; then
echo 'Congratulations! All shell files are passing lint (excluding those in hack/.shellcheck_failures).' echo 'Congratulations! All shell files are passing lint :-)'
else else
{ {
echo echo
@ -121,7 +124,7 @@ else
echo 'If the above warnings do not make sense, you can exempt this warning with a comment' echo 'If the above warnings do not make sense, you can exempt this warning with a comment'
echo ' (if your reviewer is okay with it).' echo ' (if your reviewer is okay with it).'
echo 'In general please prefer to fix the error, we have already disabled specific lints' echo 'In general please prefer to fix the error, we have already disabled specific lints'
echo ' that the project chooses to ignire.' echo ' that the project chooses to ignore.'
echo 'See: https://github.com/koalaman/shellcheck/wiki/Ignore#ignoring-one-specific-instance-in-a-file' echo 'See: https://github.com/koalaman/shellcheck/wiki/Ignore#ignoring-one-specific-instance-in-a-file'
echo echo
} >&2 } >&2

View File

@ -560,7 +560,7 @@ run_pod_tests() {
resourceVersion=$(kubectl get "${kube_flags[@]}" pod valid-pod -o go-template='{{ .metadata.resourceVersion }}') resourceVersion=$(kubectl get "${kube_flags[@]}" pod valid-pod -o go-template='{{ .metadata.resourceVersion }}')
((resourceVersion+=100)) ((resourceVersion+=100))
# Command # Command
kubectl patch "${kube_flags[@]}" pod valid-pod -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "nginx"}]},"metadata":{"resourceVersion":"'$resourceVersion'"}}' 2> "${ERROR_FILE}" || true kubectl patch "${kube_flags[@]}" pod valid-pod -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "nginx"}]},"metadata":{"resourceVersion":"'"$resourceVersion"'"}}' 2> "${ERROR_FILE}" || true
# Post-condition: should get an error reporting the conflict # Post-condition: should get an error reporting the conflict
if grep -q "please apply your changes to the latest version and try again" "${ERROR_FILE}"; then if grep -q "please apply your changes to the latest version and try again" "${ERROR_FILE}"; then
kube::log::status "\"kubectl patch with resourceVersion $resourceVersion\" returns error as expected: $(cat "${ERROR_FILE}")" kube::log::status "\"kubectl patch with resourceVersion $resourceVersion\" returns error as expected: $(cat "${ERROR_FILE}")"

View File

@ -60,7 +60,7 @@ for peer in "${PEERS[@]}"; do
if [[ "${peer}" == *"${HOSTNAME}"* ]]; then if [[ "${peer}" == *"${HOSTNAME}"* ]]; then
MY_ID=$i MY_ID=$i
MY_NAME=${peer} MY_NAME=${peer}
echo $i > "${MY_ID_FILE}" echo "$i" > "${MY_ID_FILE}"
echo "server.${i}=${peer}:2888:3888:observer;2181" >> "${CFG_BAK}" echo "server.${i}=${peer}:2888:3888:observer;2181" >> "${CFG_BAK}"
else else
if [[ $(echo srvr | /opt/nc "${peer}" 2181 | grep Mode) = "Mode: leader" ]]; then if [[ $(echo srvr | /opt/nc "${peer}" 2181 | grep Mode) = "Mode: leader" ]]; then
@ -95,10 +95,10 @@ ADD_SERVER="server.$MY_ID=$MY_NAME:2888:3888:participant;0.0.0.0:2181"
# Prove that we've actually joined the running cluster # Prove that we've actually joined the running cluster
ITERATION=0 ITERATION=0
until echo config | /opt/nc localhost 2181 | grep "${ADD_SERVER}" > /dev/null; do until echo config | /opt/nc localhost 2181 | grep "${ADD_SERVER}" > /dev/null; do
echo $ITERATION] waiting for updated config to sync back to localhost echo "$ITERATION"] waiting for updated config to sync back to localhost
sleep 1 sleep 1
(( ITERATION=ITERATION+1 )) (( ITERATION=ITERATION+1 ))
if [ $ITERATION -eq 20 ]; then if [ "$ITERATION" -eq 20 ]; then
exit 1 exit 1
fi fi
done done