mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rebase: update sigs.k8s.io/controller-runtime to current version
There is no release for sigs.k8s.io/controller-runtime that supports Kubernetes v1.27. The main branch has all the required modifications, so we can use that for the time being. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
2551a0b05f
commit
b1a4590967
23
vendor/sigs.k8s.io/controller-runtime/pkg/webhook/admission/response.go
generated
vendored
23
vendor/sigs.k8s.io/controller-runtime/pkg/webhook/admission/response.go
generated
vendored
@ -26,21 +26,21 @@ import (
|
||||
|
||||
// Allowed constructs a response indicating that the given operation
|
||||
// is allowed (without any patches).
|
||||
func Allowed(reason string) Response {
|
||||
return ValidationResponse(true, reason)
|
||||
func Allowed(message string) Response {
|
||||
return ValidationResponse(true, message)
|
||||
}
|
||||
|
||||
// Denied constructs a response indicating that the given operation
|
||||
// is not allowed.
|
||||
func Denied(reason string) Response {
|
||||
return ValidationResponse(false, reason)
|
||||
func Denied(message string) Response {
|
||||
return ValidationResponse(false, message)
|
||||
}
|
||||
|
||||
// Patched constructs a response indicating that the given operation is
|
||||
// allowed, and that the target object should be modified by the given
|
||||
// JSONPatch operations.
|
||||
func Patched(reason string, patches ...jsonpatch.JsonPatchOperation) Response {
|
||||
resp := Allowed(reason)
|
||||
func Patched(message string, patches ...jsonpatch.JsonPatchOperation) Response {
|
||||
resp := Allowed(message)
|
||||
resp.Patches = patches
|
||||
|
||||
return resp
|
||||
@ -60,21 +60,24 @@ func Errored(code int32, err error) Response {
|
||||
}
|
||||
|
||||
// ValidationResponse returns a response for admitting a request.
|
||||
func ValidationResponse(allowed bool, reason string) Response {
|
||||
func ValidationResponse(allowed bool, message string) Response {
|
||||
code := http.StatusForbidden
|
||||
reason := metav1.StatusReasonForbidden
|
||||
if allowed {
|
||||
code = http.StatusOK
|
||||
reason = ""
|
||||
}
|
||||
resp := Response{
|
||||
AdmissionResponse: admissionv1.AdmissionResponse{
|
||||
Allowed: allowed,
|
||||
Result: &metav1.Status{
|
||||
Code: int32(code),
|
||||
Code: int32(code),
|
||||
Reason: reason,
|
||||
},
|
||||
},
|
||||
}
|
||||
if len(reason) > 0 {
|
||||
resp.Result.Reason = metav1.StatusReason(reason)
|
||||
if len(message) > 0 {
|
||||
resp.Result.Message = message
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
Reference in New Issue
Block a user