From 402a1ebc743482f3e88bed54096860555166ae4a Mon Sep 17 00:00:00 2001 From: Arthur Amstutz Date: Fri, 11 Oct 2024 08:35:40 +0000 Subject: [PATCH] feat: Allow setting maintenance time in ovh_cloud_project_database --- ovh/resource_cloud_project_database.go | 11 ++--- ovh/resource_cloud_project_database_test.go | 3 ++ ovh/types_cloud_project_database.go | 44 +++++++++++-------- .../r/cloud_project_database.html.markdown | 1 + 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/ovh/resource_cloud_project_database.go b/ovh/resource_cloud_project_database.go index 906981e27..7eeeb8ce9 100644 --- a/ovh/resource_cloud_project_database.go +++ b/ovh/resource_cloud_project_database.go @@ -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": { @@ -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", diff --git a/ovh/resource_cloud_project_database_test.go b/ovh/resource_cloud_project_database_test.go index fb666da67..4918cd39c 100644 --- a/ovh/resource_cloud_project_database_test.go +++ b/ovh/resource_cloud_project_database_test.go @@ -86,6 +86,7 @@ resource "ovh_cloud_project_database" "db" { ip = "%s" } flavor = "%s" + maintenance_time = "01:00:00" } ` @@ -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"), ), }, }, diff --git a/ovh/types_cloud_project_database.go b/ovh/types_cloud_project_database.go index 7182eee48..f3467db92 100644 --- a/ovh/types_cloud_project_database.go +++ b/ovh/types_cloud_project_database.go @@ -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 { @@ -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) { @@ -314,6 +318,8 @@ func (opts *CloudProjectDatabaseUpdateOpts) fromResource(d *schema.ResourceData) } } + opts.MaintenanceTime = d.Get("maintenance_time").(string) + return opts, nil } diff --git a/website/docs/r/cloud_project_database.html.markdown b/website/docs/r/cloud_project_database.html.markdown index 542b07733..fbe7bb3bf 100644 --- a/website/docs/r/cloud_project_database.html.markdown +++ b/website/docs/r/cloud_project_database.html.markdown @@ -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