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:
Dario Tranchitella
2020-09-10 15:27:27 +02:00
committed by GitHub
parent e8362f739f
commit f4c41985d8
8 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ func (w *webhook) GetPath() string {
return "/validating-ingress"
}
type handler struct {}
type handler struct{}
func Handler() capsulewebhook.Handler {
return &handler{}
+4 -4
View File
@@ -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"
}
+5 -5
View File
@@ -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"
}
+4 -4
View File
@@ -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"
}
+3 -3
View File
@@ -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
}
+3 -3
View File
@@ -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"
}
+4 -4
View File
@@ -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"
}
+3 -3
View File
@@ -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("")