Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mq): Use external name instead of metadata.name for user #1958

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pkg/controller/mq/user/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func SetupUser(mgr ctrl.Manager, o controller.Options) error {
}

reconcilerOpts := []managed.ReconcilerOption{
managed.WithInitializers(),
managed.WithInitializers(managed.NewNameAsExternalName(mgr.GetClient())),
managed.WithCriticalAnnotationUpdater(custommanaged.NewRetryingCriticalAnnotationUpdater(mgr.GetClient())),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), opts: opts}),
managed.WithPollInterval(o.PollInterval),
Expand Down Expand Up @@ -142,7 +142,7 @@ func (e *custom) preCreate(ctx context.Context, cr *svcapitypes.User, obj *svcsd
return errors.Wrap(err, "cannot get password from the given secret")
}
obj.Password = pointer.ToOrNilIfZeroValue(pw)
obj.Username = pointer.ToOrNilIfZeroValue(cr.Name)
obj.Username = pointer.ToOrNilIfZeroValue(meta.GetExternalName(cr))
obj.BrokerId = cr.Spec.ForProvider.BrokerID
return nil
}
Expand All @@ -151,13 +151,12 @@ func postCreate(_ context.Context, cr *svcapitypes.User, obj *svcsdk.CreateUserO
if err != nil {
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, cr.Name)
return cre, nil
}

func (e *custom) preUpdate(ctx context.Context, cr *svcapitypes.User, obj *svcsdk.UpdateUserRequest) error {
obj.BrokerId = cr.Spec.ForProvider.BrokerID
obj.Username = pointer.ToOrNilIfZeroValue(cr.Name)
obj.Username = pointer.ToOrNilIfZeroValue(meta.GetExternalName(cr))

pw, pwchanged, err := mq.GetPassword(ctx, e.kube, &cr.Spec.ForProvider.PasswordSecretRef, cr.Spec.WriteConnectionSecretToReference)
if err != nil {
Expand Down
Loading