Skip to content

Commit

Permalink
Bump tflint-plugin-sdk to v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Jun 27, 2020
1 parent efa6772 commit a706fdb
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ require (
github.com/sourcegraph/go-lsp v0.0.0-20181119182933-0c7d621186c1
github.com/sourcegraph/jsonrpc2 v0.0.0-20190106185902-35a74f039c6a
github.com/spf13/afero v1.3.0
github.com/terraform-linters/tflint-plugin-sdk v0.1.2-0.20200621094814-c5fcef3ab795
github.com/terraform-linters/tflint-plugin-sdk v0.2.0
github.com/terraform-providers/terraform-provider-aws v2.65.0+incompatible
github.com/zclconf/go-cty v1.5.0
github.com/zclconf/go-cty v1.5.1
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
)

Expand Down
17 changes: 6 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
Expand Down Expand Up @@ -274,8 +272,8 @@ github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f h1:Yv9YzBlAETjy
github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-hclog v0.10.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v0.13.0 h1:Do32YnDMnq7v7FU50AgH+1ExKCOkl9HBxvSI1JWr+rA=
github.com/hashicorp/go-hclog v0.13.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU=
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-immutable-radix v0.0.0-20180129170900-7f3cd4390caa/go.mod h1:6ij3Z20p+OhOkCSrA0gImAWoHYQRGbnlcuk6XYTiaRw=
github.com/hashicorp/go-msgpack v0.5.4/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
Expand Down Expand Up @@ -312,8 +310,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8=
github.com/hashicorp/hcl/v2 v2.5.1 h1:5ytFZykUu2/4U59ogd2f+XZdi9+6oC/Tv5WzsH6fIDA=
github.com/hashicorp/hcl/v2 v2.5.1/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
github.com/hashicorp/hcl/v2 v2.6.0 h1:3krZOfGY6SziUXa6H9PJU6TyohHn7I+ARYnhbeNBz+o=
github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI=
Expand Down Expand Up @@ -596,8 +592,8 @@ github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d/go.mod h1:BST
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
github.com/tencentcloud/tencentcloud-sdk-go v3.0.82+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190808065407-f07404cefc8c/go.mod h1:wk2XFUg6egk4tSDNZtXeKfe2G6690UVyt163PuUxBZk=
github.com/terraform-linters/tflint-plugin-sdk v0.1.2-0.20200621094814-c5fcef3ab795 h1:0R6dz5vI4qBkmXww0JfjfZFsxjr9EmaWeYXJFRdm6aU=
github.com/terraform-linters/tflint-plugin-sdk v0.1.2-0.20200621094814-c5fcef3ab795/go.mod h1:MW/OviPYdTTq/aqzGkQW5vQ/zLF3F/LSrWTCTHFyt0o=
github.com/terraform-linters/tflint-plugin-sdk v0.2.0 h1:kLNBJatWgylUL1Iieys3DnaCVHChTMEqft5BW7+NVyk=
github.com/terraform-linters/tflint-plugin-sdk v0.2.0/go.mod h1:QoSqSV/8GSOrQy3OStK3EEdsA3yZm13My4BQcnx3Zic=
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200604234259-3853d337c01a h1:ujCTSJYKH0UMgO2tNl9PD8imfkf3jQdvgE+4NOjp78k=
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200604234259-3853d337c01a/go.mod h1:qu2Yl7WdzjH6gyX9SrG8vuSgqNlNRlP7hmCPXnPvFRc=
github.com/terraform-providers/terraform-provider-openstack v1.15.0/go.mod h1:2aQ6n/BtChAl1y2S60vebhyJyZXBsuAI5G4+lHrT1Ew=
Expand Down Expand Up @@ -632,9 +628,8 @@ github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLE
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.4.1/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
github.com/zclconf/go-cty v1.5.0 h1:U0USwJxGTnUd+dT565f92paYOlRtd201pI7+ZGW36XY=
github.com/zclconf/go-cty v1.5.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
github.com/zclconf/go-cty v1.5.1 h1:oALUZX+aJeEBUe2a1+uD2+UTaYfEjnKFDEMRydkGvWE=
github.com/zclconf/go-cty v1.5.1/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
github.com/zclconf/go-cty-yaml v1.0.1 h1:up11wlgAaDvlAGENcFDnZgkn0qUJurso7k6EpURKNF8=
github.com/zclconf/go-cty-yaml v1.0.1/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down
2 changes: 1 addition & 1 deletion plugin/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform/configs"
"github.com/terraform-linters/tflint-plugin-sdk/terraform"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
"github.com/terraform-linters/tflint/tflint"
)

Expand Down
5 changes: 3 additions & 2 deletions plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package plugin
import (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform/configs"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint"
client "github.com/terraform-linters/tflint-plugin-sdk/tflint"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
"github.com/terraform-linters/tflint/tflint"
"github.com/zclconf/go-cty/cty"
)
Expand Down Expand Up @@ -77,7 +78,7 @@ func (s *Server) EvalExpr(req *tfplugin.EvalExprRequest, resp *tfplugin.EvalExpr
val, err := s.runner.EvalExpr(expr, req.Ret, cty.Type{})
if err != nil {
if appErr, ok := err.(*tflint.Error); ok {
err = tfplugin.Error(*appErr)
err = client.Error(*appErr)
}
}
*resp = tfplugin.EvalExprResponse{Val: val, Err: err}
Expand Down
15 changes: 8 additions & 7 deletions plugin/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/terraform"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint"
client "github.com/terraform-linters/tflint-plugin-sdk/tflint"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
"github.com/terraform-linters/tflint/tflint"
"github.com/zclconf/go-cty/cty"
)
Expand Down Expand Up @@ -288,9 +289,9 @@ func Test_EvalExpr_errors(t *testing.T) {
t.Fatalf("Unexpected error occurred: %s", err)
}

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

func Test_EmitIssue(t *testing.T) {
runner := tflint.TestRunner(t, map[string]string{})
rule := &tfplugin.RuleObject{
Data: &tfplugin.RuleObjectData{
rule := &tfplugin.Rule{
Data: &tfplugin.RuleObject{
Name: "test_rule",
Severity: tfplugin.ERROR,
Severity: client.ERROR,
},
}

Expand Down
28 changes: 16 additions & 12 deletions plugin/stub-generator/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"bytes"
"fmt"
"os"
"os/exec"
"path/filepath"
Expand All @@ -15,18 +17,10 @@ func main() {
panic(err)
}

if err := exec.Command("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "./sources/foo/main.go").Run(); err != nil {
panic(err)
}
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 {
panic(err)
}
if err := exec.Command("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-bar"+fileExt(), "./sources/bar/main.go").Run(); err != nil {
panic(err)
}
if err := exec.Command("go", "build", "-o", "../../integration/plugin/.tflint.d/plugins/tflint-ruleset-example"+fileExt(), "./sources/example/main.go").Run(); err != nil {
panic(err)
}
execCommand("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "./sources/foo/main.go")
execCommand("cp", "../test-fixtures/plugins/tflint-ruleset-foo"+fileExt(), "../test-fixtures/locals/.tflint.d/plugins/tflint-ruleset-foo"+fileExt())
execCommand("go", "build", "-o", "../test-fixtures/plugins/tflint-ruleset-bar"+fileExt(), "./sources/bar/main.go")
execCommand("go", "build", "-o", "../../integration/plugin/.tflint.d/plugins/tflint-ruleset-example"+fileExt(), "./sources/example/main.go")
}

func fileExt() string {
Expand All @@ -35,3 +29,13 @@ func fileExt() string {
}
return ""
}

func execCommand(command string, args ...string) {
cmd := exec.Command(command, args...)
var stderr bytes.Buffer
cmd.Stderr = &stderr

if err := cmd.Run(); err != nil {
panic(fmt.Sprintf("Failed to exec command: %s", stderr.String()))
}
}
5 changes: 2 additions & 3 deletions plugin/stub-generator/sources/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ func (r *AwsInstanceExampleTypeRule) Check(runner tflint.Runner) error {
err := runner.EvaluateExpr(attribute.Expr, &instanceType)

return runner.EnsureNoError(err, func() error {
return runner.EmitIssue(
return runner.EmitIssueOnExpr(
r,
fmt.Sprintf("instance type is %s", instanceType),
attribute.Expr.Range(),
tflint.Metadata{Expr: attribute.Expr},
attribute.Expr,
)
})
})
Expand Down

0 comments on commit a706fdb

Please sign in to comment.