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

Add grant option to mysqluser #319

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add grant option to mysqluser #319

wants to merge 1 commit into from

Conversation

joeygo
Copy link

@joeygo joeygo commented Mar 3, 2024

This commit allow to define grant permissions to mysqluser.
Example:
apiVersion: mysql.nakamasato.com/v1alpha1
kind: MySQLUser
metadata:
name: sample-user
spec:
mysqlName: mysql-sample
host: '%'
grants:
- privileges: "ALL"
on: "mysql-sample-db1."
- privileges: "SELECT, INSERT, UPDATE"
on: "mysql-sample-db2.
"

@nakamasato
Copy link
Owner

Thank you for your contribution.

Let me take some time to check your change 🙏


func (r *MySQLUserReconciler) updateGrants(ctx context.Context, mysqlClient *sql.DB, mysqlUserName string, mysqlUserHost string, grants []mysqlv1alpha1.Grant) error {
log := log.FromContext(ctx)
_, err := mysqlClient.ExecContext(ctx, fmt.Sprintf("REVOKE ALL PRIVILEGES, GRANT OPTION FROM '%s'@'%s';", mysqlUserName, mysqlUserHost))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if revoking all privileges in every reconciliation loop will make the the user unstable. So I'd like to consider other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants