Skip to content

Commit e9588c5

Browse files
authored
fix(datastore): allow not setting tier.replicas (#22)
1 parent 3d6c3b9 commit e9588c5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

internal/provider/datastore.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ func (r *datastoreResource) Schema(_ context.Context, _ resource.SchemaRequest,
106106
Required: true,
107107
},
108108
"replicas": schema.Int64Attribute{
109-
MarkdownDescription: "The number of replicas for the datastore.",
109+
MarkdownDescription: "The number of replicas for the datastore. Default is 0.",
110110
Optional: true,
111+
Computed: true,
111112
},
112113
},
113114
},

internal/resource_model/datastore.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (d *Datastore) FromConfig(ctx context.Context, in *dfcloud.Datastore) {
4141
d.ID = types.StringValue(in.ID)
4242
d.Name = types.StringValue(in.Config.Name)
4343
d.NetworkId = types.StringNull()
44+
d.Tier.Replicas = types.Int64Null()
4445
d.CreatedAt = types.Int64Value(in.CreatedAt)
4546
d.Location.Provider = types.StringValue(string(in.Config.Location.Provider))
4647
d.Location.Region = types.StringValue(in.Config.Location.Region)
@@ -49,7 +50,10 @@ func (d *Datastore) FromConfig(ctx context.Context, in *dfcloud.Datastore) {
4950
d.Password = types.StringValue(in.Key)
5051
d.Tier.Memory = types.Int64Value(int64(in.Config.Tier.Memory))
5152
d.Tier.PerformanceTier = types.StringValue(string(in.Config.Tier.PerformanceTier))
52-
d.Tier.Replicas = types.Int64Value(int64(*in.Config.Tier.Replicas))
53+
54+
if in.Config.Tier.Replicas != nil {
55+
d.Tier.Replicas = types.Int64Value(int64(*in.Config.Tier.Replicas))
56+
}
5357

5458
if in.Config.MaintenanceWindow.DurationHours != nil || in.Config.MaintenanceWindow.Hour != nil || in.Config.MaintenanceWindow.Weekday != nil {
5559
d.MaintenanceWindow = types.ObjectValueMust(map[string]attr.Type{

0 commit comments

Comments
 (0)