Skip to content

Commit

Permalink
Use more descriptive name for NamespacedName arg on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancoleman committed Jun 2, 2023
1 parent 06fe76e commit 88e0307
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions control-plane/api-gateway/gatekeeper/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions control-plane/api-gateway/gatekeeper/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ 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
}
return err
}

// 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
}
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api-gateway/gatekeeper/rolebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api-gateway/gatekeeper/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api-gateway/gatekeeper/serviceaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 88e0307

Please sign in to comment.