From 2f13468388c6e16ad898b4509c5c0590cf1db251 Mon Sep 17 00:00:00 2001 From: Pat Myron Date: Sat, 25 Dec 2021 19:28:44 -0800 Subject: [PATCH 1/2] mapping servicecatalog https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/servicecatalog_budget_resource_association https://github.com/aws/aws-sdk-go/blob/main/models/apis/servicecatalog/2015-12-10/api-2.json --- rules/models/mappings/servicecatalog.hcl | 89 ++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/rules/models/mappings/servicecatalog.hcl b/rules/models/mappings/servicecatalog.hcl index 83c06e52..2925f774 100644 --- a/rules/models/mappings/servicecatalog.hcl +++ b/rules/models/mappings/servicecatalog.hcl @@ -1,8 +1,97 @@ import = "aws-sdk-go/models/apis/servicecatalog/2015-12-10/api-2.json" +mapping "aws_servicecatalog_budget_resource_association" { + budget_name = BudgetName + resource_id = Id +} + +mapping "aws_servicecatalog_constraint" { + parameters = ConstraintParameters + portfolio_id = Id + product_id = Id + type = ConstraintType + accept_language = AcceptLanguage + description = ConstraintDescription +} + mapping "aws_servicecatalog_portfolio" { name = PortfolioDisplayName description = PortfolioDescription provider_name = ProviderName tags = AddTags } + +mapping "aws_servicecatalog_portfolio_share" { + portfolio_id = Id + principal_id = Id + type = PortfolioShareType + accept_language = AcceptLanguage +} + +mapping "aws_servicecatalog_principal_portfolio_association" { + portfolio_id = Id + principal_arn = PrincipalARN + accept_language = AcceptLanguage + principal_type = PrincipalType +} + +mapping "aws_servicecatalog_product" { + name = ProductViewName + owner = ProductViewOwner + provisioning_artifact_parameters = ProvisioningArtifactProperties + type = ProductType + accept_language = AcceptLanguage + description = ProductViewShortDescription + distributor = ProductViewOwner + support_description = SupportDescription + support_email = SupportEmail + support_url = SupportUrl + tags = AddTags +} + +mapping "aws_servicecatalog_product_portfolio_association" { + portfolio_id = Id + product_id = Id + accept_language = AcceptLanguage + source_portfolio_id = Id +} + +mapping "aws_servicecatalog_provisioned_product" { + name = ProvisionedProductName + accept_language = AcceptLanguage + notification_arns = NotificationArns + path_id = Id + path_name = PortfolioDisplayName + product_id = Id + product_name = ProductViewName + provisioning_artifact_id = Id + provisioning_artifact_name = ProvisioningArtifactName + provisioning_parameters = ProvisioningParameters +} + +mapping "aws_servicecatalog_provisioning_artifact" { + product_id = Id + accept_language = AcceptLanguage + description = ProvisioningArtifactDescription + disable_template_validation = DisableTemplateValidation + guidance = ProvisioningArtifactGuidance + name = ProvisioningArtifactName + type = ProvisioningArtifactType +} + +mapping "aws_servicecatalog_service_action" { + definition = ServiceActionDefinitionMap + name = ServiceActionName + accept_language = AcceptLanguage + description = ServiceActionDescription +} + +mapping "aws_servicecatalog_tag_option" { + key = TagOptionKey + value = TagOptionValue +} + +mapping "aws_servicecatalog_tag_option_resource_association" { + resource_id = ResourceId + tag_option_id = TagOptionId +} From 01c410c7c77660bd22acc7a533c9d9eeda780bd8 Mon Sep 17 00:00:00 2001 From: Pat Myron Date: Sat, 25 Dec 2021 22:29:16 -0500 Subject: [PATCH 2/2] go generate --- docs/rules/README.md | 48 ++++++++++ ...esource_association_invalid_budget_name.go | 76 ++++++++++++++++ ...esource_association_invalid_resource_id.go | 87 +++++++++++++++++++ ...alog_constraint_invalid_accept_language.go | 67 ++++++++++++++ ...ecatalog_constraint_invalid_description.go | 67 ++++++++++++++ ...catalog_constraint_invalid_portfolio_id.go | 87 +++++++++++++++++++ ...cecatalog_constraint_invalid_product_id.go | 87 +++++++++++++++++++ ..._servicecatalog_constraint_invalid_type.go | 76 ++++++++++++++++ ...portfolio_share_invalid_accept_language.go | 67 ++++++++++++++ ...og_portfolio_share_invalid_portfolio_id.go | 87 +++++++++++++++++++ ...og_portfolio_share_invalid_principal_id.go | 87 +++++++++++++++++++ ...icecatalog_portfolio_share_invalid_type.go | 78 +++++++++++++++++ ...lio_association_invalid_accept_language.go | 67 ++++++++++++++ ...tfolio_association_invalid_portfolio_id.go | 87 +++++++++++++++++++ ...folio_association_invalid_principal_arn.go | 76 ++++++++++++++++ ...olio_association_invalid_principal_type.go | 76 ++++++++++++++++ ...catalog_product_invalid_accept_language.go | 67 ++++++++++++++ ...vicecatalog_product_invalid_description.go | 67 ++++++++++++++ ...vicecatalog_product_invalid_distributor.go | 67 ++++++++++++++ ...aws_servicecatalog_product_invalid_name.go | 67 ++++++++++++++ ...ws_servicecatalog_product_invalid_owner.go | 67 ++++++++++++++ ...log_product_invalid_support_description.go | 67 ++++++++++++++ ...cecatalog_product_invalid_support_email.go | 67 ++++++++++++++ ...vicecatalog_product_invalid_support_url.go | 67 ++++++++++++++ ...aws_servicecatalog_product_invalid_type.go | 86 ++++++++++++++++++ ...lio_association_invalid_accept_language.go | 67 ++++++++++++++ ...tfolio_association_invalid_portfolio_id.go | 87 +++++++++++++++++++ ...ortfolio_association_invalid_product_id.go | 87 +++++++++++++++++++ ...association_invalid_source_portfolio_id.go | 87 +++++++++++++++++++ ...isioned_product_invalid_accept_language.go | 67 ++++++++++++++ ...atalog_provisioned_product_invalid_name.go | 87 +++++++++++++++++++ ...log_provisioned_product_invalid_path_id.go | 87 +++++++++++++++++++ ...g_provisioned_product_invalid_path_name.go | 76 ++++++++++++++++ ..._provisioned_product_invalid_product_id.go | 87 +++++++++++++++++++ ...rovisioned_product_invalid_product_name.go | 67 ++++++++++++++ ...roduct_invalid_provisioning_artifact_id.go | 87 +++++++++++++++++++ ...duct_invalid_provisioning_artifact_name.go | 67 ++++++++++++++ ...ioning_artifact_invalid_accept_language.go | 67 ++++++++++++++ ...ovisioning_artifact_invalid_description.go | 67 ++++++++++++++ ..._provisioning_artifact_invalid_guidance.go | 77 ++++++++++++++++ ...alog_provisioning_artifact_invalid_name.go | 67 ++++++++++++++ ...rovisioning_artifact_invalid_product_id.go | 87 +++++++++++++++++++ ...alog_provisioning_artifact_invalid_type.go | 78 +++++++++++++++++ ..._service_action_invalid_accept_language.go | 67 ++++++++++++++ ...alog_service_action_invalid_description.go | 67 ++++++++++++++ ...vicecatalog_service_action_invalid_name.go | 87 +++++++++++++++++++ ...s_servicecatalog_tag_option_invalid_key.go | 87 +++++++++++++++++++ ...servicecatalog_tag_option_invalid_value.go | 87 +++++++++++++++++++ ...ource_association_invalid_tag_option_id.go | 76 ++++++++++++++++ rules/models/provider.go | 48 ++++++++++ 50 files changed, 3757 insertions(+) create mode 100644 rules/models/aws_servicecatalog_budget_resource_association_invalid_budget_name.go create mode 100644 rules/models/aws_servicecatalog_budget_resource_association_invalid_resource_id.go create mode 100644 rules/models/aws_servicecatalog_constraint_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_constraint_invalid_description.go create mode 100644 rules/models/aws_servicecatalog_constraint_invalid_portfolio_id.go create mode 100644 rules/models/aws_servicecatalog_constraint_invalid_product_id.go create mode 100644 rules/models/aws_servicecatalog_constraint_invalid_type.go create mode 100644 rules/models/aws_servicecatalog_portfolio_share_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_portfolio_share_invalid_portfolio_id.go create mode 100644 rules/models/aws_servicecatalog_portfolio_share_invalid_principal_id.go create mode 100644 rules/models/aws_servicecatalog_portfolio_share_invalid_type.go create mode 100644 rules/models/aws_servicecatalog_principal_portfolio_association_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id.go create mode 100644 rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_arn.go create mode 100644 rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_type.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_description.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_distributor.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_name.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_owner.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_support_description.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_support_email.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_support_url.go create mode 100644 rules/models/aws_servicecatalog_product_invalid_type.go create mode 100644 rules/models/aws_servicecatalog_product_portfolio_association_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_product_portfolio_association_invalid_portfolio_id.go create mode 100644 rules/models/aws_servicecatalog_product_portfolio_association_invalid_product_id.go create mode 100644 rules/models/aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_name.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_path_id.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_path_name.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_product_id.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_product_name.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id.go create mode 100644 rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name.go create mode 100644 rules/models/aws_servicecatalog_provisioning_artifact_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_provisioning_artifact_invalid_description.go create mode 100644 rules/models/aws_servicecatalog_provisioning_artifact_invalid_guidance.go create mode 100644 rules/models/aws_servicecatalog_provisioning_artifact_invalid_name.go create mode 100644 rules/models/aws_servicecatalog_provisioning_artifact_invalid_product_id.go create mode 100644 rules/models/aws_servicecatalog_provisioning_artifact_invalid_type.go create mode 100644 rules/models/aws_servicecatalog_service_action_invalid_accept_language.go create mode 100644 rules/models/aws_servicecatalog_service_action_invalid_description.go create mode 100644 rules/models/aws_servicecatalog_service_action_invalid_name.go create mode 100644 rules/models/aws_servicecatalog_tag_option_invalid_key.go create mode 100644 rules/models/aws_servicecatalog_tag_option_invalid_value.go create mode 100644 rules/models/aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id.go diff --git a/docs/rules/README.md b/docs/rules/README.md index 9072f3e3..248f5200 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -892,9 +892,57 @@ These rules enforce best practices and naming conventions: |aws_service_discovery_public_dns_namespace_invalid_description|✔| |aws_service_discovery_public_dns_namespace_invalid_name|✔| |aws_service_discovery_service_invalid_description|✔| +|aws_servicecatalog_budget_resource_association_invalid_budget_name|✔| +|aws_servicecatalog_budget_resource_association_invalid_resource_id|✔| +|aws_servicecatalog_constraint_invalid_accept_language|✔| +|aws_servicecatalog_constraint_invalid_description|✔| +|aws_servicecatalog_constraint_invalid_portfolio_id|✔| +|aws_servicecatalog_constraint_invalid_product_id|✔| +|aws_servicecatalog_constraint_invalid_type|✔| |aws_servicecatalog_portfolio_invalid_description|✔| |aws_servicecatalog_portfolio_invalid_name|✔| |aws_servicecatalog_portfolio_invalid_provider_name|✔| +|aws_servicecatalog_portfolio_share_invalid_accept_language|✔| +|aws_servicecatalog_portfolio_share_invalid_portfolio_id|✔| +|aws_servicecatalog_portfolio_share_invalid_principal_id|✔| +|aws_servicecatalog_portfolio_share_invalid_type|✔| +|aws_servicecatalog_principal_portfolio_association_invalid_accept_language|✔| +|aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id|✔| +|aws_servicecatalog_principal_portfolio_association_invalid_principal_arn|✔| +|aws_servicecatalog_principal_portfolio_association_invalid_principal_type|✔| +|aws_servicecatalog_product_invalid_accept_language|✔| +|aws_servicecatalog_product_invalid_description|✔| +|aws_servicecatalog_product_invalid_distributor|✔| +|aws_servicecatalog_product_invalid_name|✔| +|aws_servicecatalog_product_invalid_owner|✔| +|aws_servicecatalog_product_invalid_support_description|✔| +|aws_servicecatalog_product_invalid_support_email|✔| +|aws_servicecatalog_product_invalid_support_url|✔| +|aws_servicecatalog_product_invalid_type|✔| +|aws_servicecatalog_product_portfolio_association_invalid_accept_language|✔| +|aws_servicecatalog_product_portfolio_association_invalid_portfolio_id|✔| +|aws_servicecatalog_product_portfolio_association_invalid_product_id|✔| +|aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id|✔| +|aws_servicecatalog_provisioned_product_invalid_accept_language|✔| +|aws_servicecatalog_provisioned_product_invalid_name|✔| +|aws_servicecatalog_provisioned_product_invalid_path_id|✔| +|aws_servicecatalog_provisioned_product_invalid_path_name|✔| +|aws_servicecatalog_provisioned_product_invalid_product_id|✔| +|aws_servicecatalog_provisioned_product_invalid_product_name|✔| +|aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id|✔| +|aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name|✔| +|aws_servicecatalog_provisioning_artifact_invalid_accept_language|✔| +|aws_servicecatalog_provisioning_artifact_invalid_description|✔| +|aws_servicecatalog_provisioning_artifact_invalid_guidance|✔| +|aws_servicecatalog_provisioning_artifact_invalid_name|✔| +|aws_servicecatalog_provisioning_artifact_invalid_product_id|✔| +|aws_servicecatalog_provisioning_artifact_invalid_type|✔| +|aws_servicecatalog_service_action_invalid_accept_language|✔| +|aws_servicecatalog_service_action_invalid_description|✔| +|aws_servicecatalog_service_action_invalid_name|✔| +|aws_servicecatalog_tag_option_invalid_key|✔| +|aws_servicecatalog_tag_option_invalid_value|✔| +|aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id|✔| |aws_servicequotas_service_quota_invalid_quota_code|✔| |aws_servicequotas_service_quota_invalid_service_code|✔| |aws_ses_domain_mail_from_invalid_behavior_on_mx_failure|✔| diff --git a/rules/models/aws_servicecatalog_budget_resource_association_invalid_budget_name.go b/rules/models/aws_servicecatalog_budget_resource_association_invalid_budget_name.go new file mode 100644 index 00000000..9f34d6d6 --- /dev/null +++ b/rules/models/aws_servicecatalog_budget_resource_association_invalid_budget_name.go @@ -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" +) + +// AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule checks the pattern is valid +type AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule struct { + resourceType string + attributeName string + max int + min int +} + +// NewAwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule returns new rule with default attributes +func NewAwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule() *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule { + return &AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule{ + resourceType: "aws_servicecatalog_budget_resource_association", + attributeName: "budget_name", + max: 100, + min: 1, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Name() string { + return "aws_servicecatalog_budget_resource_association_invalid_budget_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) 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, + "budget_name must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "budget_name must be 1 characters or higher", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_budget_resource_association_invalid_resource_id.go b/rules/models/aws_servicecatalog_budget_resource_association_invalid_resource_id.go new file mode 100644 index 00000000..be53553a --- /dev/null +++ b/rules/models/aws_servicecatalog_budget_resource_association_invalid_resource_id.go @@ -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" +) + +// AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule checks the pattern is valid +type AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule returns new rule with default attributes +func NewAwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule() *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule { + return &AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule{ + resourceType: "aws_servicecatalog_budget_resource_association", + attributeName: "resource_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Name() string { + return "aws_servicecatalog_budget_resource_association_invalid_resource_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) 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, + "resource_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "resource_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_constraint_invalid_accept_language.go b/rules/models/aws_servicecatalog_constraint_invalid_accept_language.go new file mode 100644 index 00000000..f3d995f2 --- /dev/null +++ b/rules/models/aws_servicecatalog_constraint_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogConstraintInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogConstraintInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogConstraintInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogConstraintInvalidAcceptLanguageRule() *AwsServicecatalogConstraintInvalidAcceptLanguageRule { + return &AwsServicecatalogConstraintInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_constraint", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_constraint_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_constraint_invalid_description.go b/rules/models/aws_servicecatalog_constraint_invalid_description.go new file mode 100644 index 00000000..d532f594 --- /dev/null +++ b/rules/models/aws_servicecatalog_constraint_invalid_description.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogConstraintInvalidDescriptionRule checks the pattern is valid +type AwsServicecatalogConstraintInvalidDescriptionRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogConstraintInvalidDescriptionRule returns new rule with default attributes +func NewAwsServicecatalogConstraintInvalidDescriptionRule() *AwsServicecatalogConstraintInvalidDescriptionRule { + return &AwsServicecatalogConstraintInvalidDescriptionRule{ + resourceType: "aws_servicecatalog_constraint", + attributeName: "description", + max: 2000, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Name() string { + return "aws_servicecatalog_constraint_invalid_description" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogConstraintInvalidDescriptionRule) 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 2000 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_constraint_invalid_portfolio_id.go b/rules/models/aws_servicecatalog_constraint_invalid_portfolio_id.go new file mode 100644 index 00000000..fb34ab2d --- /dev/null +++ b/rules/models/aws_servicecatalog_constraint_invalid_portfolio_id.go @@ -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" +) + +// AwsServicecatalogConstraintInvalidPortfolioIDRule checks the pattern is valid +type AwsServicecatalogConstraintInvalidPortfolioIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogConstraintInvalidPortfolioIDRule returns new rule with default attributes +func NewAwsServicecatalogConstraintInvalidPortfolioIDRule() *AwsServicecatalogConstraintInvalidPortfolioIDRule { + return &AwsServicecatalogConstraintInvalidPortfolioIDRule{ + resourceType: "aws_servicecatalog_constraint", + attributeName: "portfolio_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogConstraintInvalidPortfolioIDRule) Name() string { + return "aws_servicecatalog_constraint_invalid_portfolio_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogConstraintInvalidPortfolioIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogConstraintInvalidPortfolioIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogConstraintInvalidPortfolioIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogConstraintInvalidPortfolioIDRule) 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, + "portfolio_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "portfolio_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_constraint_invalid_product_id.go b/rules/models/aws_servicecatalog_constraint_invalid_product_id.go new file mode 100644 index 00000000..06b0690c --- /dev/null +++ b/rules/models/aws_servicecatalog_constraint_invalid_product_id.go @@ -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" +) + +// AwsServicecatalogConstraintInvalidProductIDRule checks the pattern is valid +type AwsServicecatalogConstraintInvalidProductIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogConstraintInvalidProductIDRule returns new rule with default attributes +func NewAwsServicecatalogConstraintInvalidProductIDRule() *AwsServicecatalogConstraintInvalidProductIDRule { + return &AwsServicecatalogConstraintInvalidProductIDRule{ + resourceType: "aws_servicecatalog_constraint", + attributeName: "product_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogConstraintInvalidProductIDRule) Name() string { + return "aws_servicecatalog_constraint_invalid_product_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogConstraintInvalidProductIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogConstraintInvalidProductIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogConstraintInvalidProductIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogConstraintInvalidProductIDRule) 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, + "product_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "product_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_constraint_invalid_type.go b/rules/models/aws_servicecatalog_constraint_invalid_type.go new file mode 100644 index 00000000..33e1509f --- /dev/null +++ b/rules/models/aws_servicecatalog_constraint_invalid_type.go @@ -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" +) + +// AwsServicecatalogConstraintInvalidTypeRule checks the pattern is valid +type AwsServicecatalogConstraintInvalidTypeRule struct { + resourceType string + attributeName string + max int + min int +} + +// NewAwsServicecatalogConstraintInvalidTypeRule returns new rule with default attributes +func NewAwsServicecatalogConstraintInvalidTypeRule() *AwsServicecatalogConstraintInvalidTypeRule { + return &AwsServicecatalogConstraintInvalidTypeRule{ + resourceType: "aws_servicecatalog_constraint", + attributeName: "type", + max: 1024, + min: 1, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogConstraintInvalidTypeRule) Name() string { + return "aws_servicecatalog_constraint_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogConstraintInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogConstraintInvalidTypeRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogConstraintInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogConstraintInvalidTypeRule) 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, + "type must be 1024 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "type must be 1 characters or higher", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_portfolio_share_invalid_accept_language.go b/rules/models/aws_servicecatalog_portfolio_share_invalid_accept_language.go new file mode 100644 index 00000000..3904575a --- /dev/null +++ b/rules/models/aws_servicecatalog_portfolio_share_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogPortfolioShareInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogPortfolioShareInvalidAcceptLanguageRule() *AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule { + return &AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_portfolio_share", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_portfolio_share_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPortfolioShareInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_portfolio_share_invalid_portfolio_id.go b/rules/models/aws_servicecatalog_portfolio_share_invalid_portfolio_id.go new file mode 100644 index 00000000..f16856b8 --- /dev/null +++ b/rules/models/aws_servicecatalog_portfolio_share_invalid_portfolio_id.go @@ -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" +) + +// AwsServicecatalogPortfolioShareInvalidPortfolioIDRule checks the pattern is valid +type AwsServicecatalogPortfolioShareInvalidPortfolioIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogPortfolioShareInvalidPortfolioIDRule returns new rule with default attributes +func NewAwsServicecatalogPortfolioShareInvalidPortfolioIDRule() *AwsServicecatalogPortfolioShareInvalidPortfolioIDRule { + return &AwsServicecatalogPortfolioShareInvalidPortfolioIDRule{ + resourceType: "aws_servicecatalog_portfolio_share", + attributeName: "portfolio_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPortfolioShareInvalidPortfolioIDRule) Name() string { + return "aws_servicecatalog_portfolio_share_invalid_portfolio_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPortfolioShareInvalidPortfolioIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPortfolioShareInvalidPortfolioIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPortfolioShareInvalidPortfolioIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPortfolioShareInvalidPortfolioIDRule) 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, + "portfolio_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "portfolio_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_portfolio_share_invalid_principal_id.go b/rules/models/aws_servicecatalog_portfolio_share_invalid_principal_id.go new file mode 100644 index 00000000..5d884ad8 --- /dev/null +++ b/rules/models/aws_servicecatalog_portfolio_share_invalid_principal_id.go @@ -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" +) + +// AwsServicecatalogPortfolioShareInvalidPrincipalIDRule checks the pattern is valid +type AwsServicecatalogPortfolioShareInvalidPrincipalIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogPortfolioShareInvalidPrincipalIDRule returns new rule with default attributes +func NewAwsServicecatalogPortfolioShareInvalidPrincipalIDRule() *AwsServicecatalogPortfolioShareInvalidPrincipalIDRule { + return &AwsServicecatalogPortfolioShareInvalidPrincipalIDRule{ + resourceType: "aws_servicecatalog_portfolio_share", + attributeName: "principal_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPortfolioShareInvalidPrincipalIDRule) Name() string { + return "aws_servicecatalog_portfolio_share_invalid_principal_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPortfolioShareInvalidPrincipalIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPortfolioShareInvalidPrincipalIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPortfolioShareInvalidPrincipalIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPortfolioShareInvalidPrincipalIDRule) 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, + "principal_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "principal_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_portfolio_share_invalid_type.go b/rules/models/aws_servicecatalog_portfolio_share_invalid_type.go new file mode 100644 index 00000000..db56cbc2 --- /dev/null +++ b/rules/models/aws_servicecatalog_portfolio_share_invalid_type.go @@ -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" +) + +// AwsServicecatalogPortfolioShareInvalidTypeRule checks the pattern is valid +type AwsServicecatalogPortfolioShareInvalidTypeRule struct { + resourceType string + attributeName string + enum []string +} + +// NewAwsServicecatalogPortfolioShareInvalidTypeRule returns new rule with default attributes +func NewAwsServicecatalogPortfolioShareInvalidTypeRule() *AwsServicecatalogPortfolioShareInvalidTypeRule { + return &AwsServicecatalogPortfolioShareInvalidTypeRule{ + resourceType: "aws_servicecatalog_portfolio_share", + attributeName: "type", + enum: []string{ + "IMPORTED", + "AWS_SERVICECATALOG", + "AWS_ORGANIZATIONS", + }, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPortfolioShareInvalidTypeRule) Name() string { + return "aws_servicecatalog_portfolio_share_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPortfolioShareInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPortfolioShareInvalidTypeRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPortfolioShareInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPortfolioShareInvalidTypeRule) 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 + }) + }) +} diff --git a/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_accept_language.go b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_accept_language.go new file mode 100644 index 00000000..502b26f6 --- /dev/null +++ b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule() *AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule { + return &AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_principal_portfolio_association", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_principal_portfolio_association_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id.go b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id.go new file mode 100644 index 00000000..6572de68 --- /dev/null +++ b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id.go @@ -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" +) + +// AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule checks the pattern is valid +type AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule returns new rule with default attributes +func NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule() *AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule { + return &AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule{ + resourceType: "aws_servicecatalog_principal_portfolio_association", + attributeName: "portfolio_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule) Name() string { + return "aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule) 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, + "portfolio_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "portfolio_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_arn.go b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_arn.go new file mode 100644 index 00000000..e2a330d0 --- /dev/null +++ b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_arn.go @@ -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" +) + +// AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule checks the pattern is valid +type AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule struct { + resourceType string + attributeName string + max int + min int +} + +// NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule returns new rule with default attributes +func NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule() *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule { + return &AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule{ + resourceType: "aws_servicecatalog_principal_portfolio_association", + attributeName: "principal_arn", + max: 1000, + min: 1, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule) Name() string { + return "aws_servicecatalog_principal_portfolio_association_invalid_principal_arn" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule) 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, + "principal_arn must be 1000 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "principal_arn must be 1 characters or higher", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_type.go b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_type.go new file mode 100644 index 00000000..d46e2456 --- /dev/null +++ b/rules/models/aws_servicecatalog_principal_portfolio_association_invalid_principal_type.go @@ -0,0 +1,76 @@ +// 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" +) + +// AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule checks the pattern is valid +type AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule struct { + resourceType string + attributeName string + enum []string +} + +// NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule returns new rule with default attributes +func NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule() *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule { + return &AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule{ + resourceType: "aws_servicecatalog_principal_portfolio_association", + attributeName: "principal_type", + enum: []string{ + "IAM", + }, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule) Name() string { + return "aws_servicecatalog_principal_portfolio_association_invalid_principal_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule) 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 principal_type`, truncateLongMessage(val)), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_accept_language.go b/rules/models/aws_servicecatalog_product_invalid_accept_language.go new file mode 100644 index 00000000..d966ad41 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogProductInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidAcceptLanguageRule() *AwsServicecatalogProductInvalidAcceptLanguageRule { + return &AwsServicecatalogProductInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_product_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_description.go b/rules/models/aws_servicecatalog_product_invalid_description.go new file mode 100644 index 00000000..1fa970e2 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_description.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidDescriptionRule checks the pattern is valid +type AwsServicecatalogProductInvalidDescriptionRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidDescriptionRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidDescriptionRule() *AwsServicecatalogProductInvalidDescriptionRule { + return &AwsServicecatalogProductInvalidDescriptionRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "description", + max: 8191, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidDescriptionRule) Name() string { + return "aws_servicecatalog_product_invalid_description" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidDescriptionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidDescriptionRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidDescriptionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidDescriptionRule) 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 8191 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_distributor.go b/rules/models/aws_servicecatalog_product_invalid_distributor.go new file mode 100644 index 00000000..f014aea3 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_distributor.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidDistributorRule checks the pattern is valid +type AwsServicecatalogProductInvalidDistributorRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidDistributorRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidDistributorRule() *AwsServicecatalogProductInvalidDistributorRule { + return &AwsServicecatalogProductInvalidDistributorRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "distributor", + max: 8191, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidDistributorRule) Name() string { + return "aws_servicecatalog_product_invalid_distributor" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidDistributorRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidDistributorRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidDistributorRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidDistributorRule) 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, + "distributor must be 8191 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_name.go b/rules/models/aws_servicecatalog_product_invalid_name.go new file mode 100644 index 00000000..1bbcfa17 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_name.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidNameRule checks the pattern is valid +type AwsServicecatalogProductInvalidNameRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidNameRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidNameRule() *AwsServicecatalogProductInvalidNameRule { + return &AwsServicecatalogProductInvalidNameRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "name", + max: 8191, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidNameRule) Name() string { + return "aws_servicecatalog_product_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidNameRule) 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 8191 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_owner.go b/rules/models/aws_servicecatalog_product_invalid_owner.go new file mode 100644 index 00000000..88c1b76e --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_owner.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidOwnerRule checks the pattern is valid +type AwsServicecatalogProductInvalidOwnerRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidOwnerRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidOwnerRule() *AwsServicecatalogProductInvalidOwnerRule { + return &AwsServicecatalogProductInvalidOwnerRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "owner", + max: 8191, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidOwnerRule) Name() string { + return "aws_servicecatalog_product_invalid_owner" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidOwnerRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidOwnerRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidOwnerRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidOwnerRule) 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, + "owner must be 8191 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_support_description.go b/rules/models/aws_servicecatalog_product_invalid_support_description.go new file mode 100644 index 00000000..8137cc4d --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_support_description.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidSupportDescriptionRule checks the pattern is valid +type AwsServicecatalogProductInvalidSupportDescriptionRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidSupportDescriptionRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidSupportDescriptionRule() *AwsServicecatalogProductInvalidSupportDescriptionRule { + return &AwsServicecatalogProductInvalidSupportDescriptionRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "support_description", + max: 8191, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidSupportDescriptionRule) Name() string { + return "aws_servicecatalog_product_invalid_support_description" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidSupportDescriptionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidSupportDescriptionRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidSupportDescriptionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidSupportDescriptionRule) 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, + "support_description must be 8191 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_support_email.go b/rules/models/aws_servicecatalog_product_invalid_support_email.go new file mode 100644 index 00000000..191d241c --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_support_email.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidSupportEmailRule checks the pattern is valid +type AwsServicecatalogProductInvalidSupportEmailRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidSupportEmailRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidSupportEmailRule() *AwsServicecatalogProductInvalidSupportEmailRule { + return &AwsServicecatalogProductInvalidSupportEmailRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "support_email", + max: 254, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidSupportEmailRule) Name() string { + return "aws_servicecatalog_product_invalid_support_email" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidSupportEmailRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidSupportEmailRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidSupportEmailRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidSupportEmailRule) 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, + "support_email must be 254 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_support_url.go b/rules/models/aws_servicecatalog_product_invalid_support_url.go new file mode 100644 index 00000000..8e870d36 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_support_url.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductInvalidSupportURLRule checks the pattern is valid +type AwsServicecatalogProductInvalidSupportURLRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductInvalidSupportURLRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidSupportURLRule() *AwsServicecatalogProductInvalidSupportURLRule { + return &AwsServicecatalogProductInvalidSupportURLRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "support_url", + max: 2083, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidSupportURLRule) Name() string { + return "aws_servicecatalog_product_invalid_support_url" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidSupportURLRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidSupportURLRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidSupportURLRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidSupportURLRule) 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, + "support_url must be 2083 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_invalid_type.go b/rules/models/aws_servicecatalog_product_invalid_type.go new file mode 100644 index 00000000..78be6af1 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_invalid_type.go @@ -0,0 +1,86 @@ +// 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" +) + +// AwsServicecatalogProductInvalidTypeRule checks the pattern is valid +type AwsServicecatalogProductInvalidTypeRule struct { + resourceType string + attributeName string + max int + enum []string +} + +// NewAwsServicecatalogProductInvalidTypeRule returns new rule with default attributes +func NewAwsServicecatalogProductInvalidTypeRule() *AwsServicecatalogProductInvalidTypeRule { + return &AwsServicecatalogProductInvalidTypeRule{ + resourceType: "aws_servicecatalog_product", + attributeName: "type", + max: 8191, + enum: []string{ + "CLOUD_FORMATION_TEMPLATE", + "MARKETPLACE", + }, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductInvalidTypeRule) Name() string { + return "aws_servicecatalog_product_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductInvalidTypeRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductInvalidTypeRule) 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, + "type must be 8191 characters or less", + attribute.Expr, + ) + } + 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 + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_portfolio_association_invalid_accept_language.go b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_accept_language.go new file mode 100644 index 00000000..a473c531 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule() *AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule { + return &AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_product_portfolio_association", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_product_portfolio_association_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_portfolio_association_invalid_portfolio_id.go b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_portfolio_id.go new file mode 100644 index 00000000..7eff4080 --- /dev/null +++ b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_portfolio_id.go @@ -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" +) + +// AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule checks the pattern is valid +type AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule returns new rule with default attributes +func NewAwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule() *AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule { + return &AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule{ + resourceType: "aws_servicecatalog_product_portfolio_association", + attributeName: "portfolio_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule) Name() string { + return "aws_servicecatalog_product_portfolio_association_invalid_portfolio_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule) 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, + "portfolio_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "portfolio_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_portfolio_association_invalid_product_id.go b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_product_id.go new file mode 100644 index 00000000..ce50bd6d --- /dev/null +++ b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_product_id.go @@ -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" +) + +// AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule checks the pattern is valid +type AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProductPortfolioAssociationInvalidProductIDRule returns new rule with default attributes +func NewAwsServicecatalogProductPortfolioAssociationInvalidProductIDRule() *AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule { + return &AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule{ + resourceType: "aws_servicecatalog_product_portfolio_association", + attributeName: "product_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule) Name() string { + return "aws_servicecatalog_product_portfolio_association_invalid_product_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductPortfolioAssociationInvalidProductIDRule) 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, + "product_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "product_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id.go b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id.go new file mode 100644 index 00000000..3bb29c9d --- /dev/null +++ b/rules/models/aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id.go @@ -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" +) + +// AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule checks the pattern is valid +type AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule returns new rule with default attributes +func NewAwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule() *AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule { + return &AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule{ + resourceType: "aws_servicecatalog_product_portfolio_association", + attributeName: "source_portfolio_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule) Name() string { + return "aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule) 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, + "source_portfolio_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "source_portfolio_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_accept_language.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_accept_language.go new file mode 100644 index 00000000..6c692003 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProvisionedProductInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidAcceptLanguageRule() *AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule { + return &AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_name.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_name.go new file mode 100644 index 00000000..9e6e4dbb --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_name.go @@ -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" +) + +// AwsServicecatalogProvisionedProductInvalidNameRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidNameRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProvisionedProductInvalidNameRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidNameRule() *AwsServicecatalogProvisionedProductInvalidNameRule { + return &AwsServicecatalogProvisionedProductInvalidNameRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "name", + max: 128, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9._-]*$`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidNameRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidNameRule) 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 128 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), `^[a-zA-Z0-9][a-zA-Z0-9._-]*$`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_path_id.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_path_id.go new file mode 100644 index 00000000..0eff5cca --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_path_id.go @@ -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" +) + +// AwsServicecatalogProvisionedProductInvalidPathIDRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidPathIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProvisionedProductInvalidPathIDRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidPathIDRule() *AwsServicecatalogProvisionedProductInvalidPathIDRule { + return &AwsServicecatalogProvisionedProductInvalidPathIDRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "path_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidPathIDRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_path_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidPathIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidPathIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidPathIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidPathIDRule) 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, + "path_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "path_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_path_name.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_path_name.go new file mode 100644 index 00000000..ce0da96f --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_path_name.go @@ -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" +) + +// AwsServicecatalogProvisionedProductInvalidPathNameRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidPathNameRule struct { + resourceType string + attributeName string + max int + min int +} + +// NewAwsServicecatalogProvisionedProductInvalidPathNameRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidPathNameRule() *AwsServicecatalogProvisionedProductInvalidPathNameRule { + return &AwsServicecatalogProvisionedProductInvalidPathNameRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "path_name", + max: 100, + min: 1, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidPathNameRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_path_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidPathNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidPathNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidPathNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidPathNameRule) 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, + "path_name must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "path_name must be 1 characters or higher", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_product_id.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_product_id.go new file mode 100644 index 00000000..4f99e964 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_product_id.go @@ -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" +) + +// AwsServicecatalogProvisionedProductInvalidProductIDRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidProductIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProvisionedProductInvalidProductIDRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidProductIDRule() *AwsServicecatalogProvisionedProductInvalidProductIDRule { + return &AwsServicecatalogProvisionedProductInvalidProductIDRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "product_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidProductIDRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_product_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidProductIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidProductIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidProductIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidProductIDRule) 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, + "product_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "product_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_product_name.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_product_name.go new file mode 100644 index 00000000..d1ec9390 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_product_name.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProvisionedProductInvalidProductNameRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidProductNameRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProvisionedProductInvalidProductNameRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidProductNameRule() *AwsServicecatalogProvisionedProductInvalidProductNameRule { + return &AwsServicecatalogProvisionedProductInvalidProductNameRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "product_name", + max: 8191, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidProductNameRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_product_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidProductNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidProductNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidProductNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidProductNameRule) 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, + "product_name must be 8191 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id.go new file mode 100644 index 00000000..503f1559 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id.go @@ -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" +) + +// AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule() *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule { + return &AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "provisioning_artifact_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule) 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, + "provisioning_artifact_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "provisioning_artifact_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name.go b/rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name.go new file mode 100644 index 00000000..eeb94811 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule checks the pattern is valid +type AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule returns new rule with default attributes +func NewAwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule() *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule { + return &AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule{ + resourceType: "aws_servicecatalog_provisioned_product", + attributeName: "provisioning_artifact_name", + max: 8192, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule) Name() string { + return "aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule) 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, + "provisioning_artifact_name must be 8192 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioning_artifact_invalid_accept_language.go b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_accept_language.go new file mode 100644 index 00000000..6b529b49 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule() *AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule { + return &AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_provisioning_artifact", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_provisioning_artifact_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioning_artifact_invalid_description.go b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_description.go new file mode 100644 index 00000000..6fe43f5e --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_description.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProvisioningArtifactInvalidDescriptionRule checks the pattern is valid +type AwsServicecatalogProvisioningArtifactInvalidDescriptionRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProvisioningArtifactInvalidDescriptionRule returns new rule with default attributes +func NewAwsServicecatalogProvisioningArtifactInvalidDescriptionRule() *AwsServicecatalogProvisioningArtifactInvalidDescriptionRule { + return &AwsServicecatalogProvisioningArtifactInvalidDescriptionRule{ + resourceType: "aws_servicecatalog_provisioning_artifact", + attributeName: "description", + max: 8192, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisioningArtifactInvalidDescriptionRule) Name() string { + return "aws_servicecatalog_provisioning_artifact_invalid_description" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisioningArtifactInvalidDescriptionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisioningArtifactInvalidDescriptionRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisioningArtifactInvalidDescriptionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisioningArtifactInvalidDescriptionRule) 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 8192 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioning_artifact_invalid_guidance.go b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_guidance.go new file mode 100644 index 00000000..1ba993ae --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_guidance.go @@ -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" +) + +// AwsServicecatalogProvisioningArtifactInvalidGuidanceRule checks the pattern is valid +type AwsServicecatalogProvisioningArtifactInvalidGuidanceRule struct { + resourceType string + attributeName string + enum []string +} + +// NewAwsServicecatalogProvisioningArtifactInvalidGuidanceRule returns new rule with default attributes +func NewAwsServicecatalogProvisioningArtifactInvalidGuidanceRule() *AwsServicecatalogProvisioningArtifactInvalidGuidanceRule { + return &AwsServicecatalogProvisioningArtifactInvalidGuidanceRule{ + resourceType: "aws_servicecatalog_provisioning_artifact", + attributeName: "guidance", + enum: []string{ + "DEFAULT", + "DEPRECATED", + }, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisioningArtifactInvalidGuidanceRule) Name() string { + return "aws_servicecatalog_provisioning_artifact_invalid_guidance" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisioningArtifactInvalidGuidanceRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisioningArtifactInvalidGuidanceRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisioningArtifactInvalidGuidanceRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisioningArtifactInvalidGuidanceRule) 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 guidance`, truncateLongMessage(val)), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioning_artifact_invalid_name.go b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_name.go new file mode 100644 index 00000000..0c1d6da8 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_name.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogProvisioningArtifactInvalidNameRule checks the pattern is valid +type AwsServicecatalogProvisioningArtifactInvalidNameRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogProvisioningArtifactInvalidNameRule returns new rule with default attributes +func NewAwsServicecatalogProvisioningArtifactInvalidNameRule() *AwsServicecatalogProvisioningArtifactInvalidNameRule { + return &AwsServicecatalogProvisioningArtifactInvalidNameRule{ + resourceType: "aws_servicecatalog_provisioning_artifact", + attributeName: "name", + max: 8192, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisioningArtifactInvalidNameRule) Name() string { + return "aws_servicecatalog_provisioning_artifact_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisioningArtifactInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisioningArtifactInvalidNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisioningArtifactInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisioningArtifactInvalidNameRule) 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 8192 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioning_artifact_invalid_product_id.go b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_product_id.go new file mode 100644 index 00000000..d6fc62b3 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_product_id.go @@ -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" +) + +// AwsServicecatalogProvisioningArtifactInvalidProductIDRule checks the pattern is valid +type AwsServicecatalogProvisioningArtifactInvalidProductIDRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogProvisioningArtifactInvalidProductIDRule returns new rule with default attributes +func NewAwsServicecatalogProvisioningArtifactInvalidProductIDRule() *AwsServicecatalogProvisioningArtifactInvalidProductIDRule { + return &AwsServicecatalogProvisioningArtifactInvalidProductIDRule{ + resourceType: "aws_servicecatalog_provisioning_artifact", + attributeName: "product_id", + max: 100, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisioningArtifactInvalidProductIDRule) Name() string { + return "aws_servicecatalog_provisioning_artifact_invalid_product_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisioningArtifactInvalidProductIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisioningArtifactInvalidProductIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisioningArtifactInvalidProductIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisioningArtifactInvalidProductIDRule) 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, + "product_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "product_id 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), `^[a-zA-Z0-9_\-]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_provisioning_artifact_invalid_type.go b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_type.go new file mode 100644 index 00000000..3330e236 --- /dev/null +++ b/rules/models/aws_servicecatalog_provisioning_artifact_invalid_type.go @@ -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" +) + +// AwsServicecatalogProvisioningArtifactInvalidTypeRule checks the pattern is valid +type AwsServicecatalogProvisioningArtifactInvalidTypeRule struct { + resourceType string + attributeName string + enum []string +} + +// NewAwsServicecatalogProvisioningArtifactInvalidTypeRule returns new rule with default attributes +func NewAwsServicecatalogProvisioningArtifactInvalidTypeRule() *AwsServicecatalogProvisioningArtifactInvalidTypeRule { + return &AwsServicecatalogProvisioningArtifactInvalidTypeRule{ + resourceType: "aws_servicecatalog_provisioning_artifact", + attributeName: "type", + enum: []string{ + "CLOUD_FORMATION_TEMPLATE", + "MARKETPLACE_AMI", + "MARKETPLACE_CAR", + }, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogProvisioningArtifactInvalidTypeRule) Name() string { + return "aws_servicecatalog_provisioning_artifact_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogProvisioningArtifactInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogProvisioningArtifactInvalidTypeRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogProvisioningArtifactInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogProvisioningArtifactInvalidTypeRule) 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 + }) + }) +} diff --git a/rules/models/aws_servicecatalog_service_action_invalid_accept_language.go b/rules/models/aws_servicecatalog_service_action_invalid_accept_language.go new file mode 100644 index 00000000..8116f52a --- /dev/null +++ b/rules/models/aws_servicecatalog_service_action_invalid_accept_language.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogServiceActionInvalidAcceptLanguageRule checks the pattern is valid +type AwsServicecatalogServiceActionInvalidAcceptLanguageRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogServiceActionInvalidAcceptLanguageRule returns new rule with default attributes +func NewAwsServicecatalogServiceActionInvalidAcceptLanguageRule() *AwsServicecatalogServiceActionInvalidAcceptLanguageRule { + return &AwsServicecatalogServiceActionInvalidAcceptLanguageRule{ + resourceType: "aws_servicecatalog_service_action", + attributeName: "accept_language", + max: 100, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogServiceActionInvalidAcceptLanguageRule) Name() string { + return "aws_servicecatalog_service_action_invalid_accept_language" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogServiceActionInvalidAcceptLanguageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogServiceActionInvalidAcceptLanguageRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogServiceActionInvalidAcceptLanguageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogServiceActionInvalidAcceptLanguageRule) 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, + "accept_language must be 100 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_service_action_invalid_description.go b/rules/models/aws_servicecatalog_service_action_invalid_description.go new file mode 100644 index 00000000..59d04c8d --- /dev/null +++ b/rules/models/aws_servicecatalog_service_action_invalid_description.go @@ -0,0 +1,67 @@ +// 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" +) + +// AwsServicecatalogServiceActionInvalidDescriptionRule checks the pattern is valid +type AwsServicecatalogServiceActionInvalidDescriptionRule struct { + resourceType string + attributeName string + max int +} + +// NewAwsServicecatalogServiceActionInvalidDescriptionRule returns new rule with default attributes +func NewAwsServicecatalogServiceActionInvalidDescriptionRule() *AwsServicecatalogServiceActionInvalidDescriptionRule { + return &AwsServicecatalogServiceActionInvalidDescriptionRule{ + resourceType: "aws_servicecatalog_service_action", + attributeName: "description", + max: 1024, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogServiceActionInvalidDescriptionRule) Name() string { + return "aws_servicecatalog_service_action_invalid_description" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogServiceActionInvalidDescriptionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogServiceActionInvalidDescriptionRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogServiceActionInvalidDescriptionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogServiceActionInvalidDescriptionRule) 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 1024 characters or less", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_service_action_invalid_name.go b/rules/models/aws_servicecatalog_service_action_invalid_name.go new file mode 100644 index 00000000..9f7d56d2 --- /dev/null +++ b/rules/models/aws_servicecatalog_service_action_invalid_name.go @@ -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" +) + +// AwsServicecatalogServiceActionInvalidNameRule checks the pattern is valid +type AwsServicecatalogServiceActionInvalidNameRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogServiceActionInvalidNameRule returns new rule with default attributes +func NewAwsServicecatalogServiceActionInvalidNameRule() *AwsServicecatalogServiceActionInvalidNameRule { + return &AwsServicecatalogServiceActionInvalidNameRule{ + resourceType: "aws_servicecatalog_service_action", + attributeName: "name", + max: 256, + min: 1, + pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-.]*`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogServiceActionInvalidNameRule) Name() string { + return "aws_servicecatalog_service_action_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogServiceActionInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogServiceActionInvalidNameRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogServiceActionInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogServiceActionInvalidNameRule) 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 256 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), `^[a-zA-Z0-9_\-.]*`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_tag_option_invalid_key.go b/rules/models/aws_servicecatalog_tag_option_invalid_key.go new file mode 100644 index 00000000..a8123b0b --- /dev/null +++ b/rules/models/aws_servicecatalog_tag_option_invalid_key.go @@ -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" +) + +// AwsServicecatalogTagOptionInvalidKeyRule checks the pattern is valid +type AwsServicecatalogTagOptionInvalidKeyRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogTagOptionInvalidKeyRule returns new rule with default attributes +func NewAwsServicecatalogTagOptionInvalidKeyRule() *AwsServicecatalogTagOptionInvalidKeyRule { + return &AwsServicecatalogTagOptionInvalidKeyRule{ + resourceType: "aws_servicecatalog_tag_option", + attributeName: "key", + max: 128, + min: 1, + pattern: regexp.MustCompile(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogTagOptionInvalidKeyRule) Name() string { + return "aws_servicecatalog_tag_option_invalid_key" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogTagOptionInvalidKeyRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogTagOptionInvalidKeyRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogTagOptionInvalidKeyRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogTagOptionInvalidKeyRule) 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, + "key must be 128 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "key 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), `^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_tag_option_invalid_value.go b/rules/models/aws_servicecatalog_tag_option_invalid_value.go new file mode 100644 index 00000000..cb4fee16 --- /dev/null +++ b/rules/models/aws_servicecatalog_tag_option_invalid_value.go @@ -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" +) + +// AwsServicecatalogTagOptionInvalidValueRule checks the pattern is valid +type AwsServicecatalogTagOptionInvalidValueRule struct { + resourceType string + attributeName string + max int + min int + pattern *regexp.Regexp +} + +// NewAwsServicecatalogTagOptionInvalidValueRule returns new rule with default attributes +func NewAwsServicecatalogTagOptionInvalidValueRule() *AwsServicecatalogTagOptionInvalidValueRule { + return &AwsServicecatalogTagOptionInvalidValueRule{ + resourceType: "aws_servicecatalog_tag_option", + attributeName: "value", + max: 256, + min: 1, + pattern: regexp.MustCompile(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`), + } +} + +// Name returns the rule name +func (r *AwsServicecatalogTagOptionInvalidValueRule) Name() string { + return "aws_servicecatalog_tag_option_invalid_value" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogTagOptionInvalidValueRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogTagOptionInvalidValueRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogTagOptionInvalidValueRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogTagOptionInvalidValueRule) 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, + "value must be 256 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "value 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), `^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`), + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id.go b/rules/models/aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id.go new file mode 100644 index 00000000..45cecd8b --- /dev/null +++ b/rules/models/aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id.go @@ -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" +) + +// AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule checks the pattern is valid +type AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule struct { + resourceType string + attributeName string + max int + min int +} + +// NewAwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule returns new rule with default attributes +func NewAwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule() *AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule { + return &AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule{ + resourceType: "aws_servicecatalog_tag_option_resource_association", + attributeName: "tag_option_id", + max: 100, + min: 1, + } +} + +// Name returns the rule name +func (r *AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule) Name() string { + return "aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule) Severity() string { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *AwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule) 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, + "tag_option_id must be 100 characters or less", + attribute.Expr, + ) + } + if len(val) < r.min { + runner.EmitIssueOnExpr( + r, + "tag_option_id must be 1 characters or higher", + attribute.Expr, + ) + } + return nil + }) + }) +} diff --git a/rules/models/provider.go b/rules/models/provider.go index 697b7c5d..b268de69 100644 --- a/rules/models/provider.go +++ b/rules/models/provider.go @@ -820,9 +820,57 @@ var Rules = []tflint.Rule{ NewAwsServiceDiscoveryPublicDNSNamespaceInvalidDescriptionRule(), NewAwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule(), NewAwsServiceDiscoveryServiceInvalidDescriptionRule(), + NewAwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule(), + NewAwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule(), + NewAwsServicecatalogConstraintInvalidAcceptLanguageRule(), + NewAwsServicecatalogConstraintInvalidDescriptionRule(), + NewAwsServicecatalogConstraintInvalidPortfolioIDRule(), + NewAwsServicecatalogConstraintInvalidProductIDRule(), + NewAwsServicecatalogConstraintInvalidTypeRule(), NewAwsServicecatalogPortfolioInvalidDescriptionRule(), NewAwsServicecatalogPortfolioInvalidNameRule(), NewAwsServicecatalogPortfolioInvalidProviderNameRule(), + NewAwsServicecatalogPortfolioShareInvalidAcceptLanguageRule(), + NewAwsServicecatalogPortfolioShareInvalidPortfolioIDRule(), + NewAwsServicecatalogPortfolioShareInvalidPrincipalIDRule(), + NewAwsServicecatalogPortfolioShareInvalidTypeRule(), + NewAwsServicecatalogPrincipalPortfolioAssociationInvalidAcceptLanguageRule(), + NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPortfolioIDRule(), + NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalArnRule(), + NewAwsServicecatalogPrincipalPortfolioAssociationInvalidPrincipalTypeRule(), + NewAwsServicecatalogProductInvalidAcceptLanguageRule(), + NewAwsServicecatalogProductInvalidDescriptionRule(), + NewAwsServicecatalogProductInvalidDistributorRule(), + NewAwsServicecatalogProductInvalidNameRule(), + NewAwsServicecatalogProductInvalidOwnerRule(), + NewAwsServicecatalogProductInvalidSupportDescriptionRule(), + NewAwsServicecatalogProductInvalidSupportEmailRule(), + NewAwsServicecatalogProductInvalidSupportURLRule(), + NewAwsServicecatalogProductInvalidTypeRule(), + NewAwsServicecatalogProductPortfolioAssociationInvalidAcceptLanguageRule(), + NewAwsServicecatalogProductPortfolioAssociationInvalidPortfolioIDRule(), + NewAwsServicecatalogProductPortfolioAssociationInvalidProductIDRule(), + NewAwsServicecatalogProductPortfolioAssociationInvalidSourcePortfolioIDRule(), + NewAwsServicecatalogProvisionedProductInvalidAcceptLanguageRule(), + NewAwsServicecatalogProvisionedProductInvalidNameRule(), + NewAwsServicecatalogProvisionedProductInvalidPathIDRule(), + NewAwsServicecatalogProvisionedProductInvalidPathNameRule(), + NewAwsServicecatalogProvisionedProductInvalidProductIDRule(), + NewAwsServicecatalogProvisionedProductInvalidProductNameRule(), + NewAwsServicecatalogProvisionedProductInvalidProvisioningArtifactIDRule(), + NewAwsServicecatalogProvisionedProductInvalidProvisioningArtifactNameRule(), + NewAwsServicecatalogProvisioningArtifactInvalidAcceptLanguageRule(), + NewAwsServicecatalogProvisioningArtifactInvalidDescriptionRule(), + NewAwsServicecatalogProvisioningArtifactInvalidGuidanceRule(), + NewAwsServicecatalogProvisioningArtifactInvalidNameRule(), + NewAwsServicecatalogProvisioningArtifactInvalidProductIDRule(), + NewAwsServicecatalogProvisioningArtifactInvalidTypeRule(), + NewAwsServicecatalogServiceActionInvalidAcceptLanguageRule(), + NewAwsServicecatalogServiceActionInvalidDescriptionRule(), + NewAwsServicecatalogServiceActionInvalidNameRule(), + NewAwsServicecatalogTagOptionInvalidKeyRule(), + NewAwsServicecatalogTagOptionInvalidValueRule(), + NewAwsServicecatalogTagOptionResourceAssociationInvalidTagOptionIDRule(), NewAwsServicequotasServiceQuotaInvalidQuotaCodeRule(), NewAwsServicequotasServiceQuotaInvalidServiceCodeRule(), NewAwsSesDomainMailFromInvalidBehaviorOnMxFailureRule(),