nagaboinaramgopal opened a new pull request, #344:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/344
### Description
Every data source filters by asserting the looked-up JSON field as a string,
for example `volumeJSON[name].(string)`. A filter that references a field which
does not exist gets `nil`, and one that references a numeric field gets a
`float64`, so the assertion panics the provider with `interface conversion:
interface {} is nil, not string`. The same unsafe assertion is duplicated
across all the data sources, so each is fixed by stringifying the value with
`fmt.Sprintf("%v", ...)`, which matches any field safely.
### Testing
Added a unit test
`TestApplyVolumeFiltersDoesNotPanicOnUnknownOrNonStringField` covering the
volume data source as a representative case, filtering on an unknown field and
on a numeric field. It needs no live CloudStack:
go test ./cloudstack/ -run
TestApplyVolumeFiltersDoesNotPanicOnUnknownOrNonStringField
It panics against the current code 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]