-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbackend-ref.yaml
44 lines (44 loc) · 1.17 KB
/
backend-ref.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
apiVersion: kubevious.io/v1alpha1
kind: ClusterRule
metadata:
name: http-route-backend-ref
spec:
summary: |
Validate HTTPRoute to Backend reference.
target: |
Api('gateway.networking.k8s.io')
.Kind('HTTPRoute')
categories:
- k8s
- gateway-api
- http-route
- backend
- reference
rule: |
for(const rule of config.spec?.rules ?? [])
{
for(const backendRef of rule.backendRefs ?? [])
{
if (!backendRef.name)
{
error('backendRef.name is required');
}
else
{
const group = backendRef.group ?? "";
const kind = backendRef.kind ?? "Service";
const backendItem = Api(group)
.Kind(kind)
.name(backendRef.name)
.namespace(backendRef.namespace)
.single()
if (!backendItem)
{
if (!helpers.gateway.isInternalService(group, kind, backendRef.name))
{
error(`Could not find backend reference: ${group} :: ${kind} :: ${backendRef.name}`);
}
}
}
}
}