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

   ### Problem
   
   `device_id` on `cloudstack_attach_volume` is a `schema.TypeInt`, which the 
Terraform SDK returns as a Go `int`. The create path asserted it as `int64`:
   
   ```go
   p.SetDeviceid(v.(int64))
   ```
   
   So attaching a volume with an explicit `device_id` panics the provider:
   
   ```
   interface conversion: interface {} is int, not int64
   ```
   
   ### Fix
   
   Assert the actual type and convert to `int64`, matching how `SetDeviceid` is 
fed elsewhere:
   
   ```go
   p.SetDeviceid(int64(v.(int)))
   ```
   
   ### Test
   
   Added `TestAttachVolumeDeviceIdDoesNotPanic`, which runs the create function 
with `device_id` set against an unreachable endpoint. Before the fix it panics 
with the interface conversion error; after the fix it reaches the API call and 
returns the request error instead.
   
   ```
   go test ./cloudstack/ -run TestAttachVolumeDeviceIdDoesNotPanic
   ```
   


-- 
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