-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
validator
object to give more validation flexibility (#2484)
* Create `validator` object to give more validation flexiability Signed-off-by: Mustafa Abdelrahman <[email protected]> * Change under the hood for now to not break the API Signed-off-by: Mustafa Abdelrahman <[email protected]> * Start with `eskip.ParseFilters` and fix failing tests logs Signed-off-by: Mustafa Abdelrahman <[email protected]> * Join filters issues Signed-off-by: Mustafa Abdelrahman <[email protected]> * Fail after basic validation fails otherwise join errors Signed-off-by: Mustafa Abdelrahman <[email protected]> * Refactor & add more validation webhook tests Signed-off-by: Mustafa Abdelrahman <[email protected]> * Parse `predicates` eskip also Signed-off-by: Mustafa Abdelrahman <[email protected]> * Update failing eskip parsing tests to indicate that it only generate eskip in case of all valid grammer. Signed-off-by: Mustafa Abdelrahman <[email protected]> * Wait for `go1.21` to use `errors.Join` for now use an adhoc wrapper Signed-off-by: Mustafa Abdelrahman <[email protected]> * Use `errorJoin` for wrapping errors and keep `ValidateRouteGroups` naming Signed-off-by: Mustafa Abdelrahman <[email protected]> * Cleanup leftovers & typos Signed-off-by: Mustafa Abdelrahman <[email protected]>
- Loading branch information
1 parent
6ea4968
commit 92e0d11
Showing
18 changed files
with
595 additions
and
271 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
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,13 @@ | ||
{ | ||
"request": { | ||
"uid": "req-uid", | ||
"name": "req1", | ||
"namespace": "n1", | ||
"object": { | ||
"metadata": { | ||
"name": "rg1", | ||
"namespace": "n1" | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
cmd/webhook/admission/testdata/rg-with-invalid-eskip-filters-and-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,48 @@ | ||
{ | ||
"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\")" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
cmd/webhook/admission/testdata/rg-with-invalid-eskip-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,48 @@ | ||
{ | ||
"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\")" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
cmd/webhook/admission/testdata/rg-with-invalid-eskip-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,48 @@ | ||
{ | ||
"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\")" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
cmd/webhook/admission/testdata/rg-with-valid-eskip-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,48 @@ | ||
{ | ||
"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\")" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.