Skip to content

Commit d0590cc

Browse files
Add host_standby attribute and deprecate host_secondary attribute (#2220)
1 parent 7269aae commit d0590cc

14 files changed

+75
-37
lines changed

linode/databasemysqlv2/framework_datasource_schema.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ var frameworkDatasourceSchema = schema.Schema{
7272
Computed: true,
7373
},
7474
"host_secondary": schema.StringAttribute{
75-
Description: "The secondary/private host for the Managed Database.",
75+
Description: "The secondary/private host for the Managed Database.",
76+
Computed: true,
77+
DeprecationMessage: "Use host_standby instead.",
78+
},
79+
"host_standby": schema.StringAttribute{
80+
Description: "The standby host for the Managed Database.",
7681
Computed: true,
7782
},
7883
"members": schema.MapAttribute{

linode/databasemysqlv2/framework_models.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Model struct {
3737
EngineID types.String `tfsdk:"engine_id"`
3838
HostPrimary types.String `tfsdk:"host_primary"`
3939
HostSecondary types.String `tfsdk:"host_secondary"`
40+
HostStandby types.String `tfsdk:"host_standby"`
4041
Label types.String `tfsdk:"label"`
4142
Members types.Map `tfsdk:"members"`
4243
Platform types.String `tfsdk:"platform"`
@@ -153,6 +154,7 @@ func (m *Model) Flatten(
153154
)
154155
m.HostPrimary = helper.KeepOrUpdateString(m.HostPrimary, db.Hosts.Primary, preserveKnown)
155156
m.HostSecondary = helper.KeepOrUpdateString(m.HostSecondary, db.Hosts.Standby, preserveKnown)
157+
m.HostStandby = helper.KeepOrUpdateString(m.HostStandby, db.Hosts.Standby, preserveKnown)
156158
m.Label = helper.KeepOrUpdateString(m.Label, db.Label, preserveKnown)
157159
m.OldestRestoreTime = helper.KeepOrUpdateValue(m.OldestRestoreTime, timetypes.NewRFC3339TimePointerValue(db.OldestRestoreTime), preserveKnown)
158160
m.Platform = helper.KeepOrUpdateString(m.Platform, string(db.Platform), preserveKnown)
@@ -387,6 +389,7 @@ func (m *Model) CopyFrom(other *Model, preserveKnown bool) {
387389
m.ForkRestoreTime = helper.KeepOrUpdateValue(m.ForkRestoreTime, other.ForkRestoreTime, preserveKnown)
388390
m.HostPrimary = helper.KeepOrUpdateValue(m.HostPrimary, other.HostPrimary, preserveKnown)
389391
m.HostSecondary = helper.KeepOrUpdateValue(m.HostSecondary, other.HostSecondary, preserveKnown)
392+
m.HostStandby = helper.KeepOrUpdateValue(m.HostStandby, other.HostStandby, preserveKnown)
390393
m.Label = helper.KeepOrUpdateValue(m.Label, other.Label, preserveKnown)
391394
m.Members = helper.KeepOrUpdateValue(m.Members, other.Members, preserveKnown)
392395
m.OldestRestoreTime = helper.KeepOrUpdateValue(m.OldestRestoreTime, other.OldestRestoreTime, preserveKnown)

linode/databasemysqlv2/framework_models_unit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func TestModel_Flatten(t *testing.T) {
110110
require.Equal(t, currentTimeFWValue, model.ForkRestoreTime)
111111
require.Equal(t, "1.2.3.4", model.HostPrimary.ValueString())
112112
require.Equal(t, "4.3.2.1", model.HostSecondary.ValueString())
113+
require.Equal(t, "4.3.2.1", model.HostStandby.ValueString())
113114
require.Equal(t, "foobar", model.RootUsername.ValueString())
114115
require.Equal(t, "barfoo", model.RootPassword.ValueString())
115116
require.Equal(t, currentTimeFWValue, model.Created)

linode/databasemysqlv2/framework_resource_schema.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/hashicorp/terraform-plugin-framework-validators/float64validator"
99
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
1010
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
11-
"github.com/hashicorp/terraform-plugin-framework/path"
1211
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1312
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
1413
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
@@ -152,24 +151,20 @@ var frameworkResourceSchema = schema.Schema{
152151
},
153152
},
154153
"host_primary": schema.StringAttribute{
155-
Description: "The primary host for the Managed Database.",
156-
Computed: true,
157-
PlanModifiers: []planmodifier.String{
158-
stringplanmodifiers.UseStateForUnknownUnlessTheseChanged(
159-
path.MatchRoot("private_network"),
160-
path.MatchRoot("type"),
161-
),
162-
},
154+
Description: "The primary host for the Managed Database.",
155+
Computed: true,
156+
PlanModifiers: databaseshared.HostStringPlanModifiers,
163157
},
164158
"host_secondary": schema.StringAttribute{
165-
Description: "The secondary/private host for the Managed Database.",
166-
Computed: true,
167-
PlanModifiers: []planmodifier.String{
168-
stringplanmodifiers.UseStateForUnknownUnlessTheseChanged(
169-
path.MatchRoot("private_network"),
170-
path.MatchRoot("type"),
171-
),
172-
},
159+
Description: "The secondary/private host for the Managed Database.",
160+
Computed: true,
161+
DeprecationMessage: "Use host_standby instead.",
162+
PlanModifiers: databaseshared.HostStringPlanModifiers,
163+
},
164+
"host_standby": schema.StringAttribute{
165+
Description: "The standby host for the Managed Database.",
166+
Computed: true,
167+
PlanModifiers: databaseshared.HostStringPlanModifiers,
173168
},
174169
"members": schema.MapAttribute{
175170
ElementType: types.StringType,

linode/databasemysqlv2/resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ func TestAccResource_complex(t *testing.T) {
376376
resource.TestCheckNoResourceAttr(resName, "fork_restore_time"),
377377
resource.TestCheckNoResourceAttr(resName, "fork_source"),
378378
resource.TestCheckResourceAttrSet(resName, "host_primary"),
379+
resource.TestCheckResourceAttrSet(resName, "host_standby"),
379380
resource.TestCheckResourceAttr(resName, "label", label),
380381
resource.TestCheckResourceAttrSet(resName, "members.%"),
381382
resource.TestCheckResourceAttrSet(resName, "root_password"),

linode/databasepostgresqlv2/framework_models.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Model struct {
3737
EngineID types.String `tfsdk:"engine_id"`
3838
HostPrimary types.String `tfsdk:"host_primary"`
3939
HostSecondary types.String `tfsdk:"host_secondary"`
40+
HostStandby types.String `tfsdk:"host_standby"`
4041
Label types.String `tfsdk:"label"`
4142
Members types.Map `tfsdk:"members"`
4243
Platform types.String `tfsdk:"platform"`
@@ -172,6 +173,7 @@ func (m *Model) Flatten(
172173
)
173174
m.HostPrimary = helper.KeepOrUpdateString(m.HostPrimary, db.Hosts.Primary, preserveKnown)
174175
m.HostSecondary = helper.KeepOrUpdateString(m.HostSecondary, db.Hosts.Standby, preserveKnown)
176+
m.HostStandby = helper.KeepOrUpdateString(m.HostStandby, db.Hosts.Standby, preserveKnown)
175177
m.Label = helper.KeepOrUpdateString(m.Label, db.Label, preserveKnown)
176178
m.OldestRestoreTime = helper.KeepOrUpdateValue(m.OldestRestoreTime, timetypes.NewRFC3339TimePointerValue(db.OldestRestoreTime), preserveKnown)
177179
m.Platform = helper.KeepOrUpdateString(m.Platform, string(db.Platform), preserveKnown)
@@ -450,6 +452,7 @@ func (m *Model) CopyFrom(other *Model, preserveKnown bool) {
450452
m.ForkRestoreTime = helper.KeepOrUpdateValue(m.ForkRestoreTime, other.ForkRestoreTime, preserveKnown)
451453
m.HostPrimary = helper.KeepOrUpdateValue(m.HostPrimary, other.HostPrimary, preserveKnown)
452454
m.HostSecondary = helper.KeepOrUpdateValue(m.HostSecondary, other.HostSecondary, preserveKnown)
455+
m.HostStandby = helper.KeepOrUpdateValue(m.HostStandby, other.HostStandby, preserveKnown)
453456
m.Label = helper.KeepOrUpdateValue(m.Label, other.Label, preserveKnown)
454457
m.Members = helper.KeepOrUpdateValue(m.Members, other.Members, preserveKnown)
455458
m.OldestRestoreTime = helper.KeepOrUpdateValue(m.OldestRestoreTime, other.OldestRestoreTime, preserveKnown)

linode/databasepostgresqlv2/framework_models_unit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func TestModel_Flatten(t *testing.T) {
107107
require.Equal(t, currentTimeFWValue, model.ForkRestoreTime)
108108
require.Equal(t, "1.2.3.4", model.HostPrimary.ValueString())
109109
require.Equal(t, "4.3.2.1", model.HostSecondary.ValueString())
110+
require.Equal(t, "4.3.2.1", model.HostStandby.ValueString())
110111
require.Equal(t, "foobar", model.RootUsername.ValueString())
111112
require.Equal(t, "barfoo", model.RootPassword.ValueString())
112113
require.Equal(t, currentTimeFWValue, model.Created)

linode/databasepostgresqlv2/framework_resource_schema.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/hashicorp/terraform-plugin-framework-validators/int32validator"
1010
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
1111
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
12-
"github.com/hashicorp/terraform-plugin-framework/path"
1312
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1413
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
1514
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
@@ -154,24 +153,20 @@ var frameworkResourceSchema = schema.Schema{
154153
},
155154
},
156155
"host_primary": schema.StringAttribute{
157-
Description: "The primary host for the Managed Database.",
158-
Computed: true,
159-
PlanModifiers: []planmodifier.String{
160-
stringplanmodifiers.UseStateForUnknownUnlessTheseChanged(
161-
path.MatchRoot("private_network"),
162-
path.MatchRoot("type"),
163-
),
164-
},
156+
Description: "The primary host for the Managed Database.",
157+
Computed: true,
158+
PlanModifiers: databaseshared.HostStringPlanModifiers,
165159
},
166160
"host_secondary": schema.StringAttribute{
167-
Description: "The secondary/private host for the Managed Database.",
168-
Computed: true,
169-
PlanModifiers: []planmodifier.String{
170-
stringplanmodifiers.UseStateForUnknownUnlessTheseChanged(
171-
path.MatchRoot("private_network"),
172-
path.MatchRoot("type"),
173-
),
174-
},
161+
Description: "The secondary/private host for the Managed Database.",
162+
Computed: true,
163+
DeprecationMessage: "Use host_standby instead.",
164+
PlanModifiers: databaseshared.HostStringPlanModifiers,
165+
},
166+
"host_standby": schema.StringAttribute{
167+
Description: "The standby host for the Managed Database.",
168+
Computed: true,
169+
PlanModifiers: databaseshared.HostStringPlanModifiers,
175170
},
176171
"members": schema.MapAttribute{
177172
ElementType: types.StringType,

linode/databasepostgresqlv2/framework_schema_datasource.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ var frameworkDatasourceSchema = schema.Schema{
7676
Computed: true,
7777
},
7878
"host_secondary": schema.StringAttribute{
79-
Description: "The secondary/private host for the Managed Database.",
79+
Description: "The secondary/private host for the Managed Database.",
80+
Computed: true,
81+
DeprecationMessage: "Use host_standby instead.",
82+
},
83+
"host_standby": schema.StringAttribute{
84+
Description: "The standby host for the Managed Database.",
8085
Computed: true,
8186
},
8287
"members": schema.MapAttribute{

linode/databasepostgresqlv2/resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ func TestAccResource_complex(t *testing.T) {
373373
resource.TestCheckNoResourceAttr(resName, "fork_restore_time"),
374374
resource.TestCheckNoResourceAttr(resName, "fork_source"),
375375
resource.TestCheckResourceAttrSet(resName, "host_primary"),
376+
resource.TestCheckResourceAttrSet(resName, "host_standby"),
376377
resource.TestCheckResourceAttr(resName, "label", label),
377378
resource.TestCheckResourceAttrSet(resName, "members.%"),
378379
resource.TestCheckResourceAttrSet(resName, "root_password"),

0 commit comments

Comments
 (0)