nagaboinaramgopal opened a new pull request, #337:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/337

   ### Description
   
   The `hypervisor` `ValidateFunc` on the `cloudstack_host` resource used 
`sort.SearchStrings` as if it returned a "found" flag, but `sort.SearchStrings` 
returns the insertion index (0..len). The check `>= len(validHypervisors)` 
therefore only rejected a value that sorts after every supported entry, so 
unsupported values such as `foo`, `docker`, `esxi`, or `kvm2` passed plan-time 
validation and failed later with an opaque server-side error at apply.
   
   Fixed by treating a value as valid only when the element at the returned 
index actually equals it, which is the standard `sort.SearchStrings` idiom.
   
   ### Testing
   
   Added a unit test `TestResourceCloudStackHostHypervisorValidation` asserting 
the supported hypervisors are accepted and unsupported values are rejected. It 
needs no live CloudStack:
   
       go test ./cloudstack/ -run TestResourceCloudStackHostHypervisorValidation
   
   The test fails against the current code (bad values are accepted) and passes 
with the fix.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to