-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Compare sqlinstance-locationpreference mockgcp
- Loading branch information
1 parent
6c804b7
commit e8594ae
Showing
12 changed files
with
33 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,13 +95,9 @@ func (s *sqlInstancesService) Insert(ctx context.Context, req *pb.SqlInstancesIn | |
fqn := name.String() | ||
now := time.Now() | ||
|
||
region := "us-central1" | ||
zone := "us-central1-a" | ||
|
||
obj := proto.Clone(req.GetBody()).(*pb.DatabaseInstance) | ||
obj.Name = name.InstanceName | ||
obj.Project = name.Project.ID | ||
obj.Region = region | ||
|
||
obj.SelfLink = fmt.Sprintf("https://sqladmin.googleapis.com/sql/v1beta4/projects/%s/instances/%s", | ||
name.Project.ID, name.InstanceName) | ||
|
@@ -112,8 +108,6 @@ func (s *sqlInstancesService) Insert(ctx context.Context, req *pb.SqlInstancesIn | |
return nil, err | ||
} | ||
|
||
obj.GceZone = zone | ||
|
||
// By default, allocate a public IP for the instance. | ||
shouldAllocatePublicIP := true | ||
// By default, do not allocate a private IP for the instance. | ||
|
@@ -172,7 +166,9 @@ func (s *sqlInstancesService) Insert(ctx context.Context, req *pb.SqlInstancesIn | |
|
||
obj.ServiceAccountEmailAddress = fmt.Sprintf("p%[email protected]", name.Project.Number) | ||
|
||
populateDefaults(obj, zone) | ||
populateDefaults(obj) | ||
|
||
obj.GceZone = obj.Settings.LocationPreference.Zone | ||
|
||
obj.Settings.SettingsVersion = wrapperspb.Int64(1) | ||
|
||
|
@@ -510,7 +506,7 @@ func setDatabaseVersionDefaults(obj *pb.DatabaseInstance) error { | |
return nil | ||
} | ||
|
||
func populateDefaults(obj *pb.DatabaseInstance, zone string) { | ||
func populateDefaults(obj *pb.DatabaseInstance) { | ||
if obj.InstanceType == pb.SqlInstanceType_SQL_INSTANCE_TYPE_UNSPECIFIED { | ||
obj.InstanceType = pb.SqlInstanceType_CLOUD_SQL_INSTANCE | ||
} | ||
|
@@ -571,13 +567,12 @@ func populateDefaults(obj *pb.DatabaseInstance, zone string) { | |
ipConfiguration.SslMode = pb.IpConfiguration_ALLOW_UNENCRYPTED_AND_ENCRYPTED | ||
} | ||
|
||
locationPreference := settings.LocationPreference | ||
if locationPreference == nil { | ||
locationPreference = &pb.LocationPreference{} | ||
settings.LocationPreference = locationPreference | ||
if settings.LocationPreference == nil { | ||
settings.LocationPreference = &pb.LocationPreference{ | ||
Kind: "sql#locationPreference", | ||
Zone: obj.Region + "-a", | ||
} | ||
} | ||
locationPreference.Kind = "sql#locationPreference" | ||
locationPreference.Zone = zone | ||
|
||
backupConfiguration := settings.BackupConfiguration | ||
if backupConfiguration == nil { | ||
|
@@ -735,7 +730,7 @@ func (s *sqlInstancesService) Update(ctx context.Context, req *pb.SqlInstancesUp | |
obj.State = existing.State | ||
obj.UpgradableDatabaseVersions = existing.UpgradableDatabaseVersions | ||
|
||
populateDefaults(obj, existing.GetSettings().GetLocationPreference().GetZone()) | ||
populateDefaults(obj) | ||
|
||
obj.Settings.SettingsVersion = wrapperspb.Int64(existing.GetSettings().GetSettingsVersion().GetValue() + 1) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters