Fix of review comments. Will squash later.

Including:
- Remove external usage of resource name vars
- Add commments about why we export field helpers
This commit is contained in:
Xiangyang Chu 2019-07-18 09:12:28 +08:00
parent 313044abd7
commit 4ef227c682
3 changed files with 8 additions and 9 deletions

View File

@ -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}}" ''

View File

@ -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"

View File

@ -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