-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 validation for start_time to resource_policy #2940
Add validation for start_time to resource_policy #2940
Conversation
Hi! I'm the modular magician, I work on Magic Modules. Pull request statusesNo diff detected in Ansible. New Pull RequestsI built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed. |
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.
Can we also add a note to api.yaml? to make it more explicit they dont have a choice for MM (right now it says HH:MM where MM is 00, so we might as well say an hourly time of HH:00 instead)
func validateHourlyOnly(val interface{}, key string) (warns []string, errs []error) { | ||
v := val.(string) | ||
parts := strings.Split(v, ":") | ||
if len(parts) != 2 { |
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.
Feel free to ignore this but we also might as well verify the hour is between 0 and 23 at this point? Part of me thinks you should make this a regexp match or do time.Parse("15:04", v) (even though I hate how they make you define a custom format)
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.
we don't have to validate hours because the api will reject bad inputs there whereas the minutes it would accept and silently transform. But it's probably worth throwing it in anyway.
re: time.parse or regex - it's going to be a significantly more complex operation to use either of those over string splitting and casting to ints and I don't think either strategy provides added value in readability or flexibility.
Hi! I'm the modular magician, I work on Magic Modules. Pull request statusesterraform-provider-google-beta already has an open PR. New Pull RequestsI didn't open any new pull requests because of this PR. |
Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec.
c9d8ee3
to
cdacf6e
Compare
Fixes hashicorp/terraform-provider-google#4611
Release Note Template for Downstream PRs (will be copied)