@@ -12,16 +12,17 @@ import (
12
12
13
13
// Datastore maps the resource schema data.
14
14
type Datastore struct {
15
- ID types.String `tfsdk:"id"`
16
- Name types.String `tfsdk:"name"`
17
- NetworkId types.String `tfsdk:"network_id"`
18
- Location DatastoreLocation `tfsdk:"location"`
19
- Tier DatastoreTier `tfsdk:"tier"`
20
- Dragonfly types.Object `tfsdk:"dragonfly"`
21
- CreatedAt types.Int64 `tfsdk:"created_at"`
22
- Password types.String `tfsdk:"password"`
23
- Addr types.String `tfsdk:"addr"`
24
- DisablePassKey types.Bool `tfsdk:"disable_pass_key"`
15
+ ID types.String `tfsdk:"id"`
16
+ Name types.String `tfsdk:"name"`
17
+ NetworkId types.String `tfsdk:"network_id"`
18
+ Location DatastoreLocation `tfsdk:"location"`
19
+ Tier DatastoreTier `tfsdk:"tier"`
20
+ Dragonfly types.Object `tfsdk:"dragonfly"`
21
+ CreatedAt types.Int64 `tfsdk:"created_at"`
22
+ Password types.String `tfsdk:"password"`
23
+ Addr types.String `tfsdk:"addr"`
24
+ DisablePassKey types.Bool `tfsdk:"disable_pass_key"`
25
+ MaintenanceWindow types.Object `tfsdk:"maintenance_window"`
25
26
}
26
27
27
28
type DatastoreLocation struct {
@@ -50,6 +51,24 @@ func (d *Datastore) FromConfig(ctx context.Context, in *dfcloud.Datastore) {
50
51
d .Tier .PerformanceTier = types .StringValue (string (in .Config .Tier .PerformanceTier ))
51
52
d .Tier .Replicas = types .Int64Value (int64 (* in .Config .Tier .Replicas ))
52
53
54
+ if in .Config .MaintenanceWindow .DurationHours != nil || in .Config .MaintenanceWindow .Hour != nil || in .Config .MaintenanceWindow .Weekday != nil {
55
+ d .MaintenanceWindow = types .ObjectValueMust (map [string ]attr.Type {
56
+ "weekday" : types .Int64Type ,
57
+ "hour" : types .Int64Type ,
58
+ "duration_hours" : types .Int64Type ,
59
+ }, map [string ]attr.Value {
60
+ "weekday" : types .Int64Value (int64 (lo .FromPtr (in .Config .MaintenanceWindow .Weekday ))),
61
+ "hour" : types .Int64Value (int64 (lo .FromPtr (in .Config .MaintenanceWindow .Hour ))),
62
+ "duration_hours" : types .Int64Value (int64 (lo .FromPtr (in .Config .MaintenanceWindow .DurationHours ))),
63
+ })
64
+ } else {
65
+ d .MaintenanceWindow = types .ObjectNull (map [string ]attr.Type {
66
+ "weekday" : types .Int64Type ,
67
+ "hour" : types .Int64Type ,
68
+ "duration_hours" : types .Int64Type ,
69
+ })
70
+ }
71
+
53
72
aclRules , _ := types .ListValueFrom (ctx , types .StringType , in .Config .Dragonfly .AclRules )
54
73
d .Dragonfly = types .ObjectValueMust (map [string ]attr.Type {
55
74
"cache_mode" : types .BoolType ,
@@ -135,6 +154,18 @@ func IntoDatastoreConfig(in Datastore) *dfcloud.Datastore {
135
154
datastore .Config .Dragonfly .AclRules = & rules
136
155
}
137
156
157
+ if in .MaintenanceWindow .Attributes ()["weekday" ] != nil {
158
+ datastore .Config .MaintenanceWindow .Weekday = lo .ToPtr (int (in .MaintenanceWindow .Attributes ()["weekday" ].(types.Int64 ).ValueInt64 ()))
159
+ }
160
+
161
+ if in .MaintenanceWindow .Attributes ()["hour" ] != nil {
162
+ datastore .Config .MaintenanceWindow .Hour = lo .ToPtr (int (in .MaintenanceWindow .Attributes ()["hour" ].(types.Int64 ).ValueInt64 ()))
163
+ }
164
+
165
+ if in .MaintenanceWindow .Attributes ()["duration_hours" ] != nil {
166
+ datastore .Config .MaintenanceWindow .DurationHours = lo .ToPtr (int (in .MaintenanceWindow .Attributes ()["duration_hours" ].(types.Int64 ).ValueInt64 ()))
167
+ }
168
+
138
169
return datastore
139
170
}
140
171
0 commit comments