mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
Fix shellchecks follow the ${var:?}
pattern
This commit is contained in:
parent
b3ca8262be
commit
53c1fcf2c6
@ -103,9 +103,6 @@
|
||||
./test/cmd/request-timeout.sh
|
||||
./test/cmd/run.sh
|
||||
./test/cmd/save-config.sh
|
||||
./test/cmd/storage.sh
|
||||
./test/cmd/template-output.sh
|
||||
./test/cmd/version.sh
|
||||
./test/e2e_node/conformance/run_test.sh
|
||||
./test/e2e_node/environment/setup_host.sh
|
||||
./test/e2e_node/gubernator.sh
|
||||
|
@ -27,19 +27,19 @@ run_persistent_volumes_tests() {
|
||||
|
||||
### Create and delete persistent volume examples
|
||||
# Pre-condition: no persistent volumes currently exist
|
||||
kube::test::get_object_assert pv "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert pv "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
# Command
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/volumes/local-01.yaml "${kube_flags[@]}"
|
||||
kube::test::get_object_assert pv "{{range.items}}{{$id_field}}:{{end}}" 'pv0001:'
|
||||
kubectl delete pv pv0001 "${kube_flags[@]}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/volumes/local-02.yaml "${kube_flags[@]}"
|
||||
kube::test::get_object_assert pv "{{range.items}}{{$id_field}}:{{end}}" 'pv0002:'
|
||||
kubectl delete pv pv0002 "${kube_flags[@]}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/volumes/gce.yaml "${kube_flags[@]}"
|
||||
kube::test::get_object_assert pv "{{range.items}}{{$id_field}}:{{end}}" 'pv0003:'
|
||||
kubectl delete pv pv0003 "${kube_flags[@]}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/volumes/local-01.yaml "${kube_flags[@]:?}"
|
||||
kube::test::get_object_assert pv "{{range.items}}{{${id_field:?}}}:{{end}}" 'pv0001:'
|
||||
kubectl delete pv pv0001 "${kube_flags[@]:?}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/volumes/local-02.yaml "${kube_flags[@]:?}"
|
||||
kube::test::get_object_assert pv "{{range.items}}{{${id_field:?}}}:{{end}}" 'pv0002:'
|
||||
kubectl delete pv pv0002 "${kube_flags[@]:?}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/volumes/gce.yaml "${kube_flags[@]:?}"
|
||||
kube::test::get_object_assert pv "{{range.items}}{{${id_field:?}}}:{{end}}" 'pv0003:'
|
||||
kubectl delete pv pv0003 "${kube_flags[@]:?}"
|
||||
# Post-condition: no PVs
|
||||
kube::test::get_object_assert pv "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert pv "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
|
||||
set +o nounset
|
||||
set +o errexit
|
||||
@ -54,21 +54,21 @@ run_persistent_volume_claims_tests() {
|
||||
|
||||
### Create and delete persistent volume claim examples
|
||||
# Pre-condition: no persistent volume claims currently exist
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
# Command
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/claims/claim-01.yaml "${kube_flags[@]}"
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{$id_field}}:{{end}}" 'myclaim-1:'
|
||||
kubectl delete pvc myclaim-1 "${kube_flags[@]}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/claims/claim-01.yaml "${kube_flags[@]:?}"
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{${id_field:?}}}:{{end}}" 'myclaim-1:'
|
||||
kubectl delete pvc myclaim-1 "${kube_flags[@]:?}"
|
||||
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/claims/claim-02.yaml "${kube_flags[@]}"
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{$id_field}}:{{end}}" 'myclaim-2:'
|
||||
kubectl delete pvc myclaim-2 "${kube_flags[@]}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/claims/claim-02.yaml "${kube_flags[@]:?}"
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{${id_field:?}}}:{{end}}" 'myclaim-2:'
|
||||
kubectl delete pvc myclaim-2 "${kube_flags[@]:?}"
|
||||
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/claims/claim-03.json "${kube_flags[@]}"
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{$id_field}}:{{end}}" 'myclaim-3:'
|
||||
kubectl delete pvc myclaim-3 "${kube_flags[@]}"
|
||||
kubectl create -f test/fixtures/doc-yaml/user-guide/persistent-volumes/claims/claim-03.json "${kube_flags[@]:?}"
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{${id_field:?}}}:{{end}}" 'myclaim-3:'
|
||||
kubectl delete pvc myclaim-3 "${kube_flags[@]:?}"
|
||||
# Post-condition: no PVCs
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert pvc "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
|
||||
set +o nounset
|
||||
set +o errexit
|
||||
@ -82,9 +82,9 @@ run_storage_class_tests() {
|
||||
|
||||
### Create and delete storage class
|
||||
# Pre-condition: no storage classes currently exist
|
||||
kube::test::get_object_assert storageclass "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert storageclass "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
# Command
|
||||
kubectl create -f - "${kube_flags[@]}" << __EOF__
|
||||
kubectl create -f - "${kube_flags[@]:?}" << __EOF__
|
||||
{
|
||||
"kind": "StorageClass",
|
||||
"apiVersion": "storage.k8s.io/v1",
|
||||
@ -98,11 +98,11 @@ run_storage_class_tests() {
|
||||
}
|
||||
}
|
||||
__EOF__
|
||||
kube::test::get_object_assert storageclass "{{range.items}}{{$id_field}}:{{end}}" 'storage-class-name:'
|
||||
kube::test::get_object_assert sc "{{range.items}}{{$id_field}}:{{end}}" 'storage-class-name:'
|
||||
kubectl delete storageclass storage-class-name "${kube_flags[@]}"
|
||||
kube::test::get_object_assert storageclass "{{range.items}}{{${id_field:?}}}:{{end}}" 'storage-class-name:'
|
||||
kube::test::get_object_assert sc "{{range.items}}{{${id_field:?}}}:{{end}}" 'storage-class-name:'
|
||||
kubectl delete storageclass storage-class-name "${kube_flags[@]:?}"
|
||||
# Post-condition: no storage classes
|
||||
kube::test::get_object_assert storageclass "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert storageclass "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
|
||||
set +o nounset
|
||||
set +o errexit
|
||||
|
@ -26,83 +26,83 @@ run_template_output_tests() {
|
||||
### Test global request timeout option
|
||||
# Pre-condition: no POD exists
|
||||
create_and_use_new_namespace
|
||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
# Command
|
||||
# check that create supports --template output
|
||||
kubectl create "${kube_flags[@]}" -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml
|
||||
kubectl create "${kube_flags[@]:?}" -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml
|
||||
# Post-condition: valid-pod POD is created
|
||||
kubectl get "${kube_flags[@]}" pods -o json
|
||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" 'valid-pod:'
|
||||
kubectl get "${kube_flags[@]:?}" pods -o json
|
||||
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" 'valid-pod:'
|
||||
|
||||
# check that patch command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" patch --dry-run pods/valid-pod -p '{"patched":"value3"}' --type=merge --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" patch --dry-run pods/valid-pod -p '{"patched":"value3"}' --type=merge --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that label command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" label --dry-run pods/valid-pod label=value --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" label --dry-run pods/valid-pod label=value --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that annotate command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" annotate --dry-run pods/valid-pod annotation=value --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" annotate --dry-run pods/valid-pod annotation=value --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that apply command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" apply --dry-run -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" apply --dry-run -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that create command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that autoscale command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" autoscale --max=2 -f hack/testdata/scale-deploy-1.yaml --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" autoscale --max=2 -f hack/testdata/scale-deploy-1.yaml --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'scale-1:'
|
||||
|
||||
# check that expose command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" expose -f hack/testdata/redis-slave-replicaset.yaml --save-config --port=80 --target-port=8000 --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" expose -f hack/testdata/redis-slave-replicaset.yaml --save-config --port=80 --target-port=8000 --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'redis-slave:'
|
||||
|
||||
# check that convert command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" convert -f hack/testdata/deployment-revision1.yaml --output-version=apps/v1beta1 --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" convert -f hack/testdata/deployment-revision1.yaml --output-version=apps/v1beta1 --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'nginx:'
|
||||
|
||||
# check that run command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" run --dry-run --template="{{ .metadata.name }}:" pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)')
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" run --dry-run --template="{{ .metadata.name }}:" pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)')
|
||||
kube::test::if_has_string "${output_message}" 'pi:'
|
||||
|
||||
# check that taint command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" taint node 127.0.0.1 dedicated=foo:PreferNoSchedule --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" taint node 127.0.0.1 dedicated=foo:PreferNoSchedule --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" '127.0.0.1:'
|
||||
# untaint node
|
||||
kubectl taint node 127.0.0.1 dedicated-
|
||||
|
||||
# check that "apply set-last-applied" command supports --template output
|
||||
kubectl "${kube_flags[@]}" create -f test/e2e/testing-manifests/statefulset/cassandra/controller.yaml
|
||||
output_message=$(kubectl "${kube_flags[@]}" apply set-last-applied -f test/e2e/testing-manifests/statefulset/cassandra/controller.yaml --dry-run --create-annotation --template="{{ .metadata.name }}:")
|
||||
kubectl "${kube_flags[@]:?}" create -f test/e2e/testing-manifests/statefulset/cassandra/controller.yaml
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" apply set-last-applied -f test/e2e/testing-manifests/statefulset/cassandra/controller.yaml --dry-run --create-annotation --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'cassandra:'
|
||||
|
||||
# check that "auth reconcile" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" auth reconcile --dry-run -f test/fixtures/pkg/kubectl/cmd/auth/rbac-resource-plus.yaml --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" auth reconcile --dry-run -f test/fixtures/pkg/kubectl/cmd/auth/rbac-resource-plus.yaml --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'testing-CR:testing-CRB:testing-RB:testing-R:'
|
||||
|
||||
# check that "create clusterrole" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create clusterrole --template="{{ .metadata.name }}:" --verb get myclusterrole --non-resource-url /logs/ --resource pods)
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create clusterrole --template="{{ .metadata.name }}:" --verb get myclusterrole --non-resource-url /logs/ --resource pods)
|
||||
kube::test::if_has_string "${output_message}" 'myclusterrole:'
|
||||
|
||||
# check that "create clusterrolebinding" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create clusterrolebinding foo --clusterrole=myclusterrole --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create clusterrolebinding foo --clusterrole=myclusterrole --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create configmap" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create configmap cm --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create configmap cm --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'cm:'
|
||||
|
||||
# check that "create deployment" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create deployment deploy --image=nginx --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create deployment deploy --image=nginx --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'deploy:'
|
||||
|
||||
# check that "create job" command supports --template output
|
||||
kubectl create "${kube_flags[@]}" -f - <<EOF
|
||||
kubectl create "${kube_flags[@]:?}" -f - <<EOF
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
@ -122,128 +122,128 @@ spec:
|
||||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
|
||||
restartPolicy: OnFailure
|
||||
EOF
|
||||
output_message=$(kubectl "${kube_flags[@]}" create job foo --from=cronjob/pi --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create job foo --from=cronjob/pi --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create namespace" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create ns bar --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create ns bar --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'bar:'
|
||||
|
||||
# check that "create namespace" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create rolebinding foo --clusterrole=myclusterrole --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create rolebinding foo --clusterrole=myclusterrole --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create role" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create role --dry-run --template="{{ .metadata.name }}:" --verb get myrole --resource pods)
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create role --dry-run --template="{{ .metadata.name }}:" --verb get myrole --resource pods)
|
||||
kube::test::if_has_string "${output_message}" 'myrole:'
|
||||
|
||||
# check that "create quota" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create quota foo --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create quota foo --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create priorityclass" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create priorityclass foo --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create priorityclass foo --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create poddisruptionbudget" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create poddisruptionbudget foo --dry-run --selector=foo --min-available=1 --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create poddisruptionbudget foo --dry-run --selector=foo --min-available=1 --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create serviceaccount" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create serviceaccount foo --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create serviceaccount foo --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "set env" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" set env pod/valid-pod --dry-run A=B --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" set env pod/valid-pod --dry-run A=B --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that "set image" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" set image pod/valid-pod --dry-run kubernetes-serve-hostname=nginx --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" set image pod/valid-pod --dry-run kubernetes-serve-hostname=nginx --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that "set resources" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" set resources pod/valid-pod --limits=memory=256Mi --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" set resources pod/valid-pod --limits=memory=256Mi --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that "set selector" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" set selector -f hack/testdata/kubernetes-service.yaml A=B --local --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" set selector -f hack/testdata/kubernetes-service.yaml A=B --local --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'kubernetes:'
|
||||
|
||||
# check that "set serviceaccount" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" set serviceaccount pod/valid-pod deployer --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" set serviceaccount pod/valid-pod deployer --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'valid-pod:'
|
||||
|
||||
# check that "set subject" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" set subject clusterrolebinding/foo --user=foo --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" set subject clusterrolebinding/foo --user=foo --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create secret docker-registry" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create secret docker-registry foo --docker-username user --docker-password pass --docker-email foo@bar.baz --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create secret docker-registry foo --docker-username user --docker-password pass --docker-email foo@bar.baz --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create secret generic" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create secret generic foo --from-literal=key1=value1 --dry-run --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create secret generic foo --from-literal=key1=value1 --dry-run --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create secret tls" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create secret tls --dry-run foo --key=hack/testdata/tls.key --cert=hack/testdata/tls.crt --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create secret tls --dry-run foo --key=hack/testdata/tls.key --cert=hack/testdata/tls.crt --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create service clusterip" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create service clusterip foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create service clusterip foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create service externalname" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create service externalname foo --dry-run --external-name=bar --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create service externalname foo --dry-run --external-name=bar --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create service loadbalancer" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create service loadbalancer foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create service loadbalancer foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "create service nodeport" command supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" create service nodeport foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create service nodeport foo --dry-run --tcp=8080 --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'foo:'
|
||||
|
||||
# check that "config view" ouputs "yaml" as its default output format
|
||||
output_message=$(kubectl "${kube_flags[@]}" config view)
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" config view)
|
||||
kube::test::if_has_string "${output_message}" 'kind: Config'
|
||||
|
||||
# check that "rollout pause" supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" rollout pause deploy/deploy --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" rollout pause deploy/deploy --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'deploy:'
|
||||
|
||||
# check that "rollout history" supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" rollout history deploy/deploy --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" rollout history deploy/deploy --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'deploy:'
|
||||
|
||||
# check that "rollout resume" supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" rollout resume deploy/deploy --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" rollout resume deploy/deploy --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'deploy:'
|
||||
|
||||
# check that "rollout undo" supports --template output
|
||||
output_message=$(kubectl "${kube_flags[@]}" rollout undo deploy/deploy --to-revision=1 --template="{{ .metadata.name }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" rollout undo deploy/deploy --to-revision=1 --template="{{ .metadata.name }}:")
|
||||
kube::test::if_has_string "${output_message}" 'deploy:'
|
||||
|
||||
# check that "config view" command supports --template output
|
||||
# and that commands that set a default output (yaml in this case),
|
||||
# default to "go-template" as their output format when a --template
|
||||
# value is provided, but no explicit --output format is given.
|
||||
output_message=$(kubectl "${kube_flags[@]}" config view --template="{{ .kind }}:")
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" config view --template="{{ .kind }}:")
|
||||
kube::test::if_has_string "${output_message}" 'Config'
|
||||
|
||||
# check that running a command with both a --template flag and a
|
||||
# non-template --output prefers the non-template output value
|
||||
output_message=$(kubectl "${kube_flags[@]}" create configmap cm --dry-run --template="{{ .metadata.name }}:" --output yaml)
|
||||
output_message=$(kubectl "${kube_flags[@]:?}" create configmap cm --dry-run --template="{{ .metadata.name }}:" --output yaml)
|
||||
kube::test::if_has_string "${output_message}" 'kind: ConfigMap'
|
||||
|
||||
# cleanup
|
||||
kubectl delete cronjob pi "${kube_flags[@]}"
|
||||
kubectl delete pods --all "${kube_flags[@]}"
|
||||
kubectl delete rc cassandra "${kube_flags[@]}"
|
||||
kubectl delete clusterrole myclusterrole "${kube_flags[@]}"
|
||||
kubectl delete clusterrolebinding foo "${kube_flags[@]}"
|
||||
kubectl delete deployment deploy "${kube_flags[@]}"
|
||||
kubectl delete cronjob pi "${kube_flags[@]:?}"
|
||||
kubectl delete pods --all "${kube_flags[@]:?}"
|
||||
kubectl delete rc cassandra "${kube_flags[@]:?}"
|
||||
kubectl delete clusterrole myclusterrole "${kube_flags[@]:?}"
|
||||
kubectl delete clusterrolebinding foo "${kube_flags[@]:?}"
|
||||
kubectl delete deployment deploy "${kube_flags[@]:?}"
|
||||
|
||||
set +o nounset
|
||||
set +o errexit
|
||||
|
@ -28,7 +28,7 @@ run_kubectl_version_tests() {
|
||||
kube::log::status "Testing kubectl version"
|
||||
TEMP="${KUBE_TEMP}"
|
||||
|
||||
kubectl get "${kube_flags[@]}" --raw /version
|
||||
kubectl get "${kube_flags[@]:?}" --raw /version
|
||||
|
||||
# create version files, one for the client, one for the server.
|
||||
# these are the files we will use to ensure that the remainder output is correct
|
||||
|
Loading…
Reference in New Issue
Block a user