Skip to content

Commit

Permalink
Fix tests broken by #46
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan McCall committed Sep 16, 2016
1 parent c5060d9 commit 1c036fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type allGroup struct {
Hosts []string `json:"hosts"`
Vars map[string]string `json:"vars"`
Vars map[string]interface{} `json:"vars"`
}

func appendUniq(strs []string, item string) []string {
Expand All @@ -27,7 +27,7 @@ func appendUniq(strs []string, item string) []string {

func gatherResources(s *state) map[string]interface{} {
groups := make(map[string]interface{}, 0)
all_group := allGroup{Vars: make(map[string]string)}
all_group := allGroup{Vars: make(map[string]interface{})}
groups["all"] = &all_group

for _, res := range s.resources() {
Expand All @@ -45,7 +45,7 @@ func gatherResources(s *state) map[string]interface{} {

if len(s.outputs()) > 0 {
for _, out := range s.outputs() {
all_group.Vars[out.keyName] = out.value.(string)
all_group.Vars[out.keyName] = out.value
}
}
return groups
Expand Down Expand Up @@ -74,7 +74,7 @@ func cmdInventory(stdout io.Writer, stderr io.Writer, s *state) int {
writeLn("", stdout, stderr)
writeLn("["+group+":vars]", stdout, stderr)
for key, item := range grp.Vars {
writeLn(key+"="+item, stdout, stderr)
writeLn(key+"="+item.(string), stdout, stderr)
}
}

Expand Down
10 changes: 9 additions & 1 deletion parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,15 @@ const exampleStateFile = `

const expectedListOutput = `
{
"all": {"datacenter": "mydc", "olddatacenter": "<0.7_format", "ids": [1, 2, 3, 4], "map": {"key": "value"}},
"all": {
"hosts": ["10.0.0.1"],
"vars": {
"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"],
Expand Down

0 comments on commit 1c036fe

Please sign in to comment.