-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add disk in database resource creation #333
Changes from 4 commits
9deb0ac
7ceaa57
711d1e7
196d291
184179f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ type CloudProjectDatabaseResponse struct { | |
Status string `json:"status"` | ||
SubnetId string `json:"subnetId"` | ||
Version string `json:"version"` | ||
Disk CloudProjectDatabaseDisk `json:"disk"` | ||
} | ||
|
||
func (s *CloudProjectDatabaseResponse) String() string { | ||
|
@@ -71,6 +72,8 @@ func (v CloudProjectDatabaseResponse) ToMap() map[string]interface{} { | |
obj["plan"] = v.Plan | ||
obj["status"] = v.Status | ||
obj["version"] = v.Version | ||
obj["disk_size"] = v.Disk.Size | ||
obj["disk_type"] = v.Disk.Type | ||
|
||
return obj | ||
} | ||
|
@@ -129,11 +132,22 @@ type CloudProjectDatabaseCreateOpts struct { | |
Description string `json:"description,omitempty"` | ||
NetworkId string `json:"networkId,omitempty"` | ||
NodesPattern CloudProjectDatabaseNodesPattern `json:"nodesPattern,omitempty"` | ||
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"` | ||
Plan string `json:"plan"` | ||
SubnetId string `json:"subnetId,omitempty"` | ||
Version string `json:"version"` | ||
} | ||
|
||
type CloudProjectDatabaseDisk struct { | ||
Type string `json:"type,omitempty"` | ||
Size int `json:"size,omitempty"` | ||
} | ||
|
||
func validateCloudProjectDatabaseDiskSize(v interface{}, k string) (ws []string, errors []error) { | ||
errors = validateIsSupEqual(v.(int), 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only sup ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first the goal of this check was to avoid making request to the OVH API with negative values that would failed every time. And thus, adding more check will be redundant. |
||
return | ||
} | ||
|
||
type CloudProjectDatabaseNodesPattern struct { | ||
Flavor string `json:"flavor"` | ||
Number int `json:"number"` | ||
|
@@ -163,17 +177,18 @@ func (opts *CloudProjectDatabaseCreateOpts) FromResource(d *schema.ResourceData) | |
opts.NetworkId = nodes[0].NetworkId | ||
opts.SubnetId = nodes[0].SubnetId | ||
opts.Version = d.Get("version").(string) | ||
|
||
opts.Disk = CloudProjectDatabaseDisk{Size: d.Get("disk_size").(int), Type: d.Get("disk_type").(string)} | ||
return nil, opts | ||
} | ||
|
||
type CloudProjectDatabaseUpdateOpts struct { | ||
AclsEnabled bool `json:"aclsEnabled,omitempty"` | ||
Description string `json:"description,omitempty"` | ||
Flavor string `json:"flavor,omitempty"` | ||
Plan string `json:"plan,omitempty"` | ||
RestApi bool `json:"restApi,omitempty"` | ||
Version string `json:"version,omitempty"` | ||
AclsEnabled bool `json:"aclsEnabled,omitempty"` | ||
Description string `json:"description,omitempty"` | ||
Flavor string `json:"flavor,omitempty"` | ||
Plan string `json:"plan,omitempty"` | ||
RestApi bool `json:"restApi,omitempty"` | ||
Version string `json:"version,omitempty"` | ||
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"` | ||
} | ||
|
||
func (opts *CloudProjectDatabaseUpdateOpts) FromResource(d *schema.ResourceData) (error, *CloudProjectDatabaseUpdateOpts) { | ||
|
@@ -189,6 +204,7 @@ func (opts *CloudProjectDatabaseUpdateOpts) FromResource(d *schema.ResourceData) | |
opts.Plan = d.Get("plan").(string) | ||
opts.Flavor = d.Get("flavor").(string) | ||
opts.Version = d.Get("version").(string) | ||
opts.Disk = CloudProjectDatabaseDisk{Size: d.Get("disk_size").(int), Type: d.Get("disk_type").(string)} | ||
return nil, opts | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -68,3 +68,5 @@ The following attributes are exported: | |||||
* `plan` - Plan of the cluster. | ||||||
* `status` - Current status of the cluster. | ||||||
* `version` - The version of the engine in which the service should be deployed | ||||||
* `disk_size` - Defines the disk size of the database service. | ||||||
* `disk_type` - Defines the disk type of the database service. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -207,6 +207,8 @@ The following arguments are supported: | |||||
|
||||||
* `opensearch_acls_enabled` - (Optional) Defines whether the ACLs are enabled on an OpenSearch cluster | ||||||
|
||||||
* `disk_size` - (Optional) Defines the disk size of the database service. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to know the unit too?
As a user I don't know "80" what? :-) |
||||||
|
||||||
* `plan` - (Required) Plan of the cluster. | ||||||
Enum: "essential", "business", "enterprise". | ||||||
|
||||||
|
@@ -243,6 +245,8 @@ The following attributes are exported: | |||||
* `plan` - See Argument Reference above. | ||||||
* `status` - Current status of the cluster. | ||||||
* `version` - See Argument Reference above. | ||||||
* `disk_size` - See Argument Reference above. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you add disk_type as computed, need it here |
||||||
* `disk_type` - Defines the disk type of the database service. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## Timeouts | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
ValidateFunc
to check here thatdisk_size
is > 0.Like in
ovh/resource_cloud_project_database_kafka_topic.go