@@ -11,6 +11,7 @@ import (
11
11
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
12
12
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
13
13
"github.com/ovh/go-ovh/ovh"
14
+ "github.com/ovh/terraform-provider-ovh/ovh/helpers"
14
15
"github.com/ybriffa/rfc3339"
15
16
)
16
17
@@ -32,6 +33,7 @@ type CloudProjectDatabaseResponse struct {
32
33
Status string `json:"status"`
33
34
SubnetId string `json:"subnetId"`
34
35
Version string `json:"version"`
36
+ Disk CloudProjectDatabaseDisk `json:"disk"`
35
37
}
36
38
37
39
func (s * CloudProjectDatabaseResponse ) String () string {
@@ -71,6 +73,7 @@ func (v CloudProjectDatabaseResponse) ToMap() map[string]interface{} {
71
73
obj ["plan" ] = v .Plan
72
74
obj ["status" ] = v .Status
73
75
obj ["version" ] = v .Version
76
+ obj ["disk" ] = v .Disk .ToMap ()
74
77
75
78
return obj
76
79
}
@@ -136,7 +139,20 @@ type CloudProjectDatabaseCreateOpts struct {
136
139
}
137
140
138
141
type CloudProjectDatabaseDisk struct {
139
- Size int `json:"size"`
142
+ Type string `json:"type,omitempty"`
143
+ Size * int `json:"size,omitempty"`
144
+ }
145
+
146
+ func (cpdd * CloudProjectDatabaseDisk ) ToMap () map [string ]interface {} {
147
+ obj := make (map [string ]interface {})
148
+ obj ["size" ] = cpdd .Size
149
+ obj ["type" ] = cpdd .Type
150
+ return obj
151
+ }
152
+
153
+ func validateCloudProjectDatabaseDiskSize (v interface {}, k string ) (ws []string , errors []error ) {
154
+ errors = validateIsSupEqual (v .(int ), 0 )
155
+ return
140
156
}
141
157
142
158
type CloudProjectDatabaseNodesPattern struct {
@@ -168,24 +184,18 @@ func (opts *CloudProjectDatabaseCreateOpts) FromResource(d *schema.ResourceData)
168
184
opts .NetworkId = nodes [0 ].NetworkId
169
185
opts .SubnetId = nodes [0 ].SubnetId
170
186
opts .Version = d .Get ("version" ).(string )
171
-
172
- diskSize , ok := d .Get ("disk_size" ).(int )
173
- if ok {
174
- if diskSize < 0 {
175
- return fmt .Errorf ("the disk size needs to be positive" ), nil
176
- }
177
- opts .Disk = CloudProjectDatabaseDisk {diskSize }
178
- }
187
+ opts .Disk = CloudProjectDatabaseDisk {Size : helpers .GetNilIntPointer (d .Get ("disk_size" ))}
179
188
return nil , opts
180
189
}
181
190
182
191
type CloudProjectDatabaseUpdateOpts struct {
183
- AclsEnabled bool `json:"aclsEnabled,omitempty"`
184
- Description string `json:"description,omitempty"`
185
- Flavor string `json:"flavor,omitempty"`
186
- Plan string `json:"plan,omitempty"`
187
- RestApi bool `json:"restApi,omitempty"`
188
- Version string `json:"version,omitempty"`
192
+ AclsEnabled bool `json:"aclsEnabled,omitempty"`
193
+ Description string `json:"description,omitempty"`
194
+ Flavor string `json:"flavor,omitempty"`
195
+ Plan string `json:"plan,omitempty"`
196
+ RestApi bool `json:"restApi,omitempty"`
197
+ Version string `json:"version,omitempty"`
198
+ Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
189
199
}
190
200
191
201
func (opts * CloudProjectDatabaseUpdateOpts ) FromResource (d * schema.ResourceData ) (error , * CloudProjectDatabaseUpdateOpts ) {
@@ -201,6 +211,7 @@ func (opts *CloudProjectDatabaseUpdateOpts) FromResource(d *schema.ResourceData)
201
211
opts .Plan = d .Get ("plan" ).(string )
202
212
opts .Flavor = d .Get ("flavor" ).(string )
203
213
opts .Version = d .Get ("version" ).(string )
214
+ opts .Disk = CloudProjectDatabaseDisk {Size : helpers .GetNilIntPointer (d .Get ("disk_size" ))}
204
215
return nil , opts
205
216
}
206
217
0 commit comments