-
Notifications
You must be signed in to change notification settings - Fork 277
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
base: main
Are you sure you want to change the base?
Add maintenance day validation for database and kubernetes clusters #1293
Conversation
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ValidateFunc: validation.IsDayOfTheWeek(true), |
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.
I did not validate this also works with capitalized weekdays. The provider docs list lowercase examples but in the case of database clusters I tested and both were accepted by the DO API.
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.
I think ignoring case here is correct, but in addition to days of the week, DOKS maintenance policies can also set any
if the user has no preference.
validation.IsDayOfTheWeek
is just a thin wrapper around validation.StringInSlice
. So we can use that here it support any
as well.
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.
Ah right, I missed that even though I saw it in the docs.
I updated it and amended my commit. Hope that's alright.
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.
Thanks for another helpful contribution!
I left a comment in line re: DOKS maintenance policies also supporting any
.
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ValidateFunc: validation.IsDayOfTheWeek(true), |
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.
I think ignoring case here is correct, but in addition to days of the week, DOKS maintenance policies can also set any
if the user has no preference.
validation.IsDayOfTheWeek
is just a thin wrapper around validation.StringInSlice
. So we can use that here it support any
as well.
c831635
to
c5dd54e
Compare
c5dd54e
to
7fe8510
Compare
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ValidateFunc: validation.StringInSlice([]string{"any", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}, true), |
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.
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?
The docs did not really tell me how to use this field.