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.
mapping aws_codestarconnections (#281)
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codestarconnections_connection https://github.com/aws/aws-sdk-go/blob/main/models/apis/codestar-connections/2019-12-01/api-2.json
- Loading branch information
Showing
9 changed files
with
522 additions
and
0 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
78 changes: 78 additions & 0 deletions
78
rules/models/aws_codestarconnections_connection_invalid_host_arn.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,78 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsCodestarconnectionsConnectionInvalidHostArnRule checks the pattern is valid | ||
type AwsCodestarconnectionsConnectionInvalidHostArnRule struct { | ||
resourceType string | ||
attributeName string | ||
max int | ||
pattern *regexp.Regexp | ||
} | ||
|
||
// NewAwsCodestarconnectionsConnectionInvalidHostArnRule returns new rule with default attributes | ||
func NewAwsCodestarconnectionsConnectionInvalidHostArnRule() *AwsCodestarconnectionsConnectionInvalidHostArnRule { | ||
return &AwsCodestarconnectionsConnectionInvalidHostArnRule{ | ||
resourceType: "aws_codestarconnections_connection", | ||
attributeName: "host_arn", | ||
max: 256, | ||
pattern: regexp.MustCompile(`^arn:aws(-[\w]+)*:codestar-connections:.+:[0-9]{12}:host\/.+$`), | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Name() string { | ||
return "aws_codestarconnections_connection_invalid_host_arn" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsCodestarconnectionsConnectionInvalidHostArnRule) 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 { | ||
if len(val) > r.max { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
"host_arn must be 256 characters or less", | ||
attribute.Expr, | ||
) | ||
} | ||
if !r.pattern.MatchString(val) { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^arn:aws(-[\w]+)*:codestar-connections:.+:[0-9]{12}:host\/.+$`), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
87 changes: 87 additions & 0 deletions
87
rules/models/aws_codestarconnections_connection_invalid_name.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,87 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsCodestarconnectionsConnectionInvalidNameRule checks the pattern is valid | ||
type AwsCodestarconnectionsConnectionInvalidNameRule struct { | ||
resourceType string | ||
attributeName string | ||
max int | ||
min int | ||
pattern *regexp.Regexp | ||
} | ||
|
||
// NewAwsCodestarconnectionsConnectionInvalidNameRule returns new rule with default attributes | ||
func NewAwsCodestarconnectionsConnectionInvalidNameRule() *AwsCodestarconnectionsConnectionInvalidNameRule { | ||
return &AwsCodestarconnectionsConnectionInvalidNameRule{ | ||
resourceType: "aws_codestarconnections_connection", | ||
attributeName: "name", | ||
max: 32, | ||
min: 1, | ||
pattern: regexp.MustCompile(`^[\s\S]*$`), | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Name() string { | ||
return "aws_codestarconnections_connection_invalid_name" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsCodestarconnectionsConnectionInvalidNameRule) 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 { | ||
if len(val) > r.max { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
"name must be 32 characters or less", | ||
attribute.Expr, | ||
) | ||
} | ||
if len(val) < r.min { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
"name must be 1 characters or higher", | ||
attribute.Expr, | ||
) | ||
} | ||
if !r.pattern.MatchString(val) { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[\s\S]*$`), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
78 changes: 78 additions & 0 deletions
78
rules/models/aws_codestarconnections_connection_invalid_provider_type.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,78 @@ | ||
// 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" | ||
) | ||
|
||
// AwsCodestarconnectionsConnectionInvalidProviderTypeRule checks the pattern is valid | ||
type AwsCodestarconnectionsConnectionInvalidProviderTypeRule struct { | ||
resourceType string | ||
attributeName string | ||
enum []string | ||
} | ||
|
||
// NewAwsCodestarconnectionsConnectionInvalidProviderTypeRule returns new rule with default attributes | ||
func NewAwsCodestarconnectionsConnectionInvalidProviderTypeRule() *AwsCodestarconnectionsConnectionInvalidProviderTypeRule { | ||
return &AwsCodestarconnectionsConnectionInvalidProviderTypeRule{ | ||
resourceType: "aws_codestarconnections_connection", | ||
attributeName: "provider_type", | ||
enum: []string{ | ||
"Bitbucket", | ||
"GitHub", | ||
"GitHubEnterpriseServer", | ||
}, | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Name() string { | ||
return "aws_codestarconnections_connection_invalid_provider_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsCodestarconnectionsConnectionInvalidProviderTypeRule) 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 provider_type`, 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,87 @@ | ||
// This file generated by `generator/`. DO NOT EDIT | ||
|
||
package models | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// AwsCodestarconnectionsHostInvalidNameRule checks the pattern is valid | ||
type AwsCodestarconnectionsHostInvalidNameRule struct { | ||
resourceType string | ||
attributeName string | ||
max int | ||
min int | ||
pattern *regexp.Regexp | ||
} | ||
|
||
// NewAwsCodestarconnectionsHostInvalidNameRule returns new rule with default attributes | ||
func NewAwsCodestarconnectionsHostInvalidNameRule() *AwsCodestarconnectionsHostInvalidNameRule { | ||
return &AwsCodestarconnectionsHostInvalidNameRule{ | ||
resourceType: "aws_codestarconnections_host", | ||
attributeName: "name", | ||
max: 64, | ||
min: 1, | ||
pattern: regexp.MustCompile(`^.*$`), | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *AwsCodestarconnectionsHostInvalidNameRule) Name() string { | ||
return "aws_codestarconnections_host_invalid_name" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *AwsCodestarconnectionsHostInvalidNameRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *AwsCodestarconnectionsHostInvalidNameRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *AwsCodestarconnectionsHostInvalidNameRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *AwsCodestarconnectionsHostInvalidNameRule) 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 { | ||
if len(val) > r.max { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
"name must be 64 characters or less", | ||
attribute.Expr, | ||
) | ||
} | ||
if len(val) < r.min { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
"name must be 1 characters or higher", | ||
attribute.Expr, | ||
) | ||
} | ||
if !r.pattern.MatchString(val) { | ||
runner.EmitIssueOnExpr( | ||
r, | ||
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^.*$`), | ||
attribute.Expr, | ||
) | ||
} | ||
return nil | ||
}) | ||
}) | ||
} |
Oops, something went wrong.