Skip to content

Commit

Permalink
Bump tflint-plugin-sdk for gRPC-based new plugin system
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Mar 27, 2022
1 parent befe5d3 commit ed3780b
Show file tree
Hide file tree
Showing 275 changed files with 7,445 additions and 2,067 deletions.
19 changes: 8 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,38 @@ go 1.17

require (
github.com/dave/dst v0.26.2
github.com/google/go-cmp v0.5.6
github.com/google/go-cmp v0.5.7
github.com/hashicorp/hcl/v2 v2.11.1
github.com/onsi/gomega v1.14.0 // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e
github.com/terraform-linters/tflint-plugin-sdk v0.9.1
github.com/terraform-linters/tflint-plugin-sdk v0.9.2-0.20220327063603-919fa2776c6c
)

require (
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/go-hclog v0.16.2 // indirect
github.com/hashicorp/go-plugin v1.4.2 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/go-hclog v1.2.0 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.9.0 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
google.golang.org/grpc v1.27.1 // indirect
google.golang.org/protobuf v1.26.0 // indirect
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
77 changes: 52 additions & 25 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ package apispec
import (
"fmt"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-azurerm/project"
)

// AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule checks the pattern is valid
type AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
Expand Down Expand Up @@ -40,7 +42,7 @@ func (r *AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule) Enable
}

// Severity returns the rule severity
func (r *AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule) Severity() string {
func (r *AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule) Severity() tflint.Severity {
return tflint.ERROR
}

Expand All @@ -51,25 +53,43 @@ func (r *AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule) Link()

// Check checks the pattern is valid
func (r *AzurermAnalysisServicesServerInvalidQuerypoolConnectionModeRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
err = runner.EnsureNoError(err, func() error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as querypool_connection_mode`, truncateLongMessage(val)),
attribute.Expr,
attribute.Expr.Range(),
)
}
return nil
})
})
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ package apispec
import (
"fmt"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-azurerm/project"
)

// AzurermApplicationInsightsAnalyticsItemInvalidScopeRule checks the pattern is valid
type AzurermApplicationInsightsAnalyticsItemInvalidScopeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
Expand Down Expand Up @@ -40,7 +42,7 @@ func (r *AzurermApplicationInsightsAnalyticsItemInvalidScopeRule) Enabled() bool
}

// Severity returns the rule severity
func (r *AzurermApplicationInsightsAnalyticsItemInvalidScopeRule) Severity() string {
func (r *AzurermApplicationInsightsAnalyticsItemInvalidScopeRule) Severity() tflint.Severity {
return tflint.ERROR
}

Expand All @@ -51,25 +53,43 @@ func (r *AzurermApplicationInsightsAnalyticsItemInvalidScopeRule) Link() string

// Check checks the pattern is valid
func (r *AzurermApplicationInsightsAnalyticsItemInvalidScopeRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
err = runner.EnsureNoError(err, func() error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as scope`, truncateLongMessage(val)),
attribute.Expr,
attribute.Expr.Range(),
)
}
return nil
})
})
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ package apispec
import (
"fmt"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-azurerm/project"
)

// AzurermApplicationInsightsAnalyticsItemInvalidTypeRule checks the pattern is valid
type AzurermApplicationInsightsAnalyticsItemInvalidTypeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
Expand Down Expand Up @@ -42,7 +44,7 @@ func (r *AzurermApplicationInsightsAnalyticsItemInvalidTypeRule) Enabled() bool
}

// Severity returns the rule severity
func (r *AzurermApplicationInsightsAnalyticsItemInvalidTypeRule) Severity() string {
func (r *AzurermApplicationInsightsAnalyticsItemInvalidTypeRule) Severity() tflint.Severity {
return tflint.ERROR
}

Expand All @@ -53,25 +55,43 @@ func (r *AzurermApplicationInsightsAnalyticsItemInvalidTypeRule) Link() string {

// Check checks the pattern is valid
func (r *AzurermApplicationInsightsAnalyticsItemInvalidTypeRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
err = runner.EnsureNoError(err, func() error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as type`, truncateLongMessage(val)),
attribute.Expr,
attribute.Expr.Range(),
)
}
return nil
})
})
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ package apispec
import (
"fmt"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-azurerm/project"
)

// AzurermApplicationInsightsWebTestInvalidKindRule checks the pattern is valid
type AzurermApplicationInsightsWebTestInvalidKindRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
Expand Down Expand Up @@ -40,7 +42,7 @@ func (r *AzurermApplicationInsightsWebTestInvalidKindRule) Enabled() bool {
}

// Severity returns the rule severity
func (r *AzurermApplicationInsightsWebTestInvalidKindRule) Severity() string {
func (r *AzurermApplicationInsightsWebTestInvalidKindRule) Severity() tflint.Severity {
return tflint.ERROR
}

Expand All @@ -51,25 +53,43 @@ func (r *AzurermApplicationInsightsWebTestInvalidKindRule) Link() string {

// Check checks the pattern is valid
func (r *AzurermApplicationInsightsWebTestInvalidKindRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
err = runner.EnsureNoError(err, func() error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as kind`, truncateLongMessage(val)),
attribute.Expr,
attribute.Expr.Range(),
)
}
return nil
})
})
if err != nil {
return err
}
}

return nil
}
Loading

0 comments on commit ed3780b

Please sign in to comment.