Skip to content

Commit

Permalink
revert changes to mockgcp for cloudsql #28f990192
Browse files Browse the repository at this point in the history
  • Loading branch information
600lyy committed Nov 6, 2024
1 parent 65ee2e7 commit e0f9fc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 79 deletions.
11 changes: 0 additions & 11 deletions mockgcp/mocksql/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ func (s *MockService) NewHTTPMux(ctx context.Context, conn *grpc.ClientConn) (ht
error.Message = "The Cloud SQL instance does not exist."
error.Status = ""
}

for errIdx := range error.Errors {
if strings.HasPrefix(error.Errors[errIdx].Message, "database ") {
error.Errors[errIdx].Message = "Not Found."
error.Errors[errIdx].Reason = "notFound"
}
}
if strings.HasPrefix(error.Message, "database ") {
error.Message = "Not Found"
error.Status = ""
}
}
}

Expand Down
8 changes: 1 addition & 7 deletions mockgcp/mocksql/sqlinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func setDatabaseVersionDefaults(obj *pb.DatabaseInstance) error {
switch obj.DatabaseVersion {
case pb.SqlDatabaseVersion_MYSQL_5_7:
obj.DatabaseInstalledVersion = "MYSQL_5_7_44"
obj.MaintenanceVersion = "MYSQL_5_7_44.R20241020.00_00"
obj.MaintenanceVersion = "MYSQL_5_7_44.R20231105.01_03"
obj.UpgradableDatabaseVersions = []*pb.AvailableDatabaseVersion{
{
DisplayName: asRef("MySQL 8.0"),
Expand Down Expand Up @@ -359,11 +359,6 @@ func setDatabaseVersionDefaults(obj *pb.DatabaseInstance) error {
MajorVersion: asRef("MYSQL_8_0"),
Name: asRef("MYSQL_8_0_37"),
},
{
DisplayName: asRef("MySQL 8.0.39"),
MajorVersion: asRef("MYSQL_8_0"),
Name: asRef("MYSQL_8_0_39"),
},
}
case pb.SqlDatabaseVersion_MYSQL_8_0:
obj.DatabaseInstalledVersion = "MYSQL_8_0_31"
Expand Down Expand Up @@ -526,7 +521,6 @@ func populateDefaults(obj *pb.DatabaseInstance) {
Entitled: asRef(false),
FlagRecommenderEnabled: asRef(false),
IndexAdvisorEnabled: asRef(false),
ActiveQueryEnabled: asRef(false),
}
} else if isPostgres(obj) {
obj.GeminiConfig = &pb.GeminiInstanceConfig{
Expand Down
5 changes: 0 additions & 5 deletions mockgcp/mocksql/sqluser.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ func (s *sqlUsersService) Insert(ctx context.Context, req *pb.SqlUsersInsertRequ
obj.Project = name.Project.ID
obj.Instance = name.Instance
obj.Kind = "sql#user"
if obj.GetPasswordPolicy() == nil {
obj.PasswordPolicy = &pb.UserPasswordValidationPolicy{
Status: &pb.PasswordStatus{},
}
}

obj.Etag = fields.ComputeWeakEtag(obj)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ X-Xss-Protection: 0
"instance": "sqlinstance-sample-${uniqueId}",
"kind": "sql#user",
"name": "root",
"passwordPolicy": {
"status": {}
},
"project": "${projectId}"
}
],
Expand Down Expand Up @@ -227,7 +224,6 @@ X-Xss-Protection: 0
"etag": "abcdef0123A=",
"gceZone": "us-central1-a",
"geminiConfig": {
"activeQueryEnabled": false,
"entitled": false,
"flagRecommenderEnabled": false,
"indexAdvisorEnabled": false
Expand All @@ -240,7 +236,7 @@ X-Xss-Protection: 0
}
],
"kind": "sql#instance",
"maintenanceVersion": "MYSQL_5_7_44.R20241020.00_00",
"maintenanceVersion": "MYSQL_5_7_44.R20231105.01_03",
"name": "sqlinstance-sample-${uniqueId}",
"project": "${projectId}",
"region": "us-central1",
Expand Down Expand Up @@ -369,11 +365,6 @@ X-Xss-Protection: 0
"displayName": "MySQL 8.0.37",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_37"
},
{
"displayName": "MySQL 8.0.39",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_39"
}
]
}
Expand Down Expand Up @@ -401,11 +392,12 @@ X-Xss-Protection: 0
"errors": [
{
"domain": "global",
"message": "Not Found.",
"message": "database \"projects/${projectId}/instances/sqlinstance-sample-${uniqueId}/databases/sqldatabase-sample-${uniqueId}\" not found",
"reason": "notFound"
}
],
"message": "Not Found"
"message": "database \"projects/${projectId}/instances/sqlinstance-sample-${uniqueId}/databases/sqldatabase-sample-${uniqueId}\" not found",
"status": "NOT_FOUND"
}
}

Expand Down Expand Up @@ -549,7 +541,6 @@ X-Xss-Protection: 0
"etag": "abcdef0123A=",
"gceZone": "us-central1-a",
"geminiConfig": {
"activeQueryEnabled": false,
"entitled": false,
"flagRecommenderEnabled": false,
"indexAdvisorEnabled": false
Expand All @@ -562,7 +553,7 @@ X-Xss-Protection: 0
}
],
"kind": "sql#instance",
"maintenanceVersion": "MYSQL_5_7_44.R20241020.00_00",
"maintenanceVersion": "MYSQL_5_7_44.R20231105.01_03",
"name": "sqlinstance-sample-${uniqueId}",
"project": "${projectId}",
"region": "us-central1",
Expand Down Expand Up @@ -691,11 +682,6 @@ X-Xss-Protection: 0
"displayName": "MySQL 8.0.37",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_37"
},
{
"displayName": "MySQL 8.0.39",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_39"
}
]
}
Expand Down Expand Up @@ -793,9 +779,6 @@ X-Xss-Protection: 0
"kind": "sql#user",
"name": "sqluser-${uniqueId}",
"password": "cGFzc3dvcmQ=",
"passwordPolicy": {
"status": {}
},
"project": "${projectId}"
}
],
Expand Down Expand Up @@ -827,7 +810,6 @@ X-Xss-Protection: 0
"etag": "abcdef0123A=",
"gceZone": "us-central1-a",
"geminiConfig": {
"activeQueryEnabled": false,
"entitled": false,
"flagRecommenderEnabled": false,
"indexAdvisorEnabled": false
Expand All @@ -840,7 +822,7 @@ X-Xss-Protection: 0
}
],
"kind": "sql#instance",
"maintenanceVersion": "MYSQL_5_7_44.R20241020.00_00",
"maintenanceVersion": "MYSQL_5_7_44.R20231105.01_03",
"name": "sqlinstance-sample-${uniqueId}",
"project": "${projectId}",
"region": "us-central1",
Expand Down Expand Up @@ -969,11 +951,6 @@ X-Xss-Protection: 0
"displayName": "MySQL 8.0.37",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_37"
},
{
"displayName": "MySQL 8.0.39",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_39"
}
]
}
Expand Down Expand Up @@ -1003,9 +980,6 @@ X-Xss-Protection: 0
"kind": "sql#user",
"name": "sqluser-${uniqueId}",
"password": "cGFzc3dvcmQ=",
"passwordPolicy": {
"status": {}
},
"project": "${projectId}"
}
],
Expand Down Expand Up @@ -1037,7 +1011,6 @@ X-Xss-Protection: 0
"etag": "abcdef0123A=",
"gceZone": "us-central1-a",
"geminiConfig": {
"activeQueryEnabled": false,
"entitled": false,
"flagRecommenderEnabled": false,
"indexAdvisorEnabled": false
Expand All @@ -1050,7 +1023,7 @@ X-Xss-Protection: 0
}
],
"kind": "sql#instance",
"maintenanceVersion": "MYSQL_5_7_44.R20241020.00_00",
"maintenanceVersion": "MYSQL_5_7_44.R20231105.01_03",
"name": "sqlinstance-sample-${uniqueId}",
"project": "${projectId}",
"region": "us-central1",
Expand Down Expand Up @@ -1179,11 +1152,6 @@ X-Xss-Protection: 0
"displayName": "MySQL 8.0.37",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_37"
},
{
"displayName": "MySQL 8.0.39",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_39"
}
]
}
Expand Down Expand Up @@ -1307,9 +1275,6 @@ X-Xss-Protection: 0
"kind": "sql#user",
"name": "sqluser-${uniqueId}",
"password": "cGFzc3dvcmQ=",
"passwordPolicy": {
"status": {}
},
"project": "${projectId}"
}
],
Expand Down Expand Up @@ -1341,7 +1306,6 @@ X-Xss-Protection: 0
"etag": "abcdef0123A=",
"gceZone": "us-central1-a",
"geminiConfig": {
"activeQueryEnabled": false,
"entitled": false,
"flagRecommenderEnabled": false,
"indexAdvisorEnabled": false
Expand All @@ -1354,7 +1318,7 @@ X-Xss-Protection: 0
}
],
"kind": "sql#instance",
"maintenanceVersion": "MYSQL_5_7_44.R20241020.00_00",
"maintenanceVersion": "MYSQL_5_7_44.R20231105.01_03",
"name": "sqlinstance-sample-${uniqueId}",
"project": "${projectId}",
"region": "us-central1",
Expand Down Expand Up @@ -1483,11 +1447,6 @@ X-Xss-Protection: 0
"displayName": "MySQL 8.0.37",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_37"
},
{
"displayName": "MySQL 8.0.39",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_39"
}
]
}
Expand Down Expand Up @@ -1666,7 +1625,6 @@ X-Xss-Protection: 0
"etag": "abcdef0123A=",
"gceZone": "us-central1-a",
"geminiConfig": {
"activeQueryEnabled": false,
"entitled": false,
"flagRecommenderEnabled": false,
"indexAdvisorEnabled": false
Expand All @@ -1679,7 +1637,7 @@ X-Xss-Protection: 0
}
],
"kind": "sql#instance",
"maintenanceVersion": "MYSQL_5_7_44.R20241020.00_00",
"maintenanceVersion": "MYSQL_5_7_44.R20231105.01_03",
"name": "sqlinstance-sample-${uniqueId}",
"project": "${projectId}",
"region": "us-central1",
Expand Down Expand Up @@ -1808,11 +1766,6 @@ X-Xss-Protection: 0
"displayName": "MySQL 8.0.37",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_37"
},
{
"displayName": "MySQL 8.0.39",
"majorVersion": "MYSQL_8_0",
"name": "MYSQL_8_0_39"
}
]
}
Expand Down

0 comments on commit e0f9fc2

Please sign in to comment.