From 88e0307b7bb8a8cfa8deb8ab6a809a804bc7a7f8 Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Fri, 2 Jun 2023 13:31:17 -0400 Subject: [PATCH] Use more descriptive name for NamespacedName arg on delete --- control-plane/api-gateway/gatekeeper/deployment.go | 4 ++-- control-plane/api-gateway/gatekeeper/role.go | 6 +++--- control-plane/api-gateway/gatekeeper/rolebinding.go | 4 ++-- control-plane/api-gateway/gatekeeper/service.go | 4 ++-- control-plane/api-gateway/gatekeeper/serviceaccount.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/control-plane/api-gateway/gatekeeper/deployment.go b/control-plane/api-gateway/gatekeeper/deployment.go index eecfa31349..cc08e1bbef 100644 --- a/control-plane/api-gateway/gatekeeper/deployment.go +++ b/control-plane/api-gateway/gatekeeper/deployment.go @@ -75,8 +75,8 @@ func (g *Gatekeeper) upsertDeployment(ctx context.Context, gateway gwv1beta1.Gat return nil } -func (g *Gatekeeper) deleteDeployment(ctx context.Context, nsname types.NamespacedName) error { - err := g.Client.Delete(ctx, &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: nsname.Name, Namespace: nsname.Namespace}}) +func (g *Gatekeeper) deleteDeployment(ctx context.Context, gwName types.NamespacedName) error { + err := g.Client.Delete(ctx, &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: gwName.Name, Namespace: gwName.Namespace}}) if k8serrors.IsNotFound(err) { return nil } diff --git a/control-plane/api-gateway/gatekeeper/role.go b/control-plane/api-gateway/gatekeeper/role.go index 243180b7cb..280ea0f720 100644 --- a/control-plane/api-gateway/gatekeeper/role.go +++ b/control-plane/api-gateway/gatekeeper/role.go @@ -52,9 +52,9 @@ func (g *Gatekeeper) upsertRole(ctx context.Context, gateway gwv1beta1.Gateway, return nil } -func (g *Gatekeeper) deleteRole(ctx context.Context, nsname types.NamespacedName) error { +func (g *Gatekeeper) deleteRole(ctx context.Context, gwName types.NamespacedName) error { // Delete the Role - if err := g.Client.Delete(ctx, &rbac.Role{ObjectMeta: metav1.ObjectMeta{Name: nsname.Name, Namespace: nsname.Namespace}}); err != nil { + if err := g.Client.Delete(ctx, &rbac.Role{ObjectMeta: metav1.ObjectMeta{Name: gwName.Name, Namespace: gwName.Namespace}}); err != nil { if k8serrors.IsNotFound(err) { return nil } @@ -62,7 +62,7 @@ func (g *Gatekeeper) deleteRole(ctx context.Context, nsname types.NamespacedName } // Delete the RoleBinding - if err := g.Client.Delete(ctx, &rbac.RoleBinding{ObjectMeta: metav1.ObjectMeta{Name: nsname.Name, Namespace: nsname.Namespace}}); err != nil { + if err := g.Client.Delete(ctx, &rbac.RoleBinding{ObjectMeta: metav1.ObjectMeta{Name: gwName.Name, Namespace: gwName.Namespace}}); err != nil { if k8serrors.IsNotFound(err) { return nil } diff --git a/control-plane/api-gateway/gatekeeper/rolebinding.go b/control-plane/api-gateway/gatekeeper/rolebinding.go index af91ebd9d9..59b7179d45 100644 --- a/control-plane/api-gateway/gatekeeper/rolebinding.go +++ b/control-plane/api-gateway/gatekeeper/rolebinding.go @@ -52,8 +52,8 @@ func (g *Gatekeeper) upsertRoleBinding(ctx context.Context, gateway gwv1beta1.Ga return nil } -func (g *Gatekeeper) deleteRoleBinding(ctx context.Context, nsname types.NamespacedName) error { - if err := g.Client.Delete(ctx, &rbac.RoleBinding{ObjectMeta: metav1.ObjectMeta{Name: nsname.Name, Namespace: nsname.Namespace}}); err != nil { +func (g *Gatekeeper) deleteRoleBinding(ctx context.Context, gwName types.NamespacedName) error { + if err := g.Client.Delete(ctx, &rbac.RoleBinding{ObjectMeta: metav1.ObjectMeta{Name: gwName.Name, Namespace: gwName.Namespace}}); err != nil { if k8serrors.IsNotFound(err) { return nil } diff --git a/control-plane/api-gateway/gatekeeper/service.go b/control-plane/api-gateway/gatekeeper/service.go index 149dc067e3..80272b7495 100644 --- a/control-plane/api-gateway/gatekeeper/service.go +++ b/control-plane/api-gateway/gatekeeper/service.go @@ -53,8 +53,8 @@ func (g *Gatekeeper) upsertService(ctx context.Context, gateway gwv1beta1.Gatewa return nil } -func (g *Gatekeeper) deleteService(ctx context.Context, nsname types.NamespacedName) error { - if err := g.Client.Delete(ctx, &corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: nsname.Name, Namespace: nsname.Namespace}}); err != nil { +func (g *Gatekeeper) deleteService(ctx context.Context, gwName types.NamespacedName) error { + if err := g.Client.Delete(ctx, &corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: gwName.Name, Namespace: gwName.Namespace}}); err != nil { if k8serrors.IsNotFound(err) { return nil } diff --git a/control-plane/api-gateway/gatekeeper/serviceaccount.go b/control-plane/api-gateway/gatekeeper/serviceaccount.go index 864047fb1b..47336867aa 100644 --- a/control-plane/api-gateway/gatekeeper/serviceaccount.go +++ b/control-plane/api-gateway/gatekeeper/serviceaccount.go @@ -58,8 +58,8 @@ func (g *Gatekeeper) upsertServiceAccount(ctx context.Context, gateway gwv1beta1 return nil } -func (g *Gatekeeper) deleteServiceAccount(ctx context.Context, nsname types.NamespacedName) error { - if err := g.Client.Delete(ctx, &corev1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: nsname.Name, Namespace: nsname.Namespace}}); err != nil { +func (g *Gatekeeper) deleteServiceAccount(ctx context.Context, gwName types.NamespacedName) error { + if err := g.Client.Delete(ctx, &corev1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: gwName.Name, Namespace: gwName.Namespace}}); err != nil { if k8serrors.IsNotFound(err) { return nil }