terraform: fix some issues around filtering single counts
This commit is contained in:
parent
d1b46e99bd
commit
a754723561
|
@ -36,7 +36,7 @@ func (f *StateFilter) Filter(fs ...string) ([]*StateFilterResult, error) {
|
|||
|
||||
// If we werent given any filters, then we list all
|
||||
if len(fs) == 0 {
|
||||
as = append(as, &ResourceAddress{})
|
||||
as = append(as, &ResourceAddress{Index: -1})
|
||||
}
|
||||
|
||||
// Filter each of the address. We keep track of this in a map to
|
||||
|
@ -94,6 +94,11 @@ func (f *StateFilter) filterSingle(a *ResourceAddress) []*StateFilterResult {
|
|||
continue
|
||||
}
|
||||
|
||||
if a.Index >= 0 && key.Index != a.Index {
|
||||
// Index doesn't match
|
||||
continue
|
||||
}
|
||||
|
||||
// Build the address for this resource
|
||||
addr := &ResourceAddress{
|
||||
Path: m.Path[1:],
|
||||
|
|
|
@ -51,6 +51,15 @@ func TestStateFilterFilter(t *testing.T) {
|
|||
"*terraform.InstanceState: module.bootstrap.aws_route53_zone.oasis-consul-bootstrap",
|
||||
},
|
||||
},
|
||||
|
||||
"single count index": {
|
||||
"complete.tfstate",
|
||||
[]string{"module.consul.aws_instance.consul-green[0]"},
|
||||
[]string{
|
||||
"*terraform.ResourceState: module.consul.aws_instance.consul-green[0]",
|
||||
"*terraform.InstanceState: module.consul.aws_instance.consul-green[0]",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for n, tc := range cases {
|
||||
|
|
Loading…
Reference in New Issue