Skip to content

Commit

Permalink
experiment: add message to allowed admission response
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
  • Loading branch information
AlexanderYastrebov committed Jan 24, 2024
1 parent d3f0322 commit 9281783
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/webhook/admission/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ type admissionRequest struct {
Object json.RawMessage `json:"object,omitempty"`
}

// See https://pkg.go.dev/k8s.io/api/admission/v1#AdmissionResponse
type admissionResponse struct {
UID string `json:"uid"`
Allowed bool `json:"allowed"`
Result *status `json:"status,omitempty"`
UID string `json:"uid"`
Allowed bool `json:"allowed"`
Result *status `json:"status,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}

type status struct {
Expand Down
11 changes: 11 additions & 0 deletions cmd/webhook/admission/routegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ func (rga *RouteGroupAdmitter) admit(req *admissionRequest) (*admissionResponse,
}, nil
}

if rgItem.Metadata.Name == "admission-test" {
return &admissionResponse{
UID: req.UID,
Allowed: true,
Warnings: []string{
"This is a test warning1, see https://opensource.zalando.com/skipper/kubernetes/routegroups/",
`Argument "foo" is not allowed for filter fooBarBazQux due to whatever, see https://opensource.zalando.com/skipper/kubernetes/routegroups/ for details.`,
},
}, nil
}

return &admissionResponse{
UID: req.UID,
Allowed: true,
Expand Down

0 comments on commit 9281783

Please sign in to comment.