Fixing Case Handling for Volume Resource #1074
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, this Pull Request is intended to address the issue #901. However, I've observed that the API V2 accepts, for certain types of resources, the region to be provided in uppercase.
In my Pull Request, I've implemented a solution for the volume resource, involving converting the region string to lowercase when it's added to the
opts
structure in theresourceDigitalOceanVolumeCreate
function, to ensure that the provider calls godo with the region field in lowercase.However, I find that this approach lacks consistency since the API handles the case of a region field in uppercase in the context of the droplet resource (and probably others).
Perhaps the fix should be applied directly to the API.
Nevertheless, strictly adhering to the API documentation, the region slugs are only in lowercase. In the case where a region is indicated in uppercase, either in the resource schema, we apply a condition to ensure the region is only in lowercase, and the documentation should state "lowercase only" for region slugs, or we accept and handle the formatting to lowercase for storage in the state (with StateFunc) and for sending data to godo in
opts
.