Solve bug that prevented sending StoredVmQuota and DeployedVmQuota when creating/updating Org User #445
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.
This PR is related vmware/terraform-provider-vcd#799
Description
This PR aims to solve a bug reported on vmware/terraform-provider-vcd#799. When trying to update a user from whatever quota to 0 (unlimited), it wasn't working. Creating was working.
Detailed description
VCD Terraform provider, when updating an user it was using the method
OrgUser.Update()
. Turns out that after doing some troubleshooting, I've spotted that on structtypes.User
the attributesStoredVmQuota
andDeployedVmQuota
had theomitempty
tag, which was preventing to send these fields on the PUT HTTP request when updating if they were set to 0, because Go recognizes this as the empty value and doesn't sent it.The outcome of this was the API returning a 200 OK but these fields not being set to 0 (unlimited quota) because everything else was being update but those two fields, since they were not included in the request.
When creating a user it was working if set to 0, because if the API receives a POST request without these two fields, it set them to 0 (unlimited) by default.
To solve this, those two fields were removed that xml tag, so this fields is always sent in all PUT requests:
Also
Test_UserCRUD
has been updated to testOrgUser.Update()
and check this edge case.