From f4c41985d8dc6ba7bd4f851aac240e69aa998f48 Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Thu, 10 Sep 2020 15:27:27 +0200 Subject: [PATCH] Using pointers and internal handler for Namespace OwnerReferences (#86) * Using pointers and internal handler for Namespace OwnerReferences * Missing go fmt --- pkg/webhook/ingress/validating.go | 2 +- pkg/webhook/namespace_quota/validating.go | 8 ++++---- pkg/webhook/network_policies/validating.go | 10 +++++----- pkg/webhook/owner_reference/patching.go | 8 ++++---- pkg/webhook/pvc/validating.go | 6 +++--- pkg/webhook/service_labels/patching.go | 6 +++--- pkg/webhook/tenant_prefix/patching.go | 8 ++++---- pkg/webhook/utils/in_capsule_group.go | 6 +++--- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pkg/webhook/ingress/validating.go b/pkg/webhook/ingress/validating.go index 8444ceff..acc15698 100644 --- a/pkg/webhook/ingress/validating.go +++ b/pkg/webhook/ingress/validating.go @@ -53,7 +53,7 @@ func (w *webhook) GetPath() string { return "/validating-ingress" } -type handler struct {} +type handler struct{} func Handler() capsulewebhook.Handler { return &handler{} diff --git a/pkg/webhook/namespace_quota/validating.go b/pkg/webhook/namespace_quota/validating.go index fd103192..3fb8dadd 100644 --- a/pkg/webhook/namespace_quota/validating.go +++ b/pkg/webhook/namespace_quota/validating.go @@ -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" } diff --git a/pkg/webhook/network_policies/validating.go b/pkg/webhook/network_policies/validating.go index 9010be01..5a1f89ac 100644 --- a/pkg/webhook/network_policies/validating.go +++ b/pkg/webhook/network_policies/validating.go @@ -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" } diff --git a/pkg/webhook/owner_reference/patching.go b/pkg/webhook/owner_reference/patching.go index 9ee31ba9..20b0b3f1 100644 --- a/pkg/webhook/owner_reference/patching.go +++ b/pkg/webhook/owner_reference/patching.go @@ -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" } diff --git a/pkg/webhook/pvc/validating.go b/pkg/webhook/pvc/validating.go index f0994842..5b03a8bb 100644 --- a/pkg/webhook/pvc/validating.go +++ b/pkg/webhook/pvc/validating.go @@ -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 } diff --git a/pkg/webhook/service_labels/patching.go b/pkg/webhook/service_labels/patching.go index 55c055e7..2c53c29f 100644 --- a/pkg/webhook/service_labels/patching.go +++ b/pkg/webhook/service_labels/patching.go @@ -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" } diff --git a/pkg/webhook/tenant_prefix/patching.go b/pkg/webhook/tenant_prefix/patching.go index 9d94c364..2cf5788d 100644 --- a/pkg/webhook/tenant_prefix/patching.go +++ b/pkg/webhook/tenant_prefix/patching.go @@ -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" } diff --git a/pkg/webhook/utils/in_capsule_group.go b/pkg/webhook/utils/in_capsule_group.go index aefcda04..7fad6cc8 100644 --- a/pkg/webhook/utils/in_capsule_group.go +++ b/pkg/webhook/utils/in_capsule_group.go @@ -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("")