-
Notifications
You must be signed in to change notification settings - Fork 86
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
*: Support user management through crd. #175 #218
Conversation
08524b3
to
504e29a
Compare
de84d79
to
6bf585b
Compare
…blank line of the code block.
6bf585b
to
234f625
Compare
@@ -0,0 +1,381 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor the file.
|
||
sqlRunner, err := r.getSqlRunner(ctx, user) | ||
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("get sqlrunner faild, err: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
faild -> failed
// 3. Set the password and permissions for the existing hosts according to the spec. | ||
// Regardless of whether the password is modified or not, reset it to keep it up to date. | ||
if err := r.setPassword(ctx, sqlRunner, userName, host, password); err != nil { | ||
return fmt.Errorf("set password faild, err: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
host := []string{host} | ||
// Regardless of whether the permissions is modified or not, reset it to keep it up to date. | ||
if err := r.setPermission(ctx, sqlRunner, permissions, userName, host); err != nil { | ||
return fmt.Errorf("set permissions faild, err: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
// 7. Authorize newly created user hosts. | ||
// Ensure that the user has been successfully created before authorization. | ||
if err := r.setPermission(ctx, sqlRunner, permissions, userName, unexistHosts); err != nil { | ||
return fmt.Errorf("set permissions faild, err: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
// createUser create users in mysql based on cr information. | ||
func (r *MysqlUserReconciler) createUser(ctx context.Context, query internal.Query, sqlRunner *internal.SQLRunner) error { | ||
if err := sqlRunner.RunQuery(query.String(), query.Args()...); err != nil { | ||
return fmt.Errorf("create mysql user faild, err: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
} | ||
|
||
// If mysql user present, create or update. | ||
cuErr := r.createOrUpdate(ctx, sqlRunner, user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor it.
// 6. Add finalizer. | ||
// 7. Authorize newly created user hosts. | ||
// 8. Update user`s status. | ||
func (r *MysqlUserReconciler) createOrUpdate(ctx context.Context, sqlRunner *internal.SQLRunner, mysqlUser *mysqluser.MysqlUser) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor it.
What type of PR is this?
/enhancement
Which issue(s) this PR fixes?
Fixes #175 #198 #189 #220
What this PR does?
Summary:
Special notes for your reviewer?
The main logic is in this commit: *: Support user management through crd. #175
For test:
radondb/mysql-operator:test-2021910
radondb/mysql-sidecar:test-2021910