diff --git a/test/cmd/apps.sh b/test/cmd/apps.sh index 8b2a585af87..4c6c3c2d9c4 100755 --- a/test/cmd/apps.sh +++ b/test/cmd/apps.sh @@ -640,7 +640,7 @@ run_rs_tests() { # Post-condition: no replica set exists kube::test::get_object_assert rs "{{range.items}}{{${id_field:?}}}:{{end}}" '' - if kube::test::if_supports_resource "${horizontalpodautoscalers:?}" ; then + if kube::test::if_supports_resource "horizontalpodautoscalers" ; then ### Auto scale replica set # Pre-condition: no replica set exists kube::test::get_object_assert rs "{{range.items}}{{${id_field:?}}}:{{end}}" '' diff --git a/test/cmd/legacy-script.sh b/test/cmd/legacy-script.sh index 26cc9fd5889..d11e1aa1e03 100755 --- a/test/cmd/legacy-script.sh +++ b/test/cmd/legacy-script.sh @@ -83,8 +83,6 @@ clusterroles="clusterroles" configmaps="configmaps" csr="csr" deployments="deployments" -export horizontalpodautoscalers="horizontalpodautoscalers" -export metrics="metrics" namespaces="namespaces" nodes="nodes" persistentvolumeclaims="persistentvolumeclaims" @@ -98,10 +96,8 @@ secrets="secrets" serviceaccounts="serviceaccounts" services="services" statefulsets="statefulsets" -export static="static" storageclass="storageclass" subjectaccessreviews="subjectaccessreviews" -export selfsubjectaccessreviews="selfsubjectaccessreviews" customresourcedefinitions="customresourcedefinitions" daemonsets="daemonsets" controllerrevisions="controllerrevisions" @@ -335,7 +331,10 @@ runTests() { [ "$(kubectl get nodes -o go-template='{{ .apiVersion }}' "${kube_flags[@]}")" == "v1" ] fi - id_field=".metadata.name" + # Define helper variables for fields to prevent typos. + # They will be used in some other files under test/cmd, + # Let's export them as https://github.com/koalaman/shellcheck/wiki/SC2034 suggested. + export id_field=".metadata.name" export labels_field=".metadata.labels" export annotations_field=".metadata.annotations" export service_selector_field=".spec.selector" diff --git a/test/cmd/proxy.sh b/test/cmd/proxy.sh index 29eee0b1da1..98e30fbfcfa 100755 --- a/test/cmd/proxy.sh +++ b/test/cmd/proxy.sh @@ -27,10 +27,10 @@ run_kubectl_local_proxy_tests() { start-proxy check-curl-proxy-code /api/kubernetes 404 check-curl-proxy-code /api/v1/namespaces 200 - if kube::test::if_supports_resource "${metrics:?}" ; then + if kube::test::if_supports_resource "metrics" ; then check-curl-proxy-code /metrics 200 fi - if kube::test::if_supports_resource "${static:?}" ; then + if kube::test::if_supports_resource "static" ; then check-curl-proxy-code /static/ 200 fi stop-proxy @@ -45,7 +45,7 @@ run_kubectl_local_proxy_tests() { start-proxy /custom check-curl-proxy-code /custom/api/kubernetes 404 check-curl-proxy-code /custom/api/v1/namespaces 200 - if kube::test::if_supports_resource "${metrics}" ; then + if kube::test::if_supports_resource "metrics" ; then check-curl-proxy-code /custom/metrics 200 fi check-curl-proxy-code /custom/api/v1/namespaces 200