-
Notifications
You must be signed in to change notification settings - Fork 389
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
[Synthetics] Fix follow redirects #256
Conversation
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.
@btoueg Did you run the acceptance tests? I'm very surprised nothing is broken whereas you did modify the schema itself. Also can you add a test on options too?
|
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 this PR! Left a few comments, mostly about seeing if we can use ParseBool as I think it'll reduce the complexity here. Let me know what you think.
return old == new | ||
}, | ||
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { | ||
expectedValues := map[string]struct{}{"true": {}, "false": {}, "1": {}, "0": {}} |
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.
Could we use parseBool here too - https://golang.org/pkg/strconv/#ParseBool
If that function returns doesn't return an error then this validation passes?
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.
ParseBool
does not fit my use case here, but I rewrote it with a switch à la ParseBool
TIL
|
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { | ||
followRedirectsRaw, ok := val.(map[string]interface{})["follow_redirects"] | ||
if ok { | ||
followRedirectsStr := followRedirectsRaw.(string) |
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.
As we chatted about offline, this type assertion causes an issue on TF 0.11 (works fine in 0.12) Lets try to convert this value into a string if possible to avoid breaking things.
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.
Overall looks good to me and seems to work for TF 0.11 and 0.12, thanks for that. Currently it looks like the user shown diff is:
~ datadog_synthetics_test.test_synth
options.follow_redirects: "false" => "1"
But there doesn't appear to be any issues with spurious non-empty diffs.
Though @btoueg since we learned that from the first point TF nested schemas is limited to string values
actually can be boolean/int values and are just strings in the state, is this change explicitly needed then?
Discussed offline. The diff in 0.12 is:
|
Considering:
follow_redirects
is a boolean in Datadog json apiwe need to convert boolean like this:
☝️better because
follow_redirects
is advertised as a boolean in the documentation so this PR: