Skip to content

Commit fe4fa89

Browse files
authored
Merge pull request #2262 from gauravkghildiyal/add-cel-validation-to-presubmit
Add CEL validation to presubmit
2 parents 6b9dd5b + 4cacac2 commit fe4fa89

File tree

3 files changed

+16
-67
lines changed

3 files changed

+16
-67
lines changed

hack/cel-validation/gateway_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func TestValidateGateway(t *testing.T) {
452452
},
453453
}
454454
},
455-
wantErrors: []string{"Invalid value: \"1.2.3.4:8080\": spec.addresses[0].value in body must be of type ipv4"},
455+
wantErrors: []string{"Invalid value: \"1.2.3.4:8080\": status.addresses[0].value in body must be of type ipv4"},
456456
},
457457
{
458458
desc: "duplicate ip address or hostname",

hack/run-cel-validation-test.sh

Lines changed: 0 additions & 63 deletions
This file was deleted.

hack/verify-examples-kind.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ cleanup() {
3535
return
3636
fi
3737

38-
rm config/webhook/kustomization.yaml
38+
rm -f config/webhook/kustomization.yaml
3939

4040
if [ "${KIND_CREATE_ATTEMPTED:-}" = true ]; then
4141
kind delete cluster --name "${CLUSTER_NAME}" || true
4242
fi
4343
CLEANED_UP=true
4444
}
4545

46-
trap cleanup INT TERM
46+
trap cleanup INT TERM EXIT
4747

4848
# For exit code
4949
res=0
@@ -53,7 +53,19 @@ res=0
5353

5454
# Create cluster
5555
KIND_CREATE_ATTEMPTED=true
56-
kind create cluster --name "${CLUSTER_NAME}" || res=$?
56+
kind create cluster --name "${CLUSTER_NAME}"
57+
58+
# Verify CEL validations before installing webhook.
59+
for CHANNEL in experimental standard; do
60+
# Install CRDs.
61+
kubectl apply -f "config/crd/${CHANNEL}/gateway*.yaml"
62+
63+
# Run tests.
64+
go test -timeout=120s -count=1 sigs.k8s.io/gateway-api/hack/cel-validation
65+
66+
# Delete CRDs to reset environment.
67+
kubectl delete -f "config/crd/${CHANNEL}/gateway*.yaml"
68+
done
5769

5870
cat <<EOF >config/webhook/kustomization.yaml
5971
resources:

0 commit comments

Comments
 (0)