Skip to content

Commit

Permalink
Merge pull request #8874 from hashicorp/jbardin/json-hcl
Browse files Browse the repository at this point in the history
Fix #8820 Regression in loading variables.tf.json from module
  • Loading branch information
jbardin authored Sep 16, 2016
2 parents 4f7723b + 425142d commit 458e921
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 4 deletions.
47 changes: 47 additions & 0 deletions config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,53 @@ func TestLoadJSONBasic(t *testing.T) {
}
}

func TestLoadJSONAmbiguous(t *testing.T) {
js := `
{
"variable": {
"first": {
"default": {
"key": "val"
}
},
"second": {
"description": "Described",
"default": {
"key": "val"
}
}
}
}
`

c, err := LoadJSON([]byte(js))
if err != nil {
t.Fatalf("err: %s", err)
}

if len(c.Variables) != 2 {
t.Fatal("config should have 2 variables, found", len(c.Variables))
}

first := &Variable{
Name: "first",
Default: map[string]interface{}{"key": "val"},
}
second := &Variable{
Name: "second",
Description: "Described",
Default: map[string]interface{}{"key": "val"},
}

if !reflect.DeepEqual(first, c.Variables[0]) {
t.Fatalf("\nexpected: %#v\ngot: %#v", first, c.Variables[0])
}

if !reflect.DeepEqual(second, c.Variables[1]) {
t.Fatalf("\nexpected: %#v\ngot: %#v", second, c.Variables[1])
}
}

func TestLoadFileBasic_jsonNoName(t *testing.T) {
c, err := LoadFile(filepath.Join(fixtureDir, "resource-no-name.tf.json"))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/hashicorp/hcl/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/hashicorp/hcl/appveyor.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 58 additions & 1 deletion vendor/github.com/hashicorp/hcl/decoder.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1176,10 +1176,10 @@
"revision": "7e3c02b30806fa5779d3bdfc152ce4c6f40e7b38"
},
{
"checksumSHA1": "fa9G5tEr4oJJc3vtgn/B0NWZXfA=",
"checksumSHA1": "8OPDk+bKyRGJoKcS4QNw9F7dpE8=",
"path": "github.com/hashicorp/hcl",
"revision": "99df0eb941dd8ddbc83d3f3605a34f6a686ac85e",
"revisionTime": "2016-09-02T16:52:19Z"
"revision": "ef8133da8cda503718a74741312bf50821e6de79",
"revisionTime": "2016-09-16T13:01:00Z"
},
{
"checksumSHA1": "67DfevLBglV52Y2eAuhFc/xQni0=",
Expand Down

0 comments on commit 458e921

Please sign in to comment.