Skip to content

Commit

Permalink
Ensure orphaned bundle deployments are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Aug 28, 2020
1 parent 5489992 commit 82aa140
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/controllers/cleanup/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type handler struct {
func Register(ctx context.Context, apply apply.Apply,
secrets corecontrollers.SecretController,
serviceAccount corecontrollers.ServiceAccountController,
bundledeployment fleetcontrollers.BundleDeploymentController,
role rbaccontrollers.RoleController,
roleBinding rbaccontrollers.RoleBindingController,
clusterRole rbaccontrollers.ClusterRoleController,
Expand All @@ -34,6 +35,13 @@ func Register(ctx context.Context, apply apply.Apply,
apply: apply,
}

bundledeployment.OnChange(ctx, "managed-cleanup", func(_ string, obj *fleet.BundleDeployment) (*fleet.BundleDeployment, error) {
if obj == nil {
return nil, nil
}
return obj, h.cleanup(obj)
})

clusterRole.OnChange(ctx, "managed-cleanup", func(_ string, obj *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error) {
if obj == nil {
return nil, nil
Expand Down

0 comments on commit 82aa140

Please sign in to comment.