generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
395 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
rules/models/aws_ec2_availability_zone_group_invalid_opt_in_status.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule checks the pattern is valid | ||
type AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule struct { | ||
resourceType string | ||
attributeName string | ||
enum []string | ||
} | ||
|
||
// NewAwsEc2AvailabilityZoneGroupInvalidOptInStatusRule returns new rule with default attributes | ||
func NewAwsEc2AvailabilityZoneGroupInvalidOptInStatusRule() *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule { | ||
return &AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule{ | ||
resourceType: "aws_ec2_availability_zone_group", | ||
attributeName: "opt_in_status", | ||
enum: []string{ | ||
"opted-in", | ||
"not-opted-in", | ||
}, | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Name() string { | ||
return "aws_ec2_availability_zone_group_invalid_opt_in_status" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
found := false | ||
for _, item := range r.enum { | ||
if item == val { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" is an invalid value as opt_in_status`, truncateLongMessage(val)), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsEc2HostInvalidAutoPlacementRule checks the pattern is valid | ||
type AwsEc2HostInvalidAutoPlacementRule struct { | ||
resourceType string | ||
attributeName string | ||
enum []string | ||
} | ||
|
||
// NewAwsEc2HostInvalidAutoPlacementRule returns new rule with default attributes | ||
func NewAwsEc2HostInvalidAutoPlacementRule() *AwsEc2HostInvalidAutoPlacementRule { | ||
return &AwsEc2HostInvalidAutoPlacementRule{ | ||
resourceType: "aws_ec2_host", | ||
attributeName: "auto_placement", | ||
enum: []string{ | ||
"on", | ||
"off", | ||
}, | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsEc2HostInvalidAutoPlacementRule) Name() string { | ||
return "aws_ec2_host_invalid_auto_placement" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsEc2HostInvalidAutoPlacementRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsEc2HostInvalidAutoPlacementRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsEc2HostInvalidAutoPlacementRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsEc2HostInvalidAutoPlacementRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
found := false | ||
for _, item := range r.enum { | ||
if item == val { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" is an invalid value as auto_placement`, truncateLongMessage(val)), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsEc2HostInvalidHostRecoveryRule checks the pattern is valid | ||
type AwsEc2HostInvalidHostRecoveryRule struct { | ||
resourceType string | ||
attributeName string | ||
enum []string | ||
} | ||
|
||
// NewAwsEc2HostInvalidHostRecoveryRule returns new rule with default attributes | ||
func NewAwsEc2HostInvalidHostRecoveryRule() *AwsEc2HostInvalidHostRecoveryRule { | ||
return &AwsEc2HostInvalidHostRecoveryRule{ | ||
resourceType: "aws_ec2_host", | ||
attributeName: "host_recovery", | ||
enum: []string{ | ||
"on", | ||
"off", | ||
}, | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsEc2HostInvalidHostRecoveryRule) Name() string { | ||
return "aws_ec2_host_invalid_host_recovery" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsEc2HostInvalidHostRecoveryRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsEc2HostInvalidHostRecoveryRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsEc2HostInvalidHostRecoveryRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsEc2HostInvalidHostRecoveryRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
found := false | ||
for _, item := range r.enum { | ||
if item == val { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" is an invalid value as host_recovery`, truncateLongMessage(val)), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
77 changes: 77 additions & 0 deletions
77
rules/models/aws_ec2_traffic_mirror_filter_rule_invalid_rule_action.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule checks the pattern is valid | ||
type AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule struct { | ||
resourceType string | ||
attributeName string | ||
enum []string | ||
} | ||
|
||
// NewAwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule returns new rule with default attributes | ||
func NewAwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule() *AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule { | ||
return &AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule{ | ||
resourceType: "aws_ec2_traffic_mirror_filter_rule", | ||
attributeName: "rule_action", | ||
enum: []string{ | ||
"accept", | ||
"reject", | ||
}, | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule) Name() string { | ||
return "aws_ec2_traffic_mirror_filter_rule_invalid_rule_action" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsEc2TrafficMirrorFilterRuleInvalidRuleActionRule) Check(runner tflint.Runner) error { | ||
log.Printf("[TRACE] Check `%s` rule", r.Name()) | ||
|
||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
found := false | ||
for _, item := range r.enum { | ||
if item == val { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" is an invalid value as rule_action`, truncateLongMessage(val)), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
Oops, something went wrong.