Skip to content

Commit 6984395

Browse files
authored
Merge pull request #69 from terraform-linters/json_syntax_support
Add support for JSON configuration syntax
2 parents 79a914b + 540426e commit 6984395

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/go-hclog v0.14.1
88
github.com/hashicorp/go-plugin v1.3.0
99
github.com/hashicorp/go-version v1.2.1
10-
github.com/hashicorp/hcl/v2 v2.6.0
10+
github.com/hashicorp/hcl/v2 v2.7.0
1111
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
1212
github.com/zclconf/go-cty v1.6.1
1313
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYt
4444
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
4545
github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI=
4646
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
47-
github.com/hashicorp/hcl/v2 v2.6.0 h1:3krZOfGY6SziUXa6H9PJU6TyohHn7I+ARYnhbeNBz+o=
48-
github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
47+
github.com/hashicorp/hcl/v2 v2.7.0 h1:IU8qz5UzZ1po3M1D9/Kq6S5zbDGVfI9bnzmC1ogKKmI=
48+
github.com/hashicorp/hcl/v2 v2.7.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
4949
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
5050
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
5151
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=

tflint/client/decode.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/hashicorp/go-version"
88
hcl "github.com/hashicorp/hcl/v2"
99
"github.com/hashicorp/hcl/v2/hclsyntax"
10+
"github.com/hashicorp/hcl/v2/json"
1011
"github.com/terraform-linters/tflint-plugin-sdk/terraform/configs"
1112
)
1213

@@ -67,13 +68,7 @@ func parseExpression(src []byte, filename string, start hcl.Pos) (hcl.Expression
6768
}
6869

6970
if strings.HasSuffix(filename, ".tf.json") {
70-
return nil, hcl.Diagnostics{
71-
&hcl.Diagnostic{
72-
Severity: hcl.DiagError,
73-
Summary: "JSON configuration syntax is not supported",
74-
Subject: &hcl.Range{Filename: filename, Start: start, End: start},
75-
},
76-
}
71+
return json.ParseExpressionWithStartPos(src, filename, start)
7772
}
7873

7974
panic(fmt.Sprintf("Unexpected file: %s", filename))
@@ -85,13 +80,7 @@ func parseConfig(src []byte, filename string, start hcl.Pos) (*hcl.File, hcl.Dia
8580
}
8681

8782
if strings.HasSuffix(filename, ".tf.json") {
88-
return nil, hcl.Diagnostics{
89-
&hcl.Diagnostic{
90-
Severity: hcl.DiagError,
91-
Summary: "JSON configuration syntax is not supported",
92-
Subject: &hcl.Range{Filename: filename, Start: start, End: start},
93-
},
94-
}
83+
return json.ParseWithStartPos(src, filename, start)
9584
}
9685

9786
panic(fmt.Sprintf("Unexpected file: %s", filename))

0 commit comments

Comments
 (0)