Skip to content

Commit ff072f4

Browse files
authored
Merge pull request #823 from terraform-linters/bump_tflint-plugin-sdk
Bump tflint-plugin-sdk to v0.2.0
2 parents ceea03b + a706fdb commit ff072f4

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ require (
2121
github.com/sourcegraph/go-lsp v0.0.0-20181119182933-0c7d621186c1
2222
github.com/sourcegraph/jsonrpc2 v0.0.0-20190106185902-35a74f039c6a
2323
github.com/spf13/afero v1.3.0
24-
github.com/terraform-linters/tflint-plugin-sdk v0.1.2-0.20200621094814-c5fcef3ab795
24+
github.com/terraform-linters/tflint-plugin-sdk v0.2.0
2525
github.com/terraform-providers/terraform-provider-aws v2.65.0+incompatible
26-
github.com/zclconf/go-cty v1.5.0
26+
github.com/zclconf/go-cty v1.5.1
2727
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
2828
)
2929

go.sum

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
221221
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
222222
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
223223
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
224-
github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0=
225-
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
226224
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
227225
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
228226
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
@@ -274,8 +272,8 @@ github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f h1:Yv9YzBlAETjy
274272
github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
275273
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
276274
github.com/hashicorp/go-hclog v0.10.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
277-
github.com/hashicorp/go-hclog v0.13.0 h1:Do32YnDMnq7v7FU50AgH+1ExKCOkl9HBxvSI1JWr+rA=
278-
github.com/hashicorp/go-hclog v0.13.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
275+
github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU=
276+
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
279277
github.com/hashicorp/go-immutable-radix v0.0.0-20180129170900-7f3cd4390caa/go.mod h1:6ij3Z20p+OhOkCSrA0gImAWoHYQRGbnlcuk6XYTiaRw=
280278
github.com/hashicorp/go-msgpack v0.5.4/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
281279
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
@@ -312,8 +310,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
312310
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
313311
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
314312
github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8=
315-
github.com/hashicorp/hcl/v2 v2.5.1 h1:5ytFZykUu2/4U59ogd2f+XZdi9+6oC/Tv5WzsH6fIDA=
316-
github.com/hashicorp/hcl/v2 v2.5.1/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
317313
github.com/hashicorp/hcl/v2 v2.6.0 h1:3krZOfGY6SziUXa6H9PJU6TyohHn7I+ARYnhbeNBz+o=
318314
github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
319315
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI=
@@ -596,8 +592,8 @@ github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d/go.mod h1:BST
596592
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
597593
github.com/tencentcloud/tencentcloud-sdk-go v3.0.82+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
598594
github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190808065407-f07404cefc8c/go.mod h1:wk2XFUg6egk4tSDNZtXeKfe2G6690UVyt163PuUxBZk=
599-
github.com/terraform-linters/tflint-plugin-sdk v0.1.2-0.20200621094814-c5fcef3ab795 h1:0R6dz5vI4qBkmXww0JfjfZFsxjr9EmaWeYXJFRdm6aU=
600-
github.com/terraform-linters/tflint-plugin-sdk v0.1.2-0.20200621094814-c5fcef3ab795/go.mod h1:MW/OviPYdTTq/aqzGkQW5vQ/zLF3F/LSrWTCTHFyt0o=
595+
github.com/terraform-linters/tflint-plugin-sdk v0.2.0 h1:kLNBJatWgylUL1Iieys3DnaCVHChTMEqft5BW7+NVyk=
596+
github.com/terraform-linters/tflint-plugin-sdk v0.2.0/go.mod h1:QoSqSV/8GSOrQy3OStK3EEdsA3yZm13My4BQcnx3Zic=
601597
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200604234259-3853d337c01a h1:ujCTSJYKH0UMgO2tNl9PD8imfkf3jQdvgE+4NOjp78k=
602598
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200604234259-3853d337c01a/go.mod h1:qu2Yl7WdzjH6gyX9SrG8vuSgqNlNRlP7hmCPXnPvFRc=
603599
github.com/terraform-providers/terraform-provider-openstack v1.15.0/go.mod h1:2aQ6n/BtChAl1y2S60vebhyJyZXBsuAI5G4+lHrT1Ew=
@@ -632,9 +628,8 @@ github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLE
632628
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
633629
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
634630
github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
635-
github.com/zclconf/go-cty v1.4.1/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
636-
github.com/zclconf/go-cty v1.5.0 h1:U0USwJxGTnUd+dT565f92paYOlRtd201pI7+ZGW36XY=
637-
github.com/zclconf/go-cty v1.5.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
631+
github.com/zclconf/go-cty v1.5.1 h1:oALUZX+aJeEBUe2a1+uD2+UTaYfEjnKFDEMRydkGvWE=
632+
github.com/zclconf/go-cty v1.5.1/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
638633
github.com/zclconf/go-cty-yaml v1.0.1 h1:up11wlgAaDvlAGENcFDnZgkn0qUJurso7k6EpURKNF8=
639634
github.com/zclconf/go-cty-yaml v1.0.1/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
640635
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=

plugin/encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
hcl "github.com/hashicorp/hcl/v2"
55
"github.com/hashicorp/terraform/configs"
66
"github.com/terraform-linters/tflint-plugin-sdk/terraform"
7-
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint"
7+
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
88
"github.com/terraform-linters/tflint/tflint"
99
)
1010

plugin/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package plugin
33
import (
44
hcl "github.com/hashicorp/hcl/v2"
55
"github.com/hashicorp/terraform/configs"
6-
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint"
6+
client "github.com/terraform-linters/tflint-plugin-sdk/tflint"
7+
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
78
"github.com/terraform-linters/tflint/tflint"
89
"github.com/zclconf/go-cty/cty"
910
)
@@ -77,7 +78,7 @@ func (s *Server) EvalExpr(req *tfplugin.EvalExprRequest, resp *tfplugin.EvalExpr
7778
val, err := s.runner.EvalExpr(expr, req.Ret, cty.Type{})
7879
if err != nil {
7980
if appErr, ok := err.(*tflint.Error); ok {
80-
err = tfplugin.Error(*appErr)
81+
err = client.Error(*appErr)
8182
}
8283
}
8384
*resp = tfplugin.EvalExprResponse{Val: val, Err: err}

plugin/server_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import (
77
"github.com/google/go-cmp/cmp/cmpopts"
88
hcl "github.com/hashicorp/hcl/v2"
99
"github.com/terraform-linters/tflint-plugin-sdk/terraform"
10-
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
client "github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
1112
"github.com/terraform-linters/tflint/tflint"
1213
"github.com/zclconf/go-cty/cty"
1314
)
@@ -288,9 +289,9 @@ func Test_EvalExpr_errors(t *testing.T) {
288289
t.Fatalf("Unexpected error occurred: %s", err)
289290
}
290291

291-
expected := tfplugin.Error{
292-
Code: tfplugin.UnknownValueError,
293-
Level: tfplugin.WarningLevel,
292+
expected := client.Error{
293+
Code: client.UnknownValueError,
294+
Level: client.WarningLevel,
294295
Message: "Unknown value found in template.tf:1; Please use environment variables or tfvars to set the value",
295296
Cause: nil,
296297
}
@@ -301,10 +302,10 @@ func Test_EvalExpr_errors(t *testing.T) {
301302

302303
func Test_EmitIssue(t *testing.T) {
303304
runner := tflint.TestRunner(t, map[string]string{})
304-
rule := &tfplugin.RuleObject{
305-
Data: &tfplugin.RuleObjectData{
305+
rule := &tfplugin.Rule{
306+
Data: &tfplugin.RuleObject{
306307
Name: "test_rule",
307-
Severity: tfplugin.ERROR,
308+
Severity: client.ERROR,
308309
},
309310
}
310311

plugin/stub-generator/main.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"bytes"
5+
"fmt"
46
"os"
57
"os/exec"
68
"path/filepath"
@@ -15,18 +17,10 @@ func main() {
1517
panic(err)
1618
}
1719

18-
if err := exec.Command("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "./sources/foo/main.go").Run(); err != nil {
19-
panic(err)
20-
}
21-
if err := exec.Command("cp", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "../test-fixtures/locals/.tflint.d/plugins/tflint-ruleset-foo"+fileExt()).Run(); err != nil {
22-
panic(err)
23-
}
24-
if err := exec.Command("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-bar"+fileExt(), "./sources/bar/main.go").Run(); err != nil {
25-
panic(err)
26-
}
27-
if err := exec.Command("go", "build", "-o", "../../integration/plugin/.tflint.d/plugins/tflint-ruleset-example"+fileExt(), "./sources/example/main.go").Run(); err != nil {
28-
panic(err)
29-
}
20+
execCommand("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "./sources/foo/main.go")
21+
execCommand("cp", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "../test-fixtures/locals/.tflint.d/plugins/tflint-ruleset-foo"+fileExt())
22+
execCommand("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-bar"+fileExt(), "./sources/bar/main.go")
23+
execCommand("go", "build", "-o", "../../integration/plugin/.tflint.d/plugins/tflint-ruleset-example"+fileExt(), "./sources/example/main.go")
3024
}
3125

3226
func fileExt() string {
@@ -35,3 +29,13 @@ func fileExt() string {
3529
}
3630
return ""
3731
}
32+
33+
func execCommand(command string, args ...string) {
34+
cmd := exec.Command(command, args...)
35+
var stderr bytes.Buffer
36+
cmd.Stderr = &stderr
37+
38+
if err := cmd.Run(); err != nil {
39+
panic(fmt.Sprintf("Failed to exec command: %s", stderr.String()))
40+
}
41+
}

plugin/stub-generator/sources/example/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ func (r *AwsInstanceExampleTypeRule) Check(runner tflint.Runner) error {
5555
err := runner.EvaluateExpr(attribute.Expr, &instanceType)
5656

5757
return runner.EnsureNoError(err, func() error {
58-
return runner.EmitIssue(
58+
return runner.EmitIssueOnExpr(
5959
r,
6060
fmt.Sprintf("instance type is %s", instanceType),
61-
attribute.Expr.Range(),
62-
tflint.Metadata{Expr: attribute.Expr},
61+
attribute.Expr,
6362
)
6463
})
6564
})

0 commit comments

Comments
 (0)