Skip to content

8 files changed

+403
-0
lines changed

docs/rules/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ These rules enforce best practices and naming conventions:
356356
|aws_codebuild_project_invalid_description||
357357
|aws_codebuild_source_credential_invalid_auth_type||
358358
|aws_codebuild_source_credential_invalid_server_type||
359+
|aws_codecommit_approval_rule_template_association_invalid_approval_rule_template_name||
360+
|aws_codecommit_approval_rule_template_association_invalid_repository_name||
361+
|aws_codecommit_approval_rule_template_invalid_content||
362+
|aws_codecommit_approval_rule_template_invalid_description||
363+
|aws_codecommit_approval_rule_template_invalid_name||
359364
|aws_codecommit_repository_invalid_default_branch||
360365
|aws_codecommit_repository_invalid_description||
361366
|aws_codecommit_repository_invalid_repository_name||
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule checks the pattern is valid
13+
type AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule returns new rule with default attributes
21+
func NewAwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule() *AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule {
22+
return &AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule{
23+
resourceType: "aws_codecommit_approval_rule_template_association",
24+
attributeName: "approval_rule_template_name",
25+
max: 100,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule) Name() string {
32+
return "aws_codecommit_approval_rule_template_association_invalid_approval_rule_template_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidApprovalRuleTemplateNameRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"approval_rule_template_name must be 100 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"approval_rule_template_name must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule checks the pattern is valid
15+
type AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule returns new rule with default attributes
24+
func NewAwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule() *AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule {
25+
return &AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule{
26+
resourceType: "aws_codecommit_approval_rule_template_association",
27+
attributeName: "repository_name",
28+
max: 100,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[\w\.-]+$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule) Name() string {
36+
return "aws_codecommit_approval_rule_template_association_invalid_repository_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsCodecommitApprovalRuleTemplateAssociationInvalidRepositoryNameRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"repository_name must be 100 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"repository_name must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[\w\.-]+$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsCodecommitApprovalRuleTemplateInvalidContentRule checks the pattern is valid
13+
type AwsCodecommitApprovalRuleTemplateInvalidContentRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsCodecommitApprovalRuleTemplateInvalidContentRule returns new rule with default attributes
21+
func NewAwsCodecommitApprovalRuleTemplateInvalidContentRule() *AwsCodecommitApprovalRuleTemplateInvalidContentRule {
22+
return &AwsCodecommitApprovalRuleTemplateInvalidContentRule{
23+
resourceType: "aws_codecommit_approval_rule_template",
24+
attributeName: "content",
25+
max: 3000,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsCodecommitApprovalRuleTemplateInvalidContentRule) Name() string {
32+
return "aws_codecommit_approval_rule_template_invalid_content"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsCodecommitApprovalRuleTemplateInvalidContentRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsCodecommitApprovalRuleTemplateInvalidContentRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsCodecommitApprovalRuleTemplateInvalidContentRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsCodecommitApprovalRuleTemplateInvalidContentRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"content must be 3000 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"content must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule checks the pattern is valid
13+
type AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
}
18+
19+
// NewAwsCodecommitApprovalRuleTemplateInvalidDescriptionRule returns new rule with default attributes
20+
func NewAwsCodecommitApprovalRuleTemplateInvalidDescriptionRule() *AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule {
21+
return &AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule{
22+
resourceType: "aws_codecommit_approval_rule_template",
23+
attributeName: "description",
24+
max: 1000,
25+
}
26+
}
27+
28+
// Name returns the rule name
29+
func (r *AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule) Name() string {
30+
return "aws_codecommit_approval_rule_template_invalid_description"
31+
}
32+
33+
// Enabled returns whether the rule is enabled by default
34+
func (r *AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule) Enabled() bool {
35+
return true
36+
}
37+
38+
// Severity returns the rule severity
39+
func (r *AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule) Severity() string {
40+
return tflint.ERROR
41+
}
42+
43+
// Link returns the rule reference link
44+
func (r *AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule) Link() string {
45+
return ""
46+
}
47+
48+
// Check checks the pattern is valid
49+
func (r *AwsCodecommitApprovalRuleTemplateInvalidDescriptionRule) Check(runner tflint.Runner) error {
50+
log.Printf("[TRACE] Check `%s` rule", r.Name())
51+
52+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
53+
var val string
54+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
55+
56+
return runner.EnsureNoError(err, func() error {
57+
if len(val) > r.max {
58+
runner.EmitIssueOnExpr(
59+
r,
60+
"description must be 1000 characters or less",
61+
attribute.Expr,
62+
)
63+
}
64+
return nil
65+
})
66+
})
67+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsCodecommitApprovalRuleTemplateInvalidNameRule checks the pattern is valid
13+
type AwsCodecommitApprovalRuleTemplateInvalidNameRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsCodecommitApprovalRuleTemplateInvalidNameRule returns new rule with default attributes
21+
func NewAwsCodecommitApprovalRuleTemplateInvalidNameRule() *AwsCodecommitApprovalRuleTemplateInvalidNameRule {
22+
return &AwsCodecommitApprovalRuleTemplateInvalidNameRule{
23+
resourceType: "aws_codecommit_approval_rule_template",
24+
attributeName: "name",
25+
max: 100,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsCodecommitApprovalRuleTemplateInvalidNameRule) Name() string {
32+
return "aws_codecommit_approval_rule_template_invalid_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsCodecommitApprovalRuleTemplateInvalidNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsCodecommitApprovalRuleTemplateInvalidNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsCodecommitApprovalRuleTemplateInvalidNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsCodecommitApprovalRuleTemplateInvalidNameRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"name must be 100 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"name must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}

0 commit comments

Comments
 (0)