Bump shellcheck to 0.9.0
Fix everything it flagged.
This commit is contained in:
		| @@ -614,7 +614,7 @@ function kube::build::start_rsyncd_container() { | |||||||
|     -- /rsyncd.sh >/dev/null |     -- /rsyncd.sh >/dev/null | ||||||
|  |  | ||||||
|   local mapped_port |   local mapped_port | ||||||
|   if ! mapped_port=$("${DOCKER[@]}" port "${KUBE_RSYNC_CONTAINER_NAME}" ${KUBE_CONTAINER_RSYNC_PORT} 2> /dev/null | cut -d: -f 2) ; then |   if ! mapped_port=$("${DOCKER[@]}" port "${KUBE_RSYNC_CONTAINER_NAME}" "${KUBE_CONTAINER_RSYNC_PORT}" 2> /dev/null | cut -d: -f 2) ; then | ||||||
|     kube::log::error "Could not get effective rsync port" |     kube::log::error "Could not get effective rsync port" | ||||||
|     return 1 |     return 1 | ||||||
|   fi |   fi | ||||||
| @@ -630,7 +630,7 @@ function kube::build::start_rsyncd_container() { | |||||||
|   if kube::build::rsync_probe 127.0.0.1 "${mapped_port}"; then |   if kube::build::rsync_probe 127.0.0.1 "${mapped_port}"; then | ||||||
|     KUBE_RSYNC_ADDR="127.0.0.1:${mapped_port}" |     KUBE_RSYNC_ADDR="127.0.0.1:${mapped_port}" | ||||||
|     return 0 |     return 0 | ||||||
|   elif kube::build::rsync_probe "${container_ip}" ${KUBE_CONTAINER_RSYNC_PORT}; then |   elif kube::build::rsync_probe "${container_ip}" "${KUBE_CONTAINER_RSYNC_PORT}"; then | ||||||
|     KUBE_RSYNC_ADDR="${container_ip}:${KUBE_CONTAINER_RSYNC_PORT}" |     KUBE_RSYNC_ADDR="${container_ip}:${KUBE_CONTAINER_RSYNC_PORT}" | ||||||
|     return 0 |     return 0 | ||||||
|   fi |   fi | ||||||
|   | |||||||
| @@ -402,7 +402,7 @@ function do-node-upgrade() { | |||||||
|     if [[ "${set_instance_template_rc}" != 0 ]]; then |     if [[ "${set_instance_template_rc}" != 0 ]]; then | ||||||
|       echo "== FAILED to set-instance-template for ${group} to ${template_name} ==" |       echo "== FAILED to set-instance-template for ${group} to ${template_name} ==" | ||||||
|       echo "${set_instance_template_out}" |       echo "${set_instance_template_out}" | ||||||
|       return ${set_instance_template_rc} |       return "${set_instance_template_rc}" | ||||||
|     fi |     fi | ||||||
|     instances=() |     instances=() | ||||||
|     while IFS='' read -r line; do instances+=("$line"); done < <(gcloud compute instance-groups managed list-instances "${group}" \ |     while IFS='' read -r line; do instances+=("$line"); done < <(gcloud compute instance-groups managed list-instances "${group}" \ | ||||||
| @@ -412,7 +412,7 @@ function do-node-upgrade() { | |||||||
|     if [[ "${list_instances_rc}" != 0 ]]; then |     if [[ "${list_instances_rc}" != 0 ]]; then | ||||||
|       echo "== FAILED to list instances in group ${group} ==" |       echo "== FAILED to list instances in group ${group} ==" | ||||||
|       echo "${instances[@]}" |       echo "${instances[@]}" | ||||||
|       return ${list_instances_rc} |       return "${list_instances_rc}" | ||||||
|     fi |     fi | ||||||
|  |  | ||||||
|     process_count_left=${node_upgrade_parallelism} |     process_count_left=${node_upgrade_parallelism} | ||||||
|   | |||||||
| @@ -139,15 +139,9 @@ EOF | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| # Returns the name of an arbitrary Linux webserver pod. |  | ||||||
| function get_linux_webserver_pod_name { |  | ||||||
|   $kubectl get pods -l app=$linux_webserver_pod_label \ |  | ||||||
|     -o jsonpath='{.items[0].metadata.name}' |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # Returns the IP address of an arbitrary Linux webserver pod. | # Returns the IP address of an arbitrary Linux webserver pod. | ||||||
| function get_linux_webserver_pod_ip { | function get_linux_webserver_pod_ip { | ||||||
|   $kubectl get pods -l app=$linux_webserver_pod_label \ |   $kubectl get pods -l app="$linux_webserver_pod_label" \ | ||||||
|     -o jsonpath='{.items[0].status.podIP}' |     -o jsonpath='{.items[0].status.podIP}' | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -194,7 +188,7 @@ EOF | |||||||
|   timeout=$linux_deployment_timeout |   timeout=$linux_deployment_timeout | ||||||
|   while [[ $timeout -gt 0 ]]; do |   while [[ $timeout -gt 0 ]]; do | ||||||
|     echo "Waiting for $linux_command_replicas Linux $linux_command_pod_label pods to become Ready" |     echo "Waiting for $linux_command_replicas Linux $linux_command_pod_label pods to become Ready" | ||||||
|     statuses=$(${kubectl} get pods -l app=$linux_command_pod_label \ |     statuses=$(${kubectl} get pods -l app="$linux_command_pod_label" \ | ||||||
|       -o jsonpath='{.items[*].status.conditions[?(@.type=="Ready")].status}' \ |       -o jsonpath='{.items[*].status.conditions[?(@.type=="Ready")].status}' \ | ||||||
|       | grep "True" | wc -w) |       | grep "True" | wc -w) | ||||||
|     if [[ $statuses -eq $linux_command_replicas ]]; then |     if [[ $statuses -eq $linux_command_replicas ]]; then | ||||||
| @@ -210,7 +204,7 @@ EOF | |||||||
|   else |   else | ||||||
|     echo "ERROR: Not all $linux_command_pod_label pods became Ready" |     echo "ERROR: Not all $linux_command_pod_label pods became Ready" | ||||||
|     echo "kubectl get pods -l app=$linux_command_pod_label" |     echo "kubectl get pods -l app=$linux_command_pod_label" | ||||||
|     ${kubectl} get pods -l app=$linux_command_pod_label |     ${kubectl} get pods -l app="$linux_command_pod_label" | ||||||
|     cleanup_deployments |     cleanup_deployments | ||||||
|     exit 1 |     exit 1 | ||||||
|   fi |   fi | ||||||
| @@ -218,16 +212,10 @@ EOF | |||||||
|  |  | ||||||
| # Returns the name of an arbitrary Linux command pod. | # Returns the name of an arbitrary Linux command pod. | ||||||
| function get_linux_command_pod_name { | function get_linux_command_pod_name { | ||||||
|   $kubectl get pods -l app=$linux_command_pod_label \ |   $kubectl get pods -l app="$linux_command_pod_label" \ | ||||||
|     -o jsonpath='{.items[0].metadata.name}' |     -o jsonpath='{.items[0].metadata.name}' | ||||||
| } | } | ||||||
|  |  | ||||||
| # Returns the IP address of an arbitrary Linux command pod. |  | ||||||
| function get_linux_command_pod_ip { |  | ||||||
|   $kubectl get pods -l app=$linux_command_pod_label \ |  | ||||||
|     -o jsonpath='{.items[0].status.podIP}' |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # Installs test executables (ping, curl) in the Linux command pod. | # Installs test executables (ping, curl) in the Linux command pod. | ||||||
| # NOTE: this assumes that there is only one Linux "command pod". | # NOTE: this assumes that there is only one Linux "command pod". | ||||||
| # TODO(pjh): fix this. | # TODO(pjh): fix this. | ||||||
| @@ -318,18 +306,13 @@ EOF | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| function get_windows_webserver_pod_name { |  | ||||||
|   $kubectl get pods -l app=$windows_webserver_pod_label \ |  | ||||||
|     -o jsonpath='{.items[0].metadata.name}' |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function get_windows_webserver_pod_ip { | function get_windows_webserver_pod_ip { | ||||||
|   $kubectl get pods -l app=$windows_webserver_pod_label \ |   ${kubectl} get pods -l app="$windows_webserver_pod_label" \ | ||||||
|     -o jsonpath='{.items[0].status.podIP}' |     -o jsonpath='{.items[0].status.podIP}' | ||||||
| } | } | ||||||
|  |  | ||||||
| function undeploy_windows_webserver_pod { | function undeploy_windows_webserver_pod { | ||||||
|   ${kubectl} delete deployment $windows_webserver_deployment |   ${kubectl} delete deployment "$windows_webserver_deployment" | ||||||
| } | } | ||||||
|  |  | ||||||
| windows_command_deployment=windows-powershell | windows_command_deployment=windows-powershell | ||||||
| @@ -399,17 +382,12 @@ EOF | |||||||
| } | } | ||||||
|  |  | ||||||
| function get_windows_command_pod_name { | function get_windows_command_pod_name { | ||||||
|   $kubectl get pods -l app=$windows_command_pod_label \ |   $kubectl get pods -l app="$windows_command_pod_label" \ | ||||||
|     -o jsonpath='{.items[0].metadata.name}' |     -o jsonpath='{.items[0].metadata.name}' | ||||||
| } | } | ||||||
|  |  | ||||||
| function get_windows_command_pod_ip { |  | ||||||
|   $kubectl get pods -l app=$windows_command_pod_label \ |  | ||||||
|     -o jsonpath='{.items[0].status.podIP}' |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function undeploy_windows_command_pod { | function undeploy_windows_command_pod { | ||||||
|   ${kubectl} delete deployment $windows_command_deployment |   ${kubectl} delete deployment "$windows_command_deployment" | ||||||
| } | } | ||||||
|  |  | ||||||
| function test_linux_node_to_linux_pod { | function test_linux_node_to_linux_pod { | ||||||
| @@ -459,22 +437,6 @@ function test_linux_pod_to_windows_pod { | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| function test_linux_pod_to_internet { |  | ||||||
|   echo "TEST: ${FUNCNAME[0]}" |  | ||||||
|   local linux_command_pod |  | ||||||
|   linux_command_pod="$(get_linux_command_pod_name)" |  | ||||||
|   # A stable (hopefully) HTTP server provided by Cloudflare. |  | ||||||
|   local internet_ip="1.1.1.1" |  | ||||||
|  |  | ||||||
|   if ! $kubectl exec "$linux_command_pod" -- curl -s -m 20 \ |  | ||||||
|       "http://$internet_ip" > $output_file; then |  | ||||||
|     cleanup_deployments |  | ||||||
|     echo "Failing output: $(cat $output_file)" |  | ||||||
|     echo "FAILED: ${FUNCNAME[0]}" |  | ||||||
|     exit 1 |  | ||||||
|   fi |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function test_linux_pod_to_k8s_service { | function test_linux_pod_to_k8s_service { | ||||||
|   echo "TEST: ${FUNCNAME[0]}" |   echo "TEST: ${FUNCNAME[0]}" | ||||||
|   local linux_command_pod |   local linux_command_pod | ||||||
|   | |||||||
| @@ -269,7 +269,7 @@ runTests() { | |||||||
|      | tee ${junit_filename_prefix:+"${junit_filename_prefix}.stdout"} \ |      | tee ${junit_filename_prefix:+"${junit_filename_prefix}.stdout"} \ | ||||||
|      | grep --binary-files=text "${go_test_grep_pattern}" && rc=$? || rc=$? |      | grep --binary-files=text "${go_test_grep_pattern}" && rc=$? || rc=$? | ||||||
|     produceJUnitXMLReport "${junit_filename_prefix}" |     produceJUnitXMLReport "${junit_filename_prefix}" | ||||||
|     return ${rc} |     return "${rc}" | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
|   kube::log::status "Running tests with code coverage ${KUBE_RACE:+"and with ${KUBE_RACE}"}" |   kube::log::status "Running tests with code coverage ${KUBE_RACE:+"and with ${KUBE_RACE}"}" | ||||||
| @@ -340,7 +340,7 @@ runTests() { | |||||||
|   go tool cover -html="${COMBINED_COVER_PROFILE}" -o="${coverage_html_file}" |   go tool cover -html="${COMBINED_COVER_PROFILE}" -o="${coverage_html_file}" | ||||||
|   kube::log::status "Combined coverage report: ${coverage_html_file}" |   kube::log::status "Combined coverage report: ${coverage_html_file}" | ||||||
|  |  | ||||||
|   return ${test_result} |   return "${test_result}" | ||||||
| } | } | ||||||
|  |  | ||||||
| reportCoverageToCoveralls() { | reportCoverageToCoveralls() { | ||||||
|   | |||||||
| @@ -113,7 +113,7 @@ function is-explicitly-chosen { | |||||||
|   index=0 |   index=0 | ||||||
|   for e in "${TARGET_LIST[@]}"; do |   for e in "${TARGET_LIST[@]}"; do | ||||||
|     if [[ "${e}" == "${name}" ]]; then |     if [[ "${e}" == "${name}" ]]; then | ||||||
|       TARGET_LIST[${index}]="" |       TARGET_LIST[index]="" | ||||||
|       return |       return | ||||||
|     fi |     fi | ||||||
|     index=$((index + 1)) |     index=$((index + 1)) | ||||||
|   | |||||||
| @@ -30,8 +30,8 @@ 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.8.0" | SHELLCHECK_VERSION="0.9.0" | ||||||
| SHELLCHECK_IMAGE="docker.io/koalaman/shellcheck-alpine:v0.8.0@sha256:f42fde76d2d14a645a848826e54a4d650150e151d9c81057c898da89a82c8a56" | SHELLCHECK_IMAGE="docker.io/koalaman/shellcheck-alpine:v0.9.0@sha256:e19ed93c22423970d56568e171b4512c9244fc75dd9114045016b4a0073ac4b7" | ||||||
|  |  | ||||||
| # disabled lints | # disabled lints | ||||||
| disabled=( | disabled=( | ||||||
|   | |||||||
| @@ -328,6 +328,17 @@ setup() { | |||||||
|   kube::log::status "Setup complete" |   kube::log::status "Setup complete" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # Generate a random namespace name, based on the current time (to make | ||||||
|  | # debugging slightly easier) and a random number. Don't use `date +%N` | ||||||
|  | # because that doesn't work on OSX. | ||||||
|  | create_and_use_new_namespace() { | ||||||
|  |   local ns_name | ||||||
|  |   ns_name="namespace-$(date +%s)-${RANDOM}" | ||||||
|  |   kube::log::status "Creating namespace ${ns_name}" | ||||||
|  |   kubectl create namespace "${ns_name}" | ||||||
|  |   kubectl config set-context "${CONTEXT}" --namespace="${ns_name}" | ||||||
|  | } | ||||||
|  |  | ||||||
| # Runs all kubectl tests. | # Runs all kubectl tests. | ||||||
| # Requires an env var SUPPORTED_RESOURCES which is a comma separated list of | # Requires an env var SUPPORTED_RESOURCES which is a comma separated list of | ||||||
| # resources for which tests should be run. | # resources for which tests should be run. | ||||||
| @@ -341,17 +352,6 @@ runTests() { | |||||||
|   kube::log::status "Checking kubectl version" |   kube::log::status "Checking kubectl version" | ||||||
|   kubectl version |   kubectl version | ||||||
|  |  | ||||||
|   # Generate a random namespace name, based on the current time (to make |  | ||||||
|   # debugging slightly easier) and a random number. Don't use `date +%N` |  | ||||||
|   # because that doesn't work on OSX. |  | ||||||
|   create_and_use_new_namespace() { |  | ||||||
|     local ns_name |  | ||||||
|     ns_name="namespace-$(date +%s)-${RANDOM}" |  | ||||||
|     kube::log::status "Creating namespace ${ns_name}" |  | ||||||
|     kubectl create namespace "${ns_name}" |  | ||||||
|     kubectl config set-context "${CONTEXT}" --namespace="${ns_name}" |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   kube_flags=( '-s' "https://127.0.0.1:${SECURE_API_PORT}" '--insecure-skip-tls-verify' ) |   kube_flags=( '-s' "https://127.0.0.1:${SECURE_API_PORT}" '--insecure-skip-tls-verify' ) | ||||||
|  |  | ||||||
|   kube_flags_without_token=( "${kube_flags[@]}" ) |   kube_flags_without_token=( "${kube_flags[@]}" ) | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ set -o nounset | |||||||
| set -o pipefail | set -o pipefail | ||||||
|  |  | ||||||
| # Shutdown the tests gracefully then save the results | # Shutdown the tests gracefully then save the results | ||||||
|  | # shellcheck disable=SC2317 # false positive | ||||||
| shutdown () { | shutdown () { | ||||||
|     E2E_SUITE_PID=$(pgrep e2e.test) |     E2E_SUITE_PID=$(pgrep e2e.test) | ||||||
|     echo "sending TERM to ${E2E_SUITE_PID}" |     echo "sending TERM to ${E2E_SUITE_PID}" | ||||||
| @@ -41,7 +42,7 @@ saveResults() { | |||||||
| if [[ -n ${E2E_USE_GO_RUNNER:-} ]]; then | if [[ -n ${E2E_USE_GO_RUNNER:-} ]]; then | ||||||
|     set -x |     set -x | ||||||
|     /gorunner && ret=0 || ret=$? |     /gorunner && ret=0 || ret=$? | ||||||
|     exit ${ret} |     exit "${ret}" | ||||||
| fi | fi | ||||||
|  |  | ||||||
| # We get the TERM from kubernetes and handle it gracefully | # We get the TERM from kubernetes and handle it gracefully | ||||||
| @@ -74,4 +75,4 @@ set -x | |||||||
| /usr/local/bin/ginkgo "${ginkgo_args[@]}" /usr/local/bin/e2e.test -- --disable-log-dump --repo-root=/kubernetes --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --kubeconfig="${KUBECONFIG}" -v="${E2E_VERBOSITY}" > >(tee "${RESULTS_DIR}"/e2e.log) && ret=0 || ret=$? | /usr/local/bin/ginkgo "${ginkgo_args[@]}" /usr/local/bin/e2e.test -- --disable-log-dump --repo-root=/kubernetes --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --kubeconfig="${KUBECONFIG}" -v="${E2E_VERBOSITY}" > >(tee "${RESULTS_DIR}"/e2e.log) && ret=0 || ret=$? | ||||||
| set +x | set +x | ||||||
| saveResults | saveResults | ||||||
| exit ${ret} | exit "${ret}" | ||||||
|   | |||||||
| @@ -39,6 +39,6 @@ fi | |||||||
|  |  | ||||||
| # Running locally. | # Running locally. | ||||||
| for ((i=0; i < ${#ARGS[@]}; i++)); do | for ((i=0; i < ${#ARGS[@]}; i++)); do | ||||||
|   ARGS[$i]="$(echo "${ARGS[$i]}" | sed -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' )" |   ARGS[i]="$(echo "${ARGS[$i]}" | sed -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' )" | ||||||
| done | done | ||||||
| "${KUBE_ROOT}/hack/ginkgo-e2e.sh" "--e2e-verify-service-account=false" "--dump-logs-on-failure=false" "${ARGS[@]}" | "${KUBE_ROOT}/hack/ginkgo-e2e.sh" "--e2e-verify-service-account=false" "--dump-logs-on-failure=false" "${ARGS[@]}" | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								third_party/forked/shell2junit/sh2ju.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								third_party/forked/shell2junit/sh2ju.sh
									
									
									
									
										vendored
									
									
								
							| @@ -122,13 +122,13 @@ function juLog() { | |||||||
|   echo "+++ exit code: ${evErr}"        | tee -a ${outf} |   echo "+++ exit code: ${evErr}"        | tee -a ${outf} | ||||||
|  |  | ||||||
|   # set the appropriate error, based in the exit code and the regex |   # set the appropriate error, based in the exit code and the regex | ||||||
|   [[ ${evErr} != 0 ]] && err=1 || err=0 |   [[ ${evErr} -ne 0 ]] && err=1 || err=0 | ||||||
|   out="$(${SED} -e 's/^\([^+]\)/| \1/g' "$outf")" |   out="$(${SED} -e 's/^\([^+]\)/| \1/g' "$outf")" | ||||||
|   if [ ${err} = 0 ] && [ -n "${ereg:-}" ]; then |   if [ "${err}" -eq 0 ] && [ -n "${ereg:-}" ]; then | ||||||
|       H=$(echo "${out}" | grep -E ${icase} "${ereg}") |       H=$(echo "${out}" | grep -E ${icase} "${ereg}") | ||||||
|       [[ -n "${H}" ]] && err=1 |       [[ -n "${H}" ]] && err=1 | ||||||
|   fi |   fi | ||||||
|   [[ ${err} != 0 ]] && echo "+++ error: ${err}"         | tee -a ${outf} |   [[ ${err} -ne 0 ]] && echo "+++ error: ${err}"         | tee -a ${outf} | ||||||
|   rm -f ${outf} |   rm -f ${outf} | ||||||
|  |  | ||||||
|   errMsg=$(cat ${errf}) |   errMsg=$(cat ${errf}) | ||||||
| @@ -142,7 +142,7 @@ function juLog() { | |||||||
|   # write the junit xml report |   # write the junit xml report | ||||||
|   ## failure tag |   ## failure tag | ||||||
|   local failure="" |   local failure="" | ||||||
|   if [[ ${err} != 0 ]]; then |   if [[ ${err} -ne 0 ]]; then | ||||||
|       local failureMsg |       local failureMsg | ||||||
|       if [ -n "${failureRe}" ]; then |       if [ -n "${failureRe}" ]; then | ||||||
|           failureMsg="$(echo "${errMsg}" | grep -e "${failureRe}" | ${SED} -e "s;${failureRe};;")" |           failureMsg="$(echo "${errMsg}" | grep -e "${failureRe}" | ${SED} -e "s;${failureRe};;")" | ||||||
| @@ -195,5 +195,5 @@ EOF | |||||||
| EOF | EOF | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
|   return ${err} |   return "${err}" | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tim Hockin
					Tim Hockin