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
5 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
rules/magicmodules/google_compute_interconnect_attachment_invalid_encryption.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,73 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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 ( | ||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// GoogleComputeInterconnectAttachmentInvalidEncryptionRule checks the pattern is valid | ||
type GoogleComputeInterconnectAttachmentInvalidEncryptionRule struct { | ||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGoogleComputeInterconnectAttachmentInvalidEncryptionRule returns new rule with default attributes | ||
func NewGoogleComputeInterconnectAttachmentInvalidEncryptionRule() *GoogleComputeInterconnectAttachmentInvalidEncryptionRule { | ||
return &GoogleComputeInterconnectAttachmentInvalidEncryptionRule{ | ||
resourceType: "google_compute_interconnect_attachment", | ||
attributeName: "encryption", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GoogleComputeInterconnectAttachmentInvalidEncryptionRule) Name() string { | ||
return "google_compute_interconnect_attachment_invalid_encryption" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GoogleComputeInterconnectAttachmentInvalidEncryptionRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GoogleComputeInterconnectAttachmentInvalidEncryptionRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GoogleComputeInterconnectAttachmentInvalidEncryptionRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GoogleComputeInterconnectAttachmentInvalidEncryptionRule) Check(runner tflint.Runner) error { | ||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
validateFunc := validation.StringInSlice([]string{"NONE", "IPSEC", ""}, false) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
_, errors := validateFunc(val, r.attributeName) | ||
for _, err := range errors { | ||
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr) | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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 ( | ||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
) | ||
|
||
// GooglePubsubSchemaInvalidTypeRule checks the pattern is valid | ||
type GooglePubsubSchemaInvalidTypeRule struct { | ||
resourceType string | ||
attributeName string | ||
} | ||
|
||
// NewGooglePubsubSchemaInvalidTypeRule returns new rule with default attributes | ||
func NewGooglePubsubSchemaInvalidTypeRule() *GooglePubsubSchemaInvalidTypeRule { | ||
return &GooglePubsubSchemaInvalidTypeRule{ | ||
resourceType: "google_pubsub_schema", | ||
attributeName: "type", | ||
} | ||
} | ||
|
||
// Name returns the rule name | ||
func (r *GooglePubsubSchemaInvalidTypeRule) Name() string { | ||
return "google_pubsub_schema_invalid_type" | ||
} | ||
|
||
// Enabled returns whether the rule is enabled by default | ||
func (r *GooglePubsubSchemaInvalidTypeRule) Enabled() bool { | ||
return true | ||
} | ||
|
||
// Severity returns the rule severity | ||
func (r *GooglePubsubSchemaInvalidTypeRule) Severity() string { | ||
return tflint.ERROR | ||
} | ||
|
||
// Link returns the rule reference link | ||
func (r *GooglePubsubSchemaInvalidTypeRule) Link() string { | ||
return "" | ||
} | ||
|
||
// Check checks the pattern is valid | ||
func (r *GooglePubsubSchemaInvalidTypeRule) Check(runner tflint.Runner) error { | ||
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { | ||
var val string | ||
err := runner.EvaluateExpr(attribute.Expr, &val, nil) | ||
|
||
validateFunc := validation.StringInSlice([]string{"TYPE_UNSPECIFIED", "PROTOCOL_BUFFER", "AVRO", ""}, false) | ||
|
||
return runner.EnsureNoError(err, func() error { | ||
_, errors := validateFunc(val, r.attributeName) | ||
for _, err := range errors { | ||
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr) | ||
} | ||
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
Submodule magic-modules
updated
137 files