Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion rules/magicmodules/api_definition.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (r *GoogleApigeeApiProductInvalidNameRule) Check(runner tflint.Runner) erro
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validateRegexp(`^[a-z][a-z0-9._\-$ %]*$`)
validateFunc := validateRegexp(`^[a-zA-Z][a-zA-Z0-9._\-$ %]*$`)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleApigeeDataCollectorInvalidDataCollectorIdRule checks the pattern is valid
type GoogleApigeeDataCollectorInvalidDataCollectorIdRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleApigeeDataCollectorInvalidDataCollectorIdRule returns new rule with default attributes
func NewGoogleApigeeDataCollectorInvalidDataCollectorIdRule() *GoogleApigeeDataCollectorInvalidDataCollectorIdRule {
return &GoogleApigeeDataCollectorInvalidDataCollectorIdRule{
resourceType: "google_apigee_data_collector",
attributeName: "data_collector_id",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleApigeeDataCollectorInvalidDataCollectorIdRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validateRegexp(`^dc_[a-zA-Z0-9_]+$`)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
91 changes: 91 additions & 0 deletions rules/magicmodules/google_apigee_data_collector_invalid_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleApigeeDataCollectorInvalidTypeRule checks the pattern is valid
type GoogleApigeeDataCollectorInvalidTypeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleApigeeDataCollectorInvalidTypeRule returns new rule with default attributes
func NewGoogleApigeeDataCollectorInvalidTypeRule() *GoogleApigeeDataCollectorInvalidTypeRule {
return &GoogleApigeeDataCollectorInvalidTypeRule{
resourceType: "google_apigee_data_collector",
attributeName: "type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleApigeeDataCollectorInvalidTypeRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"BOOLEAN", "DATETIME", "FLOAT", "INTEGER", "STRING"}, false)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
91 changes: 91 additions & 0 deletions rules/magicmodules/google_artifact_registry_rule_invalid_action.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleArtifactRegistryRuleInvalidActionRule checks the pattern is valid
type GoogleArtifactRegistryRuleInvalidActionRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleArtifactRegistryRuleInvalidActionRule returns new rule with default attributes
func NewGoogleArtifactRegistryRuleInvalidActionRule() *GoogleArtifactRegistryRuleInvalidActionRule {
return &GoogleArtifactRegistryRuleInvalidActionRule{
resourceType: "google_artifact_registry_rule",
attributeName: "action",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleArtifactRegistryRuleInvalidActionRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"ACTION_UNSPECIFIED", "ALLOW", "DENY", ""}, false)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleArtifactRegistryRuleInvalidOperationRule checks the pattern is valid
type GoogleArtifactRegistryRuleInvalidOperationRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleArtifactRegistryRuleInvalidOperationRule returns new rule with default attributes
func NewGoogleArtifactRegistryRuleInvalidOperationRule() *GoogleArtifactRegistryRuleInvalidOperationRule {
return &GoogleArtifactRegistryRuleInvalidOperationRule{
resourceType: "google_artifact_registry_rule",
attributeName: "operation",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleArtifactRegistryRuleInvalidOperationRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"OPERATION_UNSPECIFIED", "DOWNLOAD", ""}, false)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule) Check(runner tflint.
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"CATALOG_TYPE_GCS_BUCKET"}, false)
validateFunc := validation.StringInSlice([]string{"CATALOG_TYPE_GCS_BUCKET", "CATALOG_TYPE_BIGLAKE"}, false)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *GoogleComputeNetworkEndpointGroupInvalidNetworkEndpointTypeRule) Check(
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"GCE_VM_IP", "GCE_VM_IP_PORT", "NON_GCP_PRIVATE_IP_PORT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT", "SERVERLESS", "PRIVATE_SERVICE_CONNECT", ""}, false)
validateFunc := validation.StringInSlice([]string{"GCE_VM_IP", "GCE_VM_IP_PORT", "NON_GCP_PRIVATE_IP_PORT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT", "SERVERLESS", "PRIVATE_SERVICE_CONNECT", "GCE_VM_IP_DEDICATED_BACKEND", ""}, false)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
Expand Down
Loading