Skip to content

Commit

Permalink
Add maintenance day validation for database and kubernetes clusters (#…
Browse files Browse the repository at this point in the history
…1293)

* database: Add validation to maintenance window and improve docs

* kubernetes: Add validation to maintenance_policy

* k8s: wrap ValidateFunc

---------

Co-authored-by: Andrew Starr-Bochicchio <[email protected]>
Co-authored-by: Andrew Starr-Bochicchio <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2025
1 parent 5b71718 commit a5d21d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions digitalocean/database/resource_database_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ func ResourceDigitalOceanDatabaseCluster() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"day": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.IsDayOfTheWeek(true),
},
"hour": {
Type: schema.TypeString,
Expand Down
11 changes: 11 additions & 0 deletions digitalocean/kubernetes/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ func ResourceDigitalOceanKubernetesCluster() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"any",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday"},
true,
),
},
"start_time": {
Type: schema.TypeString,
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/database_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ The following arguments are supported:

`maintenance_window` supports the following:

* `day` - (Required) The day of the week on which to apply maintenance updates.
* `hour` - (Required) The hour in UTC at which maintenance updates will be applied in 24 hour format.
* `day` - (Required) The day of the week on which to apply maintenance updates. May be one of `monday` through `sunday`.
* `hour` - (Required) The hour in UTC at which maintenance updates will be applied as a string in 24 hour format, e.g. `13:00`.

* `backup_restore` - (Optional) Create a new database cluster based on a backup of an existing cluster.

Expand Down

0 comments on commit a5d21d2

Please sign in to comment.