generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mapping aws_api_gateway_authorizer, aws_api_gateway_documentation_par…
…t, aws_api_gateway_domain_name (#220) * mapping aws_api_gateway_authorizer, aws_api_gateway_documentation_part, aws_api_gateway_domain_name, aws_api_gateway_method_settings https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_authorizer https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_documentation_part https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_domain_name https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_settings * fix hcl mappings * go generate * combining duplicate mappings
- Loading branch information
Showing
5 changed files
with
94 additions
and
12 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_api_gateway_domain_name_invalid_security_policy.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" | ||
) | ||
|
||
// AwsAPIGatewayDomainNameInvalidSecurityPolicyRule checks the pattern is valid | ||
type AwsAPIGatewayDomainNameInvalidSecurityPolicyRule struct { | ||
resourceType string | ||
attributeName string | ||
enum []string | ||
} | ||
|
||
// NewAwsAPIGatewayDomainNameInvalidSecurityPolicyRule returns new rule with default attributes | ||
func NewAwsAPIGatewayDomainNameInvalidSecurityPolicyRule() *AwsAPIGatewayDomainNameInvalidSecurityPolicyRule { | ||
return &AwsAPIGatewayDomainNameInvalidSecurityPolicyRule{ | ||
resourceType: "aws_api_gateway_domain_name", | ||
attributeName: "security_policy", | ||
enum: []string{ | ||
"TLS_1_0", | ||
"TLS_1_2", | ||
}, | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsAPIGatewayDomainNameInvalidSecurityPolicyRule) Name() string { | ||
return "aws_api_gateway_domain_name_invalid_security_policy" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsAPIGatewayDomainNameInvalidSecurityPolicyRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsAPIGatewayDomainNameInvalidSecurityPolicyRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsAPIGatewayDomainNameInvalidSecurityPolicyRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsAPIGatewayDomainNameInvalidSecurityPolicyRule) 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 security_policy`, 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
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
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