From d2bcb4a600c3b792e46366264e4ba32cc6760a61 Mon Sep 17 00:00:00 2001 From: fahed dorgaa Date: Fri, 22 Oct 2021 22:01:40 +0200 Subject: [PATCH] fix replica names for CloudSQLInstance Signed-off-by: fahed dorgaa --- pkg/clients/cloudsql/cloudsql.go | 2 +- pkg/clients/cloudsql/cloudsql_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/clients/cloudsql/cloudsql.go b/pkg/clients/cloudsql/cloudsql.go index 062fd113b..5daebc960 100644 --- a/pkg/clients/cloudsql/cloudsql.go +++ b/pkg/clients/cloudsql/cloudsql.go @@ -188,7 +188,7 @@ func LateInitializeSpec(spec *v1beta1.CloudSQLInstanceParameters, in sqladmin.Da spec.GceZone = gcp.LateInitializeString(spec.GceZone, in.GceZone) spec.InstanceType = gcp.LateInitializeString(spec.InstanceType, in.InstanceType) spec.MaxDiskSize = gcp.LateInitializeInt64(spec.MaxDiskSize, in.MaxDiskSize) - spec.ReplicaNames = gcp.LateInitializeStringSlice(spec.ReplicaNames, in.ReplicaNames) + spec.ReplicaNames = in.ReplicaNames spec.SuspensionReason = gcp.LateInitializeStringSlice(spec.SuspensionReason, in.SuspensionReason) if in.Settings != nil { if spec.Settings.Tier == "" { diff --git a/pkg/clients/cloudsql/cloudsql_test.go b/pkg/clients/cloudsql/cloudsql_test.go index af6f396c2..88c728437 100644 --- a/pkg/clients/cloudsql/cloudsql_test.go +++ b/pkg/clients/cloudsql/cloudsql_test.go @@ -323,6 +323,19 @@ func TestLateInitializeSpec(t *testing.T) { p.Settings.DataDiskSizeGb = gcp.Int64Ptr(30) })}, }, + "ReplicaNamesSynced": { + args: args{ + params: params(func(p *v1beta1.CloudSQLInstanceParameters) { + p.ReplicaNames = []string{"my-replica1"} + }), + db: db(func(db *sqladmin.DatabaseInstance) { + db.ReplicaNames = []string{"my-replica1", "my-replica2"} + }), + }, + want: want{params: params(func(p *v1beta1.CloudSQLInstanceParameters) { + p.ReplicaNames = []string{"my-replica1", "my-replica2"} + })}, + }, "AutoResizeAllowsIncrease": { args: args{ params: params(func(p *v1beta1.CloudSQLInstanceParameters) {