Skip to content

Commit

Permalink
Merge pull request #701 from terraform-linters/skip_to_tokenize_json_…
Browse files Browse the repository at this point in the history
…syntax

Skip to tokenize JSON syntax code
  • Loading branch information
wata727 committed Apr 4, 2020
2 parents a8f5e44 + 835b188 commit be3aa7b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
25 changes: 25 additions & 0 deletions integration/jsonsyntax/result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"issues": [
{
"rule": {
"name": "aws_instance_invalid_type",
"severity": "error",
"link": ""
},
"message": "\"t1.xmicro\" is an invalid value as instance_type",
"range": {
"filename": "template.tf.json",
"start": {
"line": 5,
"column": 26
},
"end": {
"line": 5,
"column": 37
}
},
"callers": []
}
],
"errors": []
}
10 changes: 10 additions & 0 deletions integration/jsonsyntax/template.tf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"resource": {
"aws_instance": {
"example": {
"instance_type": "t1.xmicro",
"ami": "${join(\"\", [\"ami-123456\"])}"
}
}
}
}
5 changes: 5 additions & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func TestIntegration(t *testing.T) {
Command: "./tflint --format json --module",
Dir: "plugin",
},
{
Name: "jsonsyntax",
Command: "./tflint --format json",
Dir: "jsonsyntax",
},
}

dir, _ := os.Getwd()
Expand Down
4 changes: 4 additions & 0 deletions tflint/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func (l *Loader) LoadAnnotations(dir string) (map[string]Annotations, error) {
ret := map[string]Annotations{}

for _, configFile := range configFiles {
if !strings.HasSuffix(configFile, ".tf") {
continue
}

src, err := l.fs.ReadFile(configFile)
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions tflint/test-fixtures/annotation_files/file.tf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"resource": {
"aws_instance": {
"example": {
"instance_type": "t1.xmicro",
"ami": "${join(\"\", [\"ami-123456\"])}"
}
}
}
}

0 comments on commit be3aa7b

Please sign in to comment.