Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#2594 from jasonvigil/fix-mysql…
Browse files Browse the repository at this point in the history
…-user-deletion

fix: Delete mysql root user after creation
  • Loading branch information
google-oss-prow[bot] authored Sep 3, 2024
2 parents 16431f8 + 0a4f6b3 commit a08c3a1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/direct/sql/sqlinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (a *sqlInstanceAdapter) insertInstance(ctx context.Context, u *unstructured
if user.Name == "root" && strings.HasPrefix(created.DatabaseVersion, "MYSQL") {
// Delete "root" user to match Terraform behavior, to improve default security.
// Ref: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance
op, err := a.sqlUsersClient.Delete(a.projectID, a.resourceID).Context(ctx).Name(user.Name).Do()
op, err := a.sqlUsersClient.Delete(a.projectID, a.resourceID).Context(ctx).Name(user.Name).Host(user.Host).Do()
if err != nil {
return fmt.Errorf("deleting SQLInstance %s root user failed: %w", a.desired.Name, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ X-Xss-Protection: 0

---

DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/mysqlbasic-${uniqueId}/users?alt=json&name=root&prettyPrint=false
DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/mysqlbasic-${uniqueId}/users?alt=json&host=%25&name=root&prettyPrint=false
User-Agent: kcc/controller-manager

200 OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ X-Xss-Protection: 0

---

DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-sample-${uniqueId}/users?alt=json&name=root&prettyPrint=false
DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-sample-${uniqueId}/users?alt=json&host=%25&name=root&prettyPrint=false
User-Agent: kcc/controller-manager

200 OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ X-Xss-Protection: 0

---

DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqluser-dep-${uniqueId}/users?alt=json&name=root&prettyPrint=false
DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqluser-dep-${uniqueId}/users?alt=json&host=%25&name=root&prettyPrint=false
User-Agent: kcc/controller-manager

200 OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ X-Xss-Protection: 0

---

DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/users?alt=json&name=root&prettyPrint=false
DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/${projectId}/instances/sqlinstance-${uniqueId}/users?alt=json&host=%25&name=root&prettyPrint=false
User-Agent: kcc/controller-manager

200 OK
Expand Down

0 comments on commit a08c3a1

Please sign in to comment.