mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-19 12:36:39 +00:00
Using pointers and internal handler for Namespace OwnerReferences (#86)
* Using pointers and internal handler for Namespace OwnerReferences * Missing go fmt
This commit is contained in:
@@ -53,7 +53,7 @@ func (w *webhook) GetPath() string {
|
||||
return "/validating-ingress"
|
||||
}
|
||||
|
||||
type handler struct {}
|
||||
type handler struct{}
|
||||
|
||||
func Handler() capsulewebhook.Handler {
|
||||
return &handler{}
|
||||
|
||||
@@ -41,15 +41,15 @@ func Webhook(handler capsulewebhook.Handler) capsulewebhook.Webhook {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return r.handler
|
||||
func (w *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return w.handler
|
||||
}
|
||||
|
||||
func (r *webhook) GetName() string {
|
||||
func (w *webhook) GetName() string {
|
||||
return "NamespaceQuota"
|
||||
}
|
||||
|
||||
func (r *webhook) GetPath() string {
|
||||
func (w *webhook) GetPath() string {
|
||||
return "/validate-v1-namespace-quota"
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
|
||||
// +kubebuilder:webhook:path=/validating-v1-network-policy,mutating=false,failurePolicy=fail,groups=networking.k8s.io,resources=networkpolicies,verbs=create;update;delete,versions=v1,name=validating.network-policy.capsule.clastix.io
|
||||
|
||||
type webhook struct{
|
||||
type webhook struct {
|
||||
handler capsulewebhook.Handler
|
||||
}
|
||||
|
||||
@@ -39,15 +39,15 @@ func Webhook(handler capsulewebhook.Handler) capsulewebhook.Webhook {
|
||||
return &webhook{handler: handler}
|
||||
}
|
||||
|
||||
func (n webhook) GetHandler() capsulewebhook.Handler {
|
||||
return n.handler
|
||||
func (w *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return w.handler
|
||||
}
|
||||
|
||||
func (n webhook) GetName() string {
|
||||
func (w *webhook) GetName() string {
|
||||
return "NetworkPolicy"
|
||||
}
|
||||
|
||||
func (n webhook) GetPath() string {
|
||||
func (w *webhook) GetPath() string {
|
||||
return "/validating-v1-network-policy"
|
||||
}
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ func Webhook(handler capsulewebhook.Handler) capsulewebhook.Webhook {
|
||||
return &webhook{handler: handler}
|
||||
}
|
||||
|
||||
func (w webhook) GetHandler() capsulewebhook.Handler {
|
||||
return &handler{}
|
||||
func (w *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return w.handler
|
||||
}
|
||||
|
||||
func (w webhook) GetName() string {
|
||||
func (w *webhook) GetName() string {
|
||||
return "OwnerReference"
|
||||
}
|
||||
|
||||
func (w webhook) GetPath() string {
|
||||
func (w *webhook) GetPath() string {
|
||||
return "/mutate-v1-namespace-owner-reference"
|
||||
}
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ func Webhook(handler capsulewebhook.Handler) capsulewebhook.Webhook {
|
||||
return &webhook{handler: handler}
|
||||
}
|
||||
|
||||
func (w webhook) GetName() string {
|
||||
func (w *webhook) GetName() string {
|
||||
return "Pvc"
|
||||
}
|
||||
|
||||
func (w webhook) GetPath() string {
|
||||
func (w *webhook) GetPath() string {
|
||||
return "/validating-v1-pvc"
|
||||
}
|
||||
|
||||
func (w webhook) GetHandler() capsulewebhook.Handler {
|
||||
func (w *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return w.handler
|
||||
}
|
||||
|
||||
|
||||
@@ -42,15 +42,15 @@ func Webhook(handler capsulewebhook.Handler) capsulewebhook.Webhook {
|
||||
return &webhook{handler: handler}
|
||||
}
|
||||
|
||||
func (w webhook) GetHandler() capsulewebhook.Handler {
|
||||
func (w *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return w.handler
|
||||
}
|
||||
|
||||
func (w webhook) GetName() string {
|
||||
func (w *webhook) GetName() string {
|
||||
return "ServiceLabels"
|
||||
}
|
||||
|
||||
func (w webhook) GetPath() string {
|
||||
func (w *webhook) GetPath() string {
|
||||
return "/mutate-v1-service-labels"
|
||||
}
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ func Webhook(handler capsulewebhook.Handler) *webhook {
|
||||
}
|
||||
}
|
||||
|
||||
func (o webhook) GetHandler() capsulewebhook.Handler {
|
||||
return o.handler
|
||||
func (w *webhook) GetHandler() capsulewebhook.Handler {
|
||||
return w.handler
|
||||
}
|
||||
|
||||
func (o webhook) GetName() string {
|
||||
func (w *webhook) GetName() string {
|
||||
return "OwnerReference"
|
||||
}
|
||||
|
||||
func (o webhook) GetPath() string {
|
||||
func (w *webhook) GetPath() string {
|
||||
return "/validating-v1-namespace-tenant-prefix"
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ func (h handler) isCapsuleUser(req admission.Request) bool {
|
||||
return utils.UserGroupList(req.UserInfo.Groups).IsInCapsuleGroup(h.capsuleGroup)
|
||||
}
|
||||
|
||||
func (h handler) OnCreate(client client.Client, decoder *admission.Decoder) webhook.Func {
|
||||
func (h *handler) OnCreate(client client.Client, decoder *admission.Decoder) webhook.Func {
|
||||
return func(ctx context.Context, req admission.Request) admission.Response {
|
||||
if !h.isCapsuleUser(req) {
|
||||
return admission.Allowed("")
|
||||
@@ -53,7 +53,7 @@ func (h handler) OnCreate(client client.Client, decoder *admission.Decoder) webh
|
||||
}
|
||||
}
|
||||
|
||||
func (h handler) OnDelete(client client.Client, decoder *admission.Decoder) webhook.Func {
|
||||
func (h *handler) OnDelete(client client.Client, decoder *admission.Decoder) webhook.Func {
|
||||
return func(ctx context.Context, req admission.Request) admission.Response {
|
||||
if !h.isCapsuleUser(req) {
|
||||
return admission.Allowed("")
|
||||
@@ -62,7 +62,7 @@ func (h handler) OnDelete(client client.Client, decoder *admission.Decoder) webh
|
||||
}
|
||||
}
|
||||
|
||||
func (h handler) OnUpdate(client client.Client, decoder *admission.Decoder) webhook.Func {
|
||||
func (h *handler) OnUpdate(client client.Client, decoder *admission.Decoder) webhook.Func {
|
||||
return func(ctx context.Context, req admission.Request) admission.Response {
|
||||
if !h.isCapsuleUser(req) {
|
||||
return admission.Allowed("")
|
||||
|
||||
Reference in New Issue
Block a user