Skip to content

Commit

Permalink
Merge pull request #748 from ovh/dev/aamstutz/fix-clouddb
Browse files Browse the repository at this point in the history
feat: Allow setting maintenance time in ovh_cloud_project_database
  • Loading branch information
amstuta authored Oct 11, 2024
2 parents ef7707d + 402a1eb commit bf72782
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
11 changes: 6 additions & 5 deletions ovh/resource_cloud_project_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ func resourceCloudProjectDatabase() *schema.Resource {
return d.Get("engine").(string) == "mongodb" || new == old
},
},
"maintenance_time": {
Type: schema.TypeString,
Description: "Time on which maintenances can start every day",
Optional: true,
Computed: true,
},

//Computed
"created_at": {
Expand Down Expand Up @@ -228,11 +234,6 @@ func resourceCloudProjectDatabase() *schema.Resource {
},
},
},
"maintenance_time": {
Type: schema.TypeString,
Description: "Time on which maintenances can start every day",
Computed: true,
},
"network_type": {
Type: schema.TypeString,
Description: "Type of network of the cluster",
Expand Down
3 changes: 3 additions & 0 deletions ovh/resource_cloud_project_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ resource "ovh_cloud_project_database" "db" {
ip = "%s"
}
flavor = "%s"
maintenance_time = "01:00:00"
}
`

Expand Down Expand Up @@ -157,6 +158,8 @@ func TestAccCloudProjectDatabase_basic(t *testing.T) {
"ovh_cloud_project_database.db", "plan", "essential"),
resource.TestCheckResourceAttr(
"ovh_cloud_project_database.db", "version", version),
resource.TestCheckResourceAttr(
"ovh_cloud_project_database.db", "maintenance_time", "01:00:00"),
),
},
},
Expand Down
44 changes: 25 additions & 19 deletions ovh/types_cloud_project_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,16 @@ func (v CloudProjectDatabaseNodes) ToMap() map[string]interface{} {
}

type CloudProjectDatabaseCreateOpts struct {
Backups *CloudProjectDatabaseBackups `json:"backups,omitempty"`
Description string `json:"description,omitempty"`
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
IPRestrictions []CloudProjectDatabaseIPRestriction `json:"ipRestrictions,omitempty"`
NetworkId string `json:"networkId,omitempty"`
NodesPattern CloudProjectDatabaseNodesPattern `json:"nodesPattern,omitempty"`
Plan string `json:"plan"`
SubnetId string `json:"subnetId,omitempty"`
Version string `json:"version"`
Backups *CloudProjectDatabaseBackups `json:"backups,omitempty"`
Description string `json:"description,omitempty"`
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
IPRestrictions []CloudProjectDatabaseIPRestriction `json:"ipRestrictions,omitempty"`
MaintenanceTime string `json:"maintenanceTime,omitempty"`
NetworkId string `json:"networkId,omitempty"`
NodesPattern CloudProjectDatabaseNodesPattern `json:"nodesPattern,omitempty"`
Plan string `json:"plan"`
SubnetId string `json:"subnetId,omitempty"`
Version string `json:"version"`
}

type CloudProjectDatabaseDisk struct {
Expand Down Expand Up @@ -258,20 +259,23 @@ func (opts *CloudProjectDatabaseCreateOpts) fromResource(d *schema.ResourceData)
}
}

opts.MaintenanceTime = d.Get("maintenance_time").(string)

return opts, nil
}

type CloudProjectDatabaseUpdateOpts struct {
AclsEnabled bool `json:"aclsEnabled,omitempty"`
Backups *CloudProjectDatabaseBackups `json:"backups,omitempty"`
Description string `json:"description,omitempty"`
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
Flavor string `json:"flavor,omitempty"`
IPRestrictions []CloudProjectDatabaseIPRestriction `json:"ipRestrictions,omitempty"`
Plan string `json:"plan,omitempty"`
RestAPI bool `json:"restApi,omitempty"`
SchemaRegistry bool `json:"schemaRegistry,omitempty"`
Version string `json:"version,omitempty"`
AclsEnabled bool `json:"aclsEnabled,omitempty"`
Backups *CloudProjectDatabaseBackups `json:"backups,omitempty"`
Description string `json:"description,omitempty"`
Disk CloudProjectDatabaseDisk `json:"disk,omitempty"`
Flavor string `json:"flavor,omitempty"`
IPRestrictions []CloudProjectDatabaseIPRestriction `json:"ipRestrictions,omitempty"`
MaintenanceTime string `json:"maintenanceTime,omitempty"`
Plan string `json:"plan,omitempty"`
RestAPI bool `json:"restApi,omitempty"`
SchemaRegistry bool `json:"schemaRegistry,omitempty"`
Version string `json:"version,omitempty"`
}

func (opts *CloudProjectDatabaseUpdateOpts) fromResource(d *schema.ResourceData) (*CloudProjectDatabaseUpdateOpts, error) {
Expand Down Expand Up @@ -314,6 +318,8 @@ func (opts *CloudProjectDatabaseUpdateOpts) fromResource(d *schema.ResourceData)
}
}

opts.MaintenanceTime = d.Get("maintenance_time").(string)

return opts, nil
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/cloud_project_database.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ The following arguments are supported:
* `version` - (Required) The version of the engine in which the service should be deployed
* `backup_regions` - List of region where backups are pushed. Not more than 1 regions for MongoDB. Not more than 2 regions for the other engines with one being the same as the nodes[].region field
* `backup_time` - Time on which backups start every day.
* `maintenance_time` - Time on which maintenances can start every day.

## Attributes Reference

Expand Down

0 comments on commit bf72782

Please sign in to comment.