Skip to content
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 maintenance day validation for database and kubernetes clusters #1293

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 4 additions & 3 deletions digitalocean/kubernetes/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ func ResourceDigitalOceanKubernetesCluster() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"day": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"any", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}, true),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much experience with Go. I see that Go has no line length limit. So go fmt didn't complain or change this.

Should I wrap this to have every value on a separate line for readability?

Copy link
Member

@andrewsomething andrewsomething Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not something that is required in Go, but it is still often nice for readability. I've pushed a commit doing so since we've already made you wait too long on this.

},
"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
Loading