mirror of
https://github.com/adammck/terraform-inventory
synced 2024-11-22 20:01:58 +01:00
List resources with and without counters
This commit is contained in:
parent
f518634ed6
commit
a212fb68b7
19
cli.go
19
cli.go
@ -9,18 +9,27 @@ import (
|
||||
func cmdList(stdout io.Writer, stderr io.Writer, s *state) int {
|
||||
groups := make(map[string][]string, 0)
|
||||
|
||||
// add each instance as a pseudo-group, so they can be provisioned
|
||||
// Add each instance name as a pseudo-group, so they can be provisioned
|
||||
// individually where necessary.
|
||||
for name, res := range s.resources() {
|
||||
groups[name] = []string{res.Address()}
|
||||
for _, res := range s.resources() {
|
||||
_, ok := groups[res.Name]
|
||||
if !ok {
|
||||
groups[res.Name] = []string{}
|
||||
}
|
||||
|
||||
// Add the instance by name. There can be many instances with the same name,
|
||||
// created using the count parameter.
|
||||
groups[res.Name] = append(groups[res.Name], res.Address())
|
||||
|
||||
groups[res.NameWithCounter()] = []string{res.Address()}
|
||||
}
|
||||
|
||||
return output(stdout, stderr, groups)
|
||||
}
|
||||
|
||||
func cmdHost(stdout io.Writer, stderr io.Writer, s *state, hostname string) int {
|
||||
for name, res := range s.resources() {
|
||||
if hostname == name {
|
||||
for _, res := range s.resources() {
|
||||
if hostname == res.Name {
|
||||
return output(stdout, stderr, res.Attributes())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user