Skip to content

Commit

Permalink
go generate
Browse files Browse the repository at this point in the history
  • Loading branch information
PatMyron committed Dec 29, 2021
1 parent 7f47466 commit edf6dcb
Show file tree
Hide file tree
Showing 11 changed files with 712 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,15 @@ These rules enforce best practices and naming conventions:
|aws_config_remediation_configuration_invalid_config_rule_name||
|aws_config_remediation_configuration_invalid_target_id||
|aws_config_remediation_configuration_invalid_target_type||
|aws_connect_bot_association_invalid_instance_id||
|aws_connect_contact_flow_invalid_instance_id||
|aws_connect_contact_flow_invalid_type||
|aws_connect_hours_of_operation_invalid_description||
|aws_connect_hours_of_operation_invalid_instance_id||
|aws_connect_hours_of_operation_invalid_name||
|aws_connect_instance_invalid_identity_management_type||
|aws_connect_lambda_function_association_invalid_function_arn||
|aws_connect_lambda_function_association_invalid_instance_id||
|aws_cur_report_definition_invalid_compression||
|aws_cur_report_definition_invalid_format||
|aws_cur_report_definition_invalid_report_name||
Expand Down
76 changes: 76 additions & 0 deletions rules/models/aws_connect_bot_association_invalid_instance_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsConnectBotAssociationInvalidInstanceIDRule checks the pattern is valid
type AwsConnectBotAssociationInvalidInstanceIDRule struct {
resourceType string
attributeName string
max int
min int
}

// NewAwsConnectBotAssociationInvalidInstanceIDRule returns new rule with default attributes
func NewAwsConnectBotAssociationInvalidInstanceIDRule() *AwsConnectBotAssociationInvalidInstanceIDRule {
return &AwsConnectBotAssociationInvalidInstanceIDRule{
resourceType: "aws_connect_bot_association",
attributeName: "instance_id",
max: 100,
min: 1,
}
}

// Name returns the rule name
func (r *AwsConnectBotAssociationInvalidInstanceIDRule) Name() string {
return "aws_connect_bot_association_invalid_instance_id"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsConnectBotAssociationInvalidInstanceIDRule) Enabled() bool {
return true
}

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

// Link returns the rule reference link
func (r *AwsConnectBotAssociationInvalidInstanceIDRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsConnectBotAssociationInvalidInstanceIDRule) 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,
"instance_id must be 100 characters or less",
attribute.Expr,
)
}
if len(val) < r.min {
runner.EmitIssueOnExpr(
r,
"instance_id must be 1 characters or higher",
attribute.Expr,
)
}
return nil
})
})
}
76 changes: 76 additions & 0 deletions rules/models/aws_connect_contact_flow_invalid_instance_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsConnectContactFlowInvalidInstanceIDRule checks the pattern is valid
type AwsConnectContactFlowInvalidInstanceIDRule struct {
resourceType string
attributeName string
max int
min int
}

// NewAwsConnectContactFlowInvalidInstanceIDRule returns new rule with default attributes
func NewAwsConnectContactFlowInvalidInstanceIDRule() *AwsConnectContactFlowInvalidInstanceIDRule {
return &AwsConnectContactFlowInvalidInstanceIDRule{
resourceType: "aws_connect_contact_flow",
attributeName: "instance_id",
max: 100,
min: 1,
}
}

// Name returns the rule name
func (r *AwsConnectContactFlowInvalidInstanceIDRule) Name() string {
return "aws_connect_contact_flow_invalid_instance_id"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsConnectContactFlowInvalidInstanceIDRule) Enabled() bool {
return true
}

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

// Link returns the rule reference link
func (r *AwsConnectContactFlowInvalidInstanceIDRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsConnectContactFlowInvalidInstanceIDRule) 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,
"instance_id must be 100 characters or less",
attribute.Expr,
)
}
if len(val) < r.min {
runner.EmitIssueOnExpr(
r,
"instance_id must be 1 characters or higher",
attribute.Expr,
)
}
return nil
})
})
}
84 changes: 84 additions & 0 deletions rules/models/aws_connect_contact_flow_invalid_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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"
)

// AwsConnectContactFlowInvalidTypeRule checks the pattern is valid
type AwsConnectContactFlowInvalidTypeRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsConnectContactFlowInvalidTypeRule returns new rule with default attributes
func NewAwsConnectContactFlowInvalidTypeRule() *AwsConnectContactFlowInvalidTypeRule {
return &AwsConnectContactFlowInvalidTypeRule{
resourceType: "aws_connect_contact_flow",
attributeName: "type",
enum: []string{
"CONTACT_FLOW",
"CUSTOMER_QUEUE",
"CUSTOMER_HOLD",
"CUSTOMER_WHISPER",
"AGENT_HOLD",
"AGENT_WHISPER",
"OUTBOUND_WHISPER",
"AGENT_TRANSFER",
"QUEUE_TRANSFER",
},
}
}

// Name returns the rule name
func (r *AwsConnectContactFlowInvalidTypeRule) Name() string {
return "aws_connect_contact_flow_invalid_type"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsConnectContactFlowInvalidTypeRule) Enabled() bool {
return true
}

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

// Link returns the rule reference link
func (r *AwsConnectContactFlowInvalidTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsConnectContactFlowInvalidTypeRule) 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 type`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
76 changes: 76 additions & 0 deletions rules/models/aws_connect_hours_of_operation_invalid_description.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsConnectHoursOfOperationInvalidDescriptionRule checks the pattern is valid
type AwsConnectHoursOfOperationInvalidDescriptionRule struct {
resourceType string
attributeName string
max int
min int
}

// NewAwsConnectHoursOfOperationInvalidDescriptionRule returns new rule with default attributes
func NewAwsConnectHoursOfOperationInvalidDescriptionRule() *AwsConnectHoursOfOperationInvalidDescriptionRule {
return &AwsConnectHoursOfOperationInvalidDescriptionRule{
resourceType: "aws_connect_hours_of_operation",
attributeName: "description",
max: 250,
min: 1,
}
}

// Name returns the rule name
func (r *AwsConnectHoursOfOperationInvalidDescriptionRule) Name() string {
return "aws_connect_hours_of_operation_invalid_description"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsConnectHoursOfOperationInvalidDescriptionRule) Enabled() bool {
return true
}

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

// Link returns the rule reference link
func (r *AwsConnectHoursOfOperationInvalidDescriptionRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsConnectHoursOfOperationInvalidDescriptionRule) 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,
"description must be 250 characters or less",
attribute.Expr,
)
}
if len(val) < r.min {
runner.EmitIssueOnExpr(
r,
"description must be 1 characters or higher",
attribute.Expr,
)
}
return nil
})
})
}
Loading

0 comments on commit edf6dcb

Please sign in to comment.