generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,524 additions
and
348 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
rules/magicmodules/google_bigquery_routine_invalid_data_governance_type.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
) | ||
|
||
// GoogleBigqueryRoutineInvalidDataGovernanceTypeRule checks the pattern is valid | ||
type GoogleBigqueryRoutineInvalidDataGovernanceTypeRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleBigqueryRoutineInvalidDataGovernanceTypeRule returns new rule with default attributes | ||
func NewGoogleBigqueryRoutineInvalidDataGovernanceTypeRule() *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule { | ||
return &GoogleBigqueryRoutineInvalidDataGovernanceTypeRule{ | ||
resourceType: "google_bigquery_routine", | ||
attributeName: "data_governance_type", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule) Name() string { | ||
return "google_bigquery_routine_invalid_data_governance_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule) 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{"DATA_MASKING", ""}, 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
91
rules/magicmodules/google_billing_budget_invalid_ownership_scope.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
) | ||
|
||
// GoogleBillingBudgetInvalidOwnershipScopeRule checks the pattern is valid | ||
type GoogleBillingBudgetInvalidOwnershipScopeRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleBillingBudgetInvalidOwnershipScopeRule returns new rule with default attributes | ||
func NewGoogleBillingBudgetInvalidOwnershipScopeRule() *GoogleBillingBudgetInvalidOwnershipScopeRule { | ||
return &GoogleBillingBudgetInvalidOwnershipScopeRule{ | ||
resourceType: "google_billing_budget", | ||
attributeName: "ownership_scope", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleBillingBudgetInvalidOwnershipScopeRule) Name() string { | ||
return "google_billing_budget_invalid_ownership_scope" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleBillingBudgetInvalidOwnershipScopeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleBillingBudgetInvalidOwnershipScopeRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleBillingBudgetInvalidOwnershipScopeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleBillingBudgetInvalidOwnershipScopeRule) 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{"OWNERSHIP_SCOPE_UNSPECIFIED", "ALL_USERS", "BILLING_ACCOUNT", ""}, 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
91
rules/magicmodules/google_certificate_manager_dns_authorization_invalid_type.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
) | ||
|
||
// GoogleCertificateManagerDnsAuthorizationInvalidTypeRule checks the pattern is valid | ||
type GoogleCertificateManagerDnsAuthorizationInvalidTypeRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleCertificateManagerDnsAuthorizationInvalidTypeRule returns new rule with default attributes | ||
func NewGoogleCertificateManagerDnsAuthorizationInvalidTypeRule() *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule { | ||
return &GoogleCertificateManagerDnsAuthorizationInvalidTypeRule{ | ||
resourceType: "google_certificate_manager_dns_authorization", | ||
attributeName: "type", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule) Name() string { | ||
return "google_certificate_manager_dns_authorization_invalid_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule) 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{"FIXED_RECORD", "PER_PROJECT_RECORD", ""}, 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
91
rules/magicmodules/google_cloud_quotas_quota_preference_invalid_ignore_safety_checks.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
) | ||
|
||
// GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule checks the pattern is valid | ||
type GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule returns new rule with default attributes | ||
func NewGoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule() *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule { | ||
return &GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule{ | ||
resourceType: "google_cloud_quotas_quota_preference", | ||
attributeName: "ignore_safety_checks", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule) Name() string { | ||
return "google_cloud_quotas_quota_preference_invalid_ignore_safety_checks" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule) 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{"QUOTA_SAFETY_CHECK_UNSPECIFIED", "QUOTA_DECREASE_BELOW_USAGE", "QUOTA_DECREASE_PERCENTAGE_TOO_HIGH", ""}, 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 | ||
} |
Oops, something went wrong.