Skip to content

Commit

Permalink
fix user change ns annotations (#4592)
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 committed Mar 14, 2024
1 parent 1c960df commit 424fcc7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions controllers/user/controllers/user_controller.go
Expand Up @@ -237,10 +237,11 @@ func (r *UserReconciler) syncNamespace(ctx context.Context, user *userv1.User) c
r.Logger.V(1).Info("define namespace User namespace is created", "isCreated", isCreated, "namespace", ns.Name)
}
if change, err = controllerutil.CreateOrUpdate(ctx, r.Client, ns, func() error {
ns.Annotations = map[string]string{
userAnnotationCreatorKey: user.Name,
userAnnotationOwnerKey: user.Annotations[userAnnotationOwnerKey],
if ns.Annotations == nil {
ns.Annotations = make(map[string]string)
}
ns.Annotations[userAnnotationCreatorKey] = user.Name
ns.Annotations[userAnnotationOwnerKey] = user.Annotations[userAnnotationOwnerKey]
ns.Labels = config.SetPodSecurity(ns.Labels)
// add label for namespace to filter
ns.Labels[userLabelOwnerKey] = user.Annotations[userAnnotationOwnerKey]
Expand Down

0 comments on commit 424fcc7

Please sign in to comment.