Skip to content

Commit 719353e

Browse files
authored
Update Magic Modules (#224)
1 parent f03f5db commit 719353e

8 files changed

+443
-7
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
15+
package magicmodules
16+
17+
import (
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
19+
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
20+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
21+
)
22+
23+
// GoogleCloudIdsEndpointInvalidSeverityRule checks the pattern is valid
24+
type GoogleCloudIdsEndpointInvalidSeverityRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleCloudIdsEndpointInvalidSeverityRule returns new rule with default attributes
32+
func NewGoogleCloudIdsEndpointInvalidSeverityRule() *GoogleCloudIdsEndpointInvalidSeverityRule {
33+
return &GoogleCloudIdsEndpointInvalidSeverityRule{
34+
resourceType: "google_cloud_ids_endpoint",
35+
attributeName: "severity",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleCloudIdsEndpointInvalidSeverityRule) Name() string {
41+
return "google_cloud_ids_endpoint_invalid_severity"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleCloudIdsEndpointInvalidSeverityRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleCloudIdsEndpointInvalidSeverityRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleCloudIdsEndpointInvalidSeverityRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleCloudIdsEndpointInvalidSeverityRule) Check(runner tflint.Runner) error {
61+
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
62+
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
63+
}, nil)
64+
if err != nil {
65+
return err
66+
}
67+
68+
for _, resource := range resources.Blocks {
69+
attribute, exists := resource.Body.Attributes[r.attributeName]
70+
if !exists {
71+
continue
72+
}
73+
74+
var val string
75+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
76+
77+
validateFunc := validation.StringInSlice([]string{"INFORMATIONAL", "LOW", "MEDIUM", "HIGH", "CRITICAL"}, false)
78+
79+
err = runner.EnsureNoError(err, func() error {
80+
_, errors := validateFunc(val, r.attributeName)
81+
for _, err := range errors {
82+
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
83+
}
84+
return nil
85+
})
86+
if err != nil {
87+
return err
88+
}
89+
}
90+
91+
return nil
92+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
15+
package magicmodules
16+
17+
import (
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
19+
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
20+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
21+
)
22+
23+
// GoogleComputeBackendBucketInvalidCompressionModeRule checks the pattern is valid
24+
type GoogleComputeBackendBucketInvalidCompressionModeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleComputeBackendBucketInvalidCompressionModeRule returns new rule with default attributes
32+
func NewGoogleComputeBackendBucketInvalidCompressionModeRule() *GoogleComputeBackendBucketInvalidCompressionModeRule {
33+
return &GoogleComputeBackendBucketInvalidCompressionModeRule{
34+
resourceType: "google_compute_backend_bucket",
35+
attributeName: "compression_mode",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleComputeBackendBucketInvalidCompressionModeRule) Name() string {
41+
return "google_compute_backend_bucket_invalid_compression_mode"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleComputeBackendBucketInvalidCompressionModeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleComputeBackendBucketInvalidCompressionModeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleComputeBackendBucketInvalidCompressionModeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleComputeBackendBucketInvalidCompressionModeRule) Check(runner tflint.Runner) error {
61+
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
62+
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
63+
}, nil)
64+
if err != nil {
65+
return err
66+
}
67+
68+
for _, resource := range resources.Blocks {
69+
attribute, exists := resource.Body.Attributes[r.attributeName]
70+
if !exists {
71+
continue
72+
}
73+
74+
var val string
75+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
76+
77+
validateFunc := validation.StringInSlice([]string{"AUTOMATIC", "DISABLED", ""}, false)
78+
79+
err = runner.EnsureNoError(err, func() error {
80+
_, errors := validateFunc(val, r.attributeName)
81+
for _, err := range errors {
82+
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
83+
}
84+
return nil
85+
})
86+
if err != nil {
87+
return err
88+
}
89+
}
90+
91+
return nil
92+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
15+
package magicmodules
16+
17+
import (
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
19+
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
20+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
21+
)
22+
23+
// GoogleComputeBackendServiceInvalidCompressionModeRule checks the pattern is valid
24+
type GoogleComputeBackendServiceInvalidCompressionModeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleComputeBackendServiceInvalidCompressionModeRule returns new rule with default attributes
32+
func NewGoogleComputeBackendServiceInvalidCompressionModeRule() *GoogleComputeBackendServiceInvalidCompressionModeRule {
33+
return &GoogleComputeBackendServiceInvalidCompressionModeRule{
34+
resourceType: "google_compute_backend_service",
35+
attributeName: "compression_mode",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleComputeBackendServiceInvalidCompressionModeRule) Name() string {
41+
return "google_compute_backend_service_invalid_compression_mode"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleComputeBackendServiceInvalidCompressionModeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleComputeBackendServiceInvalidCompressionModeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleComputeBackendServiceInvalidCompressionModeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleComputeBackendServiceInvalidCompressionModeRule) Check(runner tflint.Runner) error {
61+
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
62+
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
63+
}, nil)
64+
if err != nil {
65+
return err
66+
}
67+
68+
for _, resource := range resources.Blocks {
69+
attribute, exists := resource.Body.Attributes[r.attributeName]
70+
if !exists {
71+
continue
72+
}
73+
74+
var val string
75+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
76+
77+
validateFunc := validation.StringInSlice([]string{"AUTOMATIC", "DISABLED", ""}, false)
78+
79+
err = runner.EnsureNoError(err, func() error {
80+
_, errors := validateFunc(val, r.attributeName)
81+
for _, err := range errors {
82+
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
83+
}
84+
return nil
85+
})
86+
if err != nil {
87+
return err
88+
}
89+
}
90+
91+
return nil
92+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
15+
package magicmodules
16+
17+
import (
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
19+
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
20+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
21+
)
22+
23+
// GoogleTagsTagKeyInvalidPurposeRule checks the pattern is valid
24+
type GoogleTagsTagKeyInvalidPurposeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleTagsTagKeyInvalidPurposeRule returns new rule with default attributes
32+
func NewGoogleTagsTagKeyInvalidPurposeRule() *GoogleTagsTagKeyInvalidPurposeRule {
33+
return &GoogleTagsTagKeyInvalidPurposeRule{
34+
resourceType: "google_tags_tag_key",
35+
attributeName: "purpose",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleTagsTagKeyInvalidPurposeRule) Name() string {
41+
return "google_tags_tag_key_invalid_purpose"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleTagsTagKeyInvalidPurposeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleTagsTagKeyInvalidPurposeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleTagsTagKeyInvalidPurposeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleTagsTagKeyInvalidPurposeRule) Check(runner tflint.Runner) error {
61+
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
62+
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
63+
}, nil)
64+
if err != nil {
65+
return err
66+
}
67+
68+
for _, resource := range resources.Blocks {
69+
attribute, exists := resource.Body.Attributes[r.attributeName]
70+
if !exists {
71+
continue
72+
}
73+
74+
var val string
75+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
76+
77+
validateFunc := validation.StringInSlice([]string{"GCE_FIREWALL", ""}, false)
78+
79+
err = runner.EnsureNoError(err, func() error {
80+
_, errors := validateFunc(val, r.attributeName)
81+
for _, err := range errors {
82+
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
83+
}
84+
return nil
85+
})
86+
if err != nil {
87+
return err
88+
}
89+
}
90+
91+
return nil
92+
}

0 commit comments

Comments
 (0)