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
30 changed files
with
1,731 additions
and
60 deletions.
There are no files selected for viewing
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
91 changes: 91 additions & 0 deletions
91
rules/magicmodules/google_alloydb_cluster_invalid_cluster_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" | ||
) | ||
|
||
// GoogleAlloydbClusterInvalidClusterTypeRule checks the pattern is valid | ||
type GoogleAlloydbClusterInvalidClusterTypeRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleAlloydbClusterInvalidClusterTypeRule returns new rule with default attributes | ||
func NewGoogleAlloydbClusterInvalidClusterTypeRule() *GoogleAlloydbClusterInvalidClusterTypeRule { | ||
return &GoogleAlloydbClusterInvalidClusterTypeRule{ | ||
resourceType: "google_alloydb_cluster", | ||
attributeName: "cluster_type", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Name() string { | ||
return "google_alloydb_cluster_invalid_cluster_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) 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{"PRIMARY", "SECONDARY", ""}, 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 | ||
} |
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
91 changes: 91 additions & 0 deletions
91
rules/magicmodules/google_alloydb_user_invalid_user_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" | ||
) | ||
|
||
// GoogleAlloydbUserInvalidUserTypeRule checks the pattern is valid | ||
type GoogleAlloydbUserInvalidUserTypeRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleAlloydbUserInvalidUserTypeRule returns new rule with default attributes | ||
func NewGoogleAlloydbUserInvalidUserTypeRule() *GoogleAlloydbUserInvalidUserTypeRule { | ||
return &GoogleAlloydbUserInvalidUserTypeRule{ | ||
resourceType: "google_alloydb_user", | ||
attributeName: "user_type", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleAlloydbUserInvalidUserTypeRule) Name() string { | ||
return "google_alloydb_user_invalid_user_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleAlloydbUserInvalidUserTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleAlloydbUserInvalidUserTypeRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleAlloydbUserInvalidUserTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleAlloydbUserInvalidUserTypeRule) 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{"ALLOYDB_BUILT_IN", "ALLOYDB_IAM_USER"}, 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_apigee_environment_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" | ||
) | ||
|
||
// GoogleApigeeEnvironmentInvalidTypeRule checks the pattern is valid | ||
type GoogleApigeeEnvironmentInvalidTypeRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleApigeeEnvironmentInvalidTypeRule returns new rule with default attributes | ||
func NewGoogleApigeeEnvironmentInvalidTypeRule() *GoogleApigeeEnvironmentInvalidTypeRule { | ||
return &GoogleApigeeEnvironmentInvalidTypeRule{ | ||
resourceType: "google_apigee_environment", | ||
attributeName: "type", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Name() string { | ||
return "google_apigee_environment_invalid_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleApigeeEnvironmentInvalidTypeRule) 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{"ENVIRONMENT_TYPE_UNSPECIFIED", "BASE", "INTERMEDIATE", "COMPREHENSIVE", ""}, 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 | ||
} |
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
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
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
Oops, something went wrong.