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
13 changed files
with
800 additions
and
273 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
...icmodules/google_certificate_manager_certificate_issuance_config_invalid_key_algorithm.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" | ||
) | ||
|
||
// GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule checks the pattern is valid | ||
type GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule returns new rule with default attributes | ||
func NewGoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule() *GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule { | ||
return &GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule{ | ||
resourceType: "google_certificate_manager_certificate_issuance_config", | ||
attributeName: "key_algorithm", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule) Name() string { | ||
return "google_certificate_manager_certificate_issuance_config_invalid_key_algorithm" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleCertificateManagerCertificateIssuanceConfigInvalidKeyAlgorithmRule) 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{"RSA_2048", "ECDSA_P256"}, 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
91 changes: 91 additions & 0 deletions
91
rules/magicmodules/google_compute_region_commitment_invalid_category.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" | ||
) | ||
|
||
// GoogleComputeRegionCommitmentInvalidCategoryRule checks the pattern is valid | ||
type GoogleComputeRegionCommitmentInvalidCategoryRule struct { | ||
tflint.DefaultRule | ||
|
||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleComputeRegionCommitmentInvalidCategoryRule returns new rule with default attributes | ||
func NewGoogleComputeRegionCommitmentInvalidCategoryRule() *GoogleComputeRegionCommitmentInvalidCategoryRule { | ||
return &GoogleComputeRegionCommitmentInvalidCategoryRule{ | ||
resourceType: "google_compute_region_commitment", | ||
attributeName: "category", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleComputeRegionCommitmentInvalidCategoryRule) Name() string { | ||
return "google_compute_region_commitment_invalid_category" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleComputeRegionCommitmentInvalidCategoryRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleComputeRegionCommitmentInvalidCategoryRule) Severity() tflint.Severity { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleComputeRegionCommitmentInvalidCategoryRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleComputeRegionCommitmentInvalidCategoryRule) 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{"LICENSE", "MACHINE", ""}, 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
Oops, something went wrong.