Skip to content

Commit 0a397b5

Browse files
Update Magic Modules (#416)
Co-authored-by: wata727 <9624059+wata727@users.noreply.github.com>
1 parent 3885fa3 commit 0a397b5

21 files changed

+1433
-5
lines changed

rules/magicmodules/api_definition.go

Lines changed: 39 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
// GoogleAlloydbInstanceInvalidActivationPolicyRule checks the pattern is valid
24+
type GoogleAlloydbInstanceInvalidActivationPolicyRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleAlloydbInstanceInvalidActivationPolicyRule returns new rule with default attributes
32+
func NewGoogleAlloydbInstanceInvalidActivationPolicyRule() *GoogleAlloydbInstanceInvalidActivationPolicyRule {
33+
return &GoogleAlloydbInstanceInvalidActivationPolicyRule{
34+
resourceType: "google_alloydb_instance",
35+
attributeName: "activation_policy",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Name() string {
41+
return "google_alloydb_instance_invalid_activation_policy"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) 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+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"ACTIVATION_POLICY_UNSPECIFIED", "ALWAYS", "NEVER", ""}, false)
76+
77+
_, errors := validateFunc(val, r.attributeName)
78+
for _, err := range errors {
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
82+
}
83+
return nil
84+
}, nil)
85+
if err != nil {
86+
return err
87+
}
88+
}
89+
90+
return nil
91+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
// GoogleBigqueryRoutineInvalidSecurityModeRule checks the pattern is valid
24+
type GoogleBigqueryRoutineInvalidSecurityModeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleBigqueryRoutineInvalidSecurityModeRule returns new rule with default attributes
32+
func NewGoogleBigqueryRoutineInvalidSecurityModeRule() *GoogleBigqueryRoutineInvalidSecurityModeRule {
33+
return &GoogleBigqueryRoutineInvalidSecurityModeRule{
34+
resourceType: "google_bigquery_routine",
35+
attributeName: "security_mode",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Name() string {
41+
return "google_bigquery_routine_invalid_security_mode"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) 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+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"DEFINER", "INVOKER", ""}, false)
76+
77+
_, errors := validateFunc(val, r.attributeName)
78+
for _, err := range errors {
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
82+
}
83+
return nil
84+
}, nil)
85+
if err != nil {
86+
return err
87+
}
88+
}
89+
90+
return nil
91+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
// GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule checks the pattern is valid
24+
type GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleCloudRunV2WorkerPoolInvalidLaunchStageRule returns new rule with default attributes
32+
func NewGoogleCloudRunV2WorkerPoolInvalidLaunchStageRule() *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule {
33+
return &GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule{
34+
resourceType: "google_cloud_run_v2_worker_pool",
35+
attributeName: "launch_stage",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Name() string {
41+
return "google_cloud_run_v2_worker_pool_invalid_launch_stage"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) 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+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"UNIMPLEMENTED", "PRELAUNCH", "EARLY_ACCESS", "ALPHA", "BETA", "GA", "DEPRECATED", ""}, false)
76+
77+
_, errors := validateFunc(val, r.attributeName)
78+
for _, err := range errors {
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
82+
}
83+
return nil
84+
}, nil)
85+
if err != nil {
86+
return err
87+
}
88+
}
89+
90+
return nil
91+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
// GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule checks the pattern is valid
24+
type GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule returns new rule with default attributes
32+
func NewGoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule() *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule {
33+
return &GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule{
34+
resourceType: "google_compute_backend_service",
35+
attributeName: "external_managed_migration_state",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Name() string {
41+
return "google_compute_backend_service_invalid_external_managed_migration_state"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) 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+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"PREPARE", "TEST_BY_PERCENTAGE", "TEST_ALL_TRAFFIC", ""}, false)
76+
77+
_, errors := validateFunc(val, r.attributeName)
78+
for _, err := range errors {
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
82+
}
83+
return nil
84+
}, nil)
85+
if err != nil {
86+
return err
87+
}
88+
}
89+
90+
return nil
91+
}

rules/magicmodules/google_compute_backend_service_invalid_protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (r *GoogleComputeBackendServiceInvalidProtocolRule) Check(runner tflint.Run
7272
}
7373

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", "UNSPECIFIED", ""}, false)
75+
validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "UDP", "GRPC", "UNSPECIFIED", "H2C", ""}, false)
7676

7777
_, errors := validateFunc(val, r.attributeName)
7878
for _, err := range errors {

0 commit comments

Comments
 (0)