@@ -51,24 +51,44 @@ res=0
51
51
KIND_CREATE_ATTEMPTED=true
52
52
kind create cluster --name " ${CLUSTER_NAME} " --kubeconfig " ${KUBECONFIG} " || res=$?
53
53
54
- for VERSION in v1alpha1 v1alpha2
55
- do
56
- # Install CRDs
57
- kubectl apply --kubeconfig " ${KUBECONFIG} " -f config/crd/" ${VERSION} " || res=$?
54
+ # #### Test v1alpha1 CRD apply
55
+ # Install CRDs
56
+ kubectl apply --kubeconfig " ${KUBECONFIG} " -f config/crd/v1alpha1 || res=$?
58
57
59
- # Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
60
- sleep 8
58
+ # Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
59
+ sleep 8
61
60
62
- # Install all example gateway-api resources.
63
- kubectl apply --kubeconfig " ${KUBECONFIG} " --recursive -f examples/" ${VERSION} " || res=$?
61
+ # Install all example gateway-api resources.
62
+ kubectl apply --kubeconfig " ${KUBECONFIG} " --recursive -f examples/v1alpha1 || res=$?
64
63
65
- # Uninstall CRDs
66
- kubectl delete --kubeconfig " ${KUBECONFIG} " -f config/crd/" ${VERSION} " || res=$?
67
- done
64
+ # Uninstall CRDs
65
+ kubectl delete --kubeconfig " ${KUBECONFIG} " -f config/crd/v1alpha1 || res=$?
68
66
69
- # None of these examples should be successfully configured
70
- kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2
67
+ # #### Test v1alpha2 CRD apply and that invalid examples are invalid.
68
+ # Install CRDs
69
+ kubectl apply --kubeconfig " ${KUBECONFIG} " -f config/crd/v1alpha2 || res=$?
70
+
71
+ # Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
72
+ sleep 8
71
73
74
+ # Install all example gateway-api resources.
75
+ kubectl apply --kubeconfig " ${KUBECONFIG} " --recursive -f examples/v1alpha2 || res=$?
76
+
77
+ # Install invalid gateway-api resources.
78
+ # None of these examples should be successfully configured
79
+ # This is very hacky, sorry.
80
+ # Firstly, apply the examples, remembering that errors are on stdout
81
+ kubectl apply --kubeconfig " ${KUBECONFIG} " --recursive -f hack/invalid-examples 2>&1 | \
82
+ # First, we grep out the expected responses.
83
+ # After this, if everything is as expected, the output should be empty.
84
+ grep -v ' is invalid' | \
85
+ grep -v ' missing required field' | \
86
+ # Then, we grep for anything else.
87
+ # If anything else is found, this will return 0
88
+ # which is *not* what we want.
89
+ grep -e ' .' && \
90
+ res=2 || \
91
+ echo Examples failed as expected
72
92
# Clean up and exit
73
93
cleanup || res=$?
74
94
exit $res
0 commit comments