Skip to content

Commit 711d1e7

Browse files
committed
Add disk type in cloud project data
1 parent 7ceaa57 commit 711d1e7

5 files changed

+23
-12
lines changed

ovh/data_cloud_project_database.go

+10
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ func dataSourceCloudProjectDatabase() *schema.Resource {
157157
Description: "Version of the engine deployed on the cluster",
158158
Computed: true,
159159
},
160+
"disk_size": {
161+
Type: schema.TypeInt,
162+
Description: "Disk size attributes of the cluster",
163+
Computed: true,
164+
},
165+
"disk_type": {
166+
Type: schema.TypeInt,
167+
Description: "Disk type attributes of the cluster",
168+
Computed: true,
169+
},
160170
},
161171
}
162172
}

ovh/resource_cloud_project_database.go

+5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ func resourceCloudProjectDatabase() *schema.Resource {
186186
Optional: true,
187187
ValidateFunc: validateCloudProjectDatabaseDiskSize,
188188
},
189+
"disk_type": {
190+
Type: schema.TypeInt,
191+
Description: "Disk type attributes of the cluster",
192+
Computed: true,
193+
},
189194
},
190195
}
191196
}

ovh/types_cloud_project_database.go

+5-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1313
"github.com/ovh/go-ovh/ovh"
14-
"github.com/ovh/terraform-provider-ovh/ovh/helpers"
1514
"github.com/ybriffa/rfc3339"
1615
)
1716

@@ -73,7 +72,8 @@ func (v CloudProjectDatabaseResponse) ToMap() map[string]interface{} {
7372
obj["plan"] = v.Plan
7473
obj["status"] = v.Status
7574
obj["version"] = v.Version
76-
obj["disk"] = v.Disk.ToMap()
75+
obj["disk_size"] = v.Disk.Size
76+
obj["disk_type"] = v.Disk.Type
7777

7878
return obj
7979
}
@@ -140,14 +140,7 @@ type CloudProjectDatabaseCreateOpts struct {
140140

141141
type CloudProjectDatabaseDisk struct {
142142
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
143+
Size int `json:"size,omitempty"`
151144
}
152145

153146
func validateCloudProjectDatabaseDiskSize(v interface{}, k string) (ws []string, errors []error) {
@@ -184,7 +177,7 @@ func (opts *CloudProjectDatabaseCreateOpts) FromResource(d *schema.ResourceData)
184177
opts.NetworkId = nodes[0].NetworkId
185178
opts.SubnetId = nodes[0].SubnetId
186179
opts.Version = d.Get("version").(string)
187-
opts.Disk = CloudProjectDatabaseDisk{Size: helpers.GetNilIntPointer(d.Get("disk_size"))}
180+
opts.Disk = CloudProjectDatabaseDisk{Size: d.Get("disk_size").(int)}
188181
return nil, opts
189182
}
190183

@@ -211,7 +204,7 @@ func (opts *CloudProjectDatabaseUpdateOpts) FromResource(d *schema.ResourceData)
211204
opts.Plan = d.Get("plan").(string)
212205
opts.Flavor = d.Get("flavor").(string)
213206
opts.Version = d.Get("version").(string)
214-
opts.Disk = CloudProjectDatabaseDisk{Size: helpers.GetNilIntPointer(d.Get("disk_size"))}
207+
opts.Disk = CloudProjectDatabaseDisk{Size: d.Get("disk_size").(int)}
215208
return nil, opts
216209
}
217210

website/docs/d/cloud_project_database.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ The following attributes are exported:
6868
* `plan` - Plan of the cluster.
6969
* `status` - Current status of the cluster.
7070
* `version` - The version of the engine in which the service should be deployed
71+
* `disk_size` - Defines the disk size of the database service.
72+
* `disk_type` - Defines the disk type of the database service.

website/docs/r/cloud_project_database.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ The following attributes are exported:
246246
* `status` - Current status of the cluster.
247247
* `version` - See Argument Reference above.
248248
* `disk_size` - See Argument Reference above.
249+
* `disk_type` - Defines the disk type of the database service.
249250

250251
## Timeouts
251252

0 commit comments

Comments
 (0)