-
Notifications
You must be signed in to change notification settings - Fork 4.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
Provider - Add the missing suppress.CaseDifference
for case-insensitive string properties
#15182
Conversation
…tive string properties
hey @magodo Thanks for this PR. Whilst this is one approach to solve this issue, unfortunately this is actually a slightly different bug insofar as these fields should be case-sensitive instead of case-insensitive (and have incorrectly been marked as Thanks! |
@tombuildsstuff I'm not sure whether it is totally fine to make all of them to be case-sensitiv. E.g. some of them are marked as case-insensitive for walking around service issues? Also, it might breaks some users' existing configurations? |
@tombuildsstuff Thank you for mentioning the identity issue, that makes a lot of sense. While for the other properties, we are still not sure whether it is safe to make them case sensitive for the same reason. This PR is to complement the in correct case-insensitive usages, about whether to make some of them to be case-sensitive, how about we open another issue/PR for that? |
@magodo - all enums should be case sensitive and only when its absolutely required to work around a bug should we be ignoring case, and there should be a linked issue documenting it somewhere on the rest specs. also in those cases we can just change the casing on read to match what the enums are if the service refuses to respect the enum casing while still enforcing the correct case in terraform. |
@katbyte I absolutely agree that we should always allow users to specify enum in case sensitive manner, unless there is a necessary need to work around something. While this PR is not for this purpose, it just make sure thoese already marked as case insensitive (no matter on purpose or not) enums are really acting as case insensitively, i.e. apply with uppercase previously and then change it to lowercase won't cause a diff. This is accomplished by adding the suppression. In order to identify which case insensitve enums are not necessary is another topic, from my opinion, it should be done case by case, with some decent test to verify. Also, doing that change might break some existing configs users are using. So I'd suggest to make it in another PR(s). WDYT? |
At this point so close to 3.0 i suggest we do the opposite, remove the case insensitive bool on validation with a 3.0 flag and make the move towards can sensitivity. this is a large pr to fix a single issue with storagev2 |
…-sensitive in 3.0 The **enum** here means any schema with `ValidateFunc: validation.StringInSlice(...)` defined. This commit corrects the missing case-insensitive enum schemas via `gogrep -x 'validation.StringInSlice($_, true)' ./internal/...` (previously it was: `gogrep -x '$_: {$*_, Type: pluginsdk.TypeString, $*_}' -g 'validation.StringInSlice($_, true)'`) by ensuring they all have a `DiffSuppressFunc`. Then this commit changes makes both the validate func to be case-insensitive only for v2.0, also the diff suppression function only takes effect for v2.0.
@katbyte I've refined the PR to modify all the places listed by
As discussed offline, some of the enums listed in the Also, we can expect some of these schemas will be reverted back to be case insensitive in case the backend API has case problems. In that case, we will want a PR to do the revert (either via resetting them to be case insensitive, or do the casing conversion during flatten), together with a Swagger issue to track the issue. |
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 @magodo - now just need to fix up the merge conflicts and runt ests to check case
@katbyte I've resolved the conflicts now. Now the output of |
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 @magodo - LGTM 🏗️
This functionality has been released in v2.97.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
For string properties whose
ValidateFunc
is set tovalidation.StringInSlice
with case-insensitive flag set totrue
, ensure it comes with theDiffSuppressFunc: suppress.CaseDifference
or the alike.With the help of
gogrep
(gogrep -x '$_: {$*_, Type: pluginsdk.TypeString, $*_}' -g 'validation.StringInSlice($_, true)' -v 'suppress.CaseDifference' ./...
), I've complemented all the properties that are not met.PS: I assume either
StateFunc: state.IgnoreCase
orDiffSuppressFunc: uppress.CaseDifference
does the trick. So I didn't add up for theStateFunc
.Fixes #15173