-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent multiple items per yaml item (#2691)
* Don't allow more than one filter/predicate per yaml/json item Signed-off-by: Mustafa Abdelrahman <[email protected]>
- Loading branch information
1 parent
b515758
commit f6f38c4
Showing
14 changed files
with
265 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
cmd/webhook/admission/testdata/rg/rg-with-multiple-filters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"request": { | ||
"uid": "req-uid", | ||
"name": "req1", | ||
"operation": "create", | ||
"kind": { | ||
"group": "zalando", | ||
"version": "v1", | ||
"kind": "RouteGroup" | ||
}, | ||
"namespace": "n1", | ||
"object": { | ||
"metadata": { | ||
"name": "rg1", | ||
"namespace": "n1" | ||
}, | ||
"spec": { | ||
"backends": [ | ||
{ | ||
"name": "backend", | ||
"type": "shunt" | ||
} | ||
], | ||
"defaultBackends": [ | ||
{ | ||
"backendName": "backend" | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"backends": [ | ||
{ | ||
"backendName": "backend" | ||
} | ||
], | ||
"filters": [ | ||
"status(201) -> inlineContent(\"hi\")", | ||
" " | ||
], | ||
"path": "/", | ||
"predicates": [ | ||
"Method(\"GET\")" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
cmd/webhook/admission/testdata/rg/rg-with-multiple-predicates.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"request": { | ||
"uid": "req-uid", | ||
"name": "req1", | ||
"operation": "create", | ||
"kind": { | ||
"group": "zalando", | ||
"version": "v1", | ||
"kind": "RouteGroup" | ||
}, | ||
"namespace": "n1", | ||
"object": { | ||
"metadata": { | ||
"name": "rg1", | ||
"namespace": "n1" | ||
}, | ||
"spec": { | ||
"backends": [ | ||
{ | ||
"name": "backend", | ||
"type": "shunt" | ||
} | ||
], | ||
"defaultBackends": [ | ||
{ | ||
"backendName": "backend" | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"backends": [ | ||
{ | ||
"backendName": "backend" | ||
} | ||
], | ||
"filters": [ | ||
"status(201)" | ||
], | ||
"path": "/", | ||
"predicates": [ | ||
"Method(\"GET\") && Path(\"/\")", | ||
" " | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
dataclients/kubernetes/definitions/testdata/errorwrapdata/errors.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
route group without name | ||
error in route group default/rg1: route group without backend | ||
single predicate expected at "Path("/foo") && Method("GET")" | ||
single predicate expected at "" | ||
single filter expected at "inlineContent("/foo") -> status(200)" | ||
single filter expected at " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
dataclients/kubernetes/definitions/testdata/validation/route-with-empty-filter.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
test-route-group | ||
invalid filter | ||
single filter expected |
3 changes: 1 addition & 2 deletions
3
dataclients/kubernetes/definitions/testdata/validation/route-with-empty-predicate.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
test-route-group | ||
invalid predicate | ||
single predicate expected |
1 change: 1 addition & 0 deletions
1
...ients/kubernetes/definitions/testdata/validation/route-with-multiple-filters-one-item.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
single filter expected |
25 changes: 25 additions & 0 deletions
25
...ents/kubernetes/definitions/testdata/validation/route-with-multiple-filters-one-item.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: zalando.org/v1 | ||
kind: RouteGroup | ||
metadata: | ||
name: test-route-group | ||
spec: | ||
hosts: | ||
- example.org | ||
backends: | ||
- name: app | ||
type: service | ||
serviceName: app-svc | ||
servicePort: 80 | ||
defaultBackends: | ||
- backendName: app | ||
routes: | ||
- path: / | ||
methods: | ||
- GET | ||
- HEAD | ||
predicates: | ||
- Foo("X-Bar", "42") | ||
filters: | ||
- foo(42) -> bar(24) | ||
backends: | ||
- backendName: app |
1 change: 1 addition & 0 deletions
1
...ts/kubernetes/definitions/testdata/validation/route-with-multiple-predicates-one-item.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
single predicate expected |
26 changes: 26 additions & 0 deletions
26
...s/kubernetes/definitions/testdata/validation/route-with-multiple-predicates-one-item.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: zalando.org/v1 | ||
kind: RouteGroup | ||
metadata: | ||
name: test-route-group | ||
spec: | ||
hosts: | ||
- example.org | ||
backends: | ||
- name: app | ||
type: service | ||
serviceName: app-svc | ||
servicePort: 80 | ||
defaultBackends: | ||
- backendName: app | ||
routes: | ||
- path: / | ||
methods: | ||
- GET | ||
- HEAD | ||
predicates: | ||
- Foo("X-Bar", "42") && Bar("X-Foo", "24") | ||
filters: | ||
- foo(42) | ||
- bar(24) | ||
backends: | ||
- backendName: app |