Skip to content

Commit d2c881f

Browse files
committed
chore: always update the personal organization
1 parent e3085c5 commit d2c881f

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

internal/controller/resourcemanager/personal_organization_controller.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,23 @@ func (r *PersonalOrganizationController) Reconcile(ctx context.Context, req ctrl
5858
Annotations: map[string]string{
5959
"kubernetes.io/display-name": fmt.Sprintf("Personal Organization - %s %s", user.Spec.GivenName, user.Spec.FamilyName),
6060
},
61-
OwnerReferences: []metav1.OwnerReference{
62-
// The owner reference is used to ensure that the personal organization
63-
// is deleted when the user is deleted.
64-
{
65-
APIVersion: iamv1alpha1.SchemeGroupVersion.String(),
66-
Kind: "User",
67-
Name: user.Name,
68-
UID: user.UID,
69-
},
70-
},
71-
},
72-
Spec: resourcemanagerv1alpha1.OrganizationSpec{
73-
Type: "Personal",
7461
},
7562
}
7663

7764
_, err := controllerutil.CreateOrUpdate(ctx, r.Client, personalOrg, func() error {
7865
logger.Info("Creating or updating personal organization", "organization", personalOrg.Name)
7966
personalOrg.Annotations["kubernetes.io/display-name"] = fmt.Sprintf("Personal Organization - %s %s", user.Spec.GivenName, user.Spec.FamilyName)
67+
personalOrg.ObjectMeta.OwnerReferences = []metav1.OwnerReference{
68+
// The owner reference is used to ensure that the personal organization
69+
// is deleted when the user is deleted.
70+
{
71+
APIVersion: iamv1alpha1.SchemeGroupVersion.String(),
72+
Kind: "User",
73+
Name: user.Name,
74+
UID: user.UID,
75+
},
76+
}
77+
personalOrg.Spec.Type = "Personal"
8078
return nil
8179
})
8280
if err != nil {

0 commit comments

Comments
 (0)