@@ -51,24 +51,50 @@ 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
+ sleep 1
65
+
66
+ kubectl delete --kubeconfig " ${KUBECONFIG} " --recursive -f examples/v1alpha1 || res=$?
67
+
68
+
69
+ # Uninstall CRDs
70
+ kubectl delete --kubeconfig " ${KUBECONFIG} " -f config/crd/v1alpha1 || res=$?
68
71
69
- # None of these examples should be successfully configured
70
- kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2
71
72
73
+ # #### Test v1alpha2 CRD apply and that invalid examples are invalid.
74
+ # Install CRDs
75
+ kubectl apply --kubeconfig " ${KUBECONFIG} " -f config/crd/v1alpha2 || res=$?
76
+
77
+ # Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
78
+ sleep 8
79
+
80
+ # Install all example gateway-api resources.
81
+ kubectl apply --kubeconfig " ${KUBECONFIG} " --recursive -f examples/v1alpha2 || res=$?
82
+
83
+ # Install invalid gateway-api resources.
84
+ # None of these examples should be successfully configured
85
+ # This is very hacky, sorry.
86
+ # Firstly, apply the examples, remembering that errors are on stdout
87
+ kubectl apply --kubeconfig " ${KUBECONFIG} " --recursive -f hack/invalid-examples 2>&1 | \
88
+ # First, we grep out the expected responses.
89
+ # After this, if everything is as expoected, the output should be empty.
90
+ grep -v ' is invalid' | \
91
+ grep -v ' missing required field' | \
92
+ # Then, we grep for anything else.
93
+ # If anything else is found, this will return 0
94
+ # which is *not* what we want.
95
+ grep -e ' .' && \
96
+ res=2 || \
97
+ echo Examples failed as expected
72
98
# Clean up and exit
73
99
cleanup || res=$?
74
100
exit $res
0 commit comments