-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validator: prevent multiple filters/predicates per yaml item #2691
Merged
MustafaSaber
merged 5 commits into
cw2023freeze
from
prohibite-multiple-items-per-yaml-item
Oct 25, 2023
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b9e20b
Don't allow more than one filter/predicate per yaml/json item
MustafaSaber 1edc372
Update error messages
MustafaSaber 936b026
move empty filter check into filters validation
MustafaSaber 0adbfd9
update error naming
MustafaSaber 1c98c74
check error first
MustafaSaber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we use this for both no filter and multiple filters I think it should be named like
errSingleFilterExpected