nagaboinaramgopal opened a new pull request, #338:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/338
### Description
`applyPodFilters` (`data_source_cloudstack_pod.go`) and
`applyClusterFilters` (`data_source_cloudstack_cluster.go`) returned `true` as
soon as any single filter block matched, so a data source with two or more
filters selected a resource that matched only one of them. For example:
data "cloudstack_pod" "p" {
filter { name = "name" value = "pod-a" }
filter { name = "allocation_state" value = "Disabled" }
}
selects a pod named `pod-a` even when it is actually `Enabled`, because the
name filter alone short-circuits to a match. The result is silent selection of
the wrong pod or cluster.
Every other data source in the provider (instance, volume, template, and
others) ANDs its filters: it returns `false` the moment a filter does not match
and `true` only after all match. This aligns pod and cluster with that
established behaviour.
### Testing
Added unit tests `TestApplyPodFiltersAreAndedNotOred` and
`TestApplyClusterFiltersAreAndedNotOred` asserting that a resource matching
only one of two filters is not selected, and that a resource matching all
filters is. They need no live CloudStack:
go test ./cloudstack/ -run 'TestApply(Pod|Cluster)FiltersAreAndedNotOred'
The tests fail against the current code and pass 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]