diff --git a/cli.go b/cli.go index 6f28013..4cf1aaf 100644 --- a/cli.go +++ b/cli.go @@ -21,9 +21,9 @@ func gatherResources(s *state) map[string]interface{} { } if len(s.outputs()) > 0 { - groups["all"] = make(map[string]string, 0) + groups["all"] = make(map[string]interface{}, 0) for _, out := range s.outputs() { - groups["all"].(map[string]string)[out.keyName] = out.value + groups["all"].(map[string]interface{})[out.keyName] = out.value } } return groups diff --git a/output.go b/output.go index 7cb6343..515b643 100644 --- a/output.go +++ b/output.go @@ -8,10 +8,10 @@ type Output struct { // The keyName and value of the output keyName string - value string + value interface{} } -func NewOutput(keyName string, value string) (*Output, error) { +func NewOutput(keyName string, value interface{}) (*Output, error) { // TODO: Warn instead of silently ignore error? if len(keyName) == 0 { diff --git a/parser.go b/parser.go index 53e4eb8..6dc27e0 100644 --- a/parser.go +++ b/parser.go @@ -35,10 +35,10 @@ func (s *state) outputs() []*Output { for _, m := range s.Modules { for k, v := range m.Outputs { - var o *Output; + var o *Output switch v := v.(type) { case map[string]interface{}: - o, _ = NewOutput(k, v["value"].(string)) + o, _ = NewOutput(k, v["value"]) case string: o, _ = NewOutput(k, v) default: diff --git a/parser_test.go b/parser_test.go index 3e47ad4..02b116c 100644 --- a/parser_test.go +++ b/parser_test.go @@ -24,7 +24,17 @@ const exampleStateFile = ` "sensitive": false, "type": "string", "value": "mydc" - } + }, + "ids": { + "type": "list", + "value": [1, 2, 3, 4] + }, + "map": { + "type": "map", + "value": { + "key": "value" + } + } }, "resources": { "aws_instance.one.0": { @@ -129,7 +139,7 @@ const exampleStateFile = ` const expectedListOutput = ` { - "all": {"datacenter": "mydc", "olddatacenter": "<0.7_format"}, + "all": {"datacenter": "mydc", "olddatacenter": "<0.7_format", "ids": [1, 2, 3, 4], "map": {"key": "value"}}, "one": ["10.0.0.1", "10.0.1.1"], "two": ["50.0.0.1"], "three": ["192.168.0.3"],