Skip to content

Commit af0f1ab

Browse files
authored
Update Magic Modules (#315)
1 parent 7507382 commit af0f1ab

File tree

30 files changed

+1731
-60
lines changed

30 files changed

+1731
-60
lines changed

rules/magicmodules/google_cloudiot_registry_invalid_log_level.go renamed to rules/magicmodules/google_alloydb_backup_invalid_type.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,44 @@ import (
2020
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
2121
)
2222

23-
// GoogleCloudiotRegistryInvalidLogLevelRule checks the pattern is valid
24-
type GoogleCloudiotRegistryInvalidLogLevelRule struct {
23+
// GoogleAlloydbBackupInvalidTypeRule checks the pattern is valid
24+
type GoogleAlloydbBackupInvalidTypeRule struct {
2525
tflint.DefaultRule
2626

2727
resourceType string
2828
attributeName string
2929
}
3030

31-
// NewGoogleCloudiotRegistryInvalidLogLevelRule returns new rule with default attributes
32-
func NewGoogleCloudiotRegistryInvalidLogLevelRule() *GoogleCloudiotRegistryInvalidLogLevelRule {
33-
return &GoogleCloudiotRegistryInvalidLogLevelRule{
34-
resourceType: "google_cloudiot_registry",
35-
attributeName: "log_level",
31+
// NewGoogleAlloydbBackupInvalidTypeRule returns new rule with default attributes
32+
func NewGoogleAlloydbBackupInvalidTypeRule() *GoogleAlloydbBackupInvalidTypeRule {
33+
return &GoogleAlloydbBackupInvalidTypeRule{
34+
resourceType: "google_alloydb_backup",
35+
attributeName: "type",
3636
}
3737
}
3838

3939
// Name returns the rule name
40-
func (r *GoogleCloudiotRegistryInvalidLogLevelRule) Name() string {
41-
return "google_cloudiot_registry_invalid_log_level"
40+
func (r *GoogleAlloydbBackupInvalidTypeRule) Name() string {
41+
return "google_alloydb_backup_invalid_type"
4242
}
4343

4444
// Enabled returns whether the rule is enabled by default
45-
func (r *GoogleCloudiotRegistryInvalidLogLevelRule) Enabled() bool {
45+
func (r *GoogleAlloydbBackupInvalidTypeRule) Enabled() bool {
4646
return true
4747
}
4848

4949
// Severity returns the rule severity
50-
func (r *GoogleCloudiotRegistryInvalidLogLevelRule) Severity() tflint.Severity {
50+
func (r *GoogleAlloydbBackupInvalidTypeRule) Severity() tflint.Severity {
5151
return tflint.ERROR
5252
}
5353

5454
// Link returns the rule reference link
55-
func (r *GoogleCloudiotRegistryInvalidLogLevelRule) Link() string {
55+
func (r *GoogleAlloydbBackupInvalidTypeRule) Link() string {
5656
return ""
5757
}
5858

5959
// Check checks the pattern is valid
60-
func (r *GoogleCloudiotRegistryInvalidLogLevelRule) Check(runner tflint.Runner) error {
60+
func (r *GoogleAlloydbBackupInvalidTypeRule) Check(runner tflint.Runner) error {
6161
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
6262
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
6363
}, nil)
@@ -72,7 +72,7 @@ func (r *GoogleCloudiotRegistryInvalidLogLevelRule) Check(runner tflint.Runner)
7272
}
7373

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"NONE", "ERROR", "INFO", "DEBUG", ""}, false)
75+
validateFunc := validation.StringInSlice([]string{"TYPE_UNSPECIFIED", "ON_DEMAND", "AUTOMATED", "CONTINUOUS", ""}, false)
7676

7777
_, errors := validateFunc(val, r.attributeName)
7878
for _, err := range errors {
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+
// GoogleAlloydbClusterInvalidClusterTypeRule checks the pattern is valid
24+
type GoogleAlloydbClusterInvalidClusterTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleAlloydbClusterInvalidClusterTypeRule returns new rule with default attributes
32+
func NewGoogleAlloydbClusterInvalidClusterTypeRule() *GoogleAlloydbClusterInvalidClusterTypeRule {
33+
return &GoogleAlloydbClusterInvalidClusterTypeRule{
34+
resourceType: "google_alloydb_cluster",
35+
attributeName: "cluster_type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Name() string {
41+
return "google_alloydb_cluster_invalid_cluster_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleAlloydbClusterInvalidClusterTypeRule) 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{"PRIMARY", "SECONDARY", ""}, 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_alloydb_instance_invalid_instance_type.go

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

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"PRIMARY", "READ_POOL"}, false)
75+
validateFunc := validation.StringInSlice([]string{"PRIMARY", "READ_POOL", "SECONDARY"}, false)
7676

7777
_, errors := validateFunc(val, r.attributeName)
7878
for _, err := range errors {
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+
// GoogleAlloydbUserInvalidUserTypeRule checks the pattern is valid
24+
type GoogleAlloydbUserInvalidUserTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleAlloydbUserInvalidUserTypeRule returns new rule with default attributes
32+
func NewGoogleAlloydbUserInvalidUserTypeRule() *GoogleAlloydbUserInvalidUserTypeRule {
33+
return &GoogleAlloydbUserInvalidUserTypeRule{
34+
resourceType: "google_alloydb_user",
35+
attributeName: "user_type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleAlloydbUserInvalidUserTypeRule) Name() string {
41+
return "google_alloydb_user_invalid_user_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleAlloydbUserInvalidUserTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleAlloydbUserInvalidUserTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleAlloydbUserInvalidUserTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleAlloydbUserInvalidUserTypeRule) 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{"ALLOYDB_BUILT_IN", "ALLOYDB_IAM_USER"}, 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+
// GoogleApigeeEnvironmentInvalidTypeRule checks the pattern is valid
24+
type GoogleApigeeEnvironmentInvalidTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleApigeeEnvironmentInvalidTypeRule returns new rule with default attributes
32+
func NewGoogleApigeeEnvironmentInvalidTypeRule() *GoogleApigeeEnvironmentInvalidTypeRule {
33+
return &GoogleApigeeEnvironmentInvalidTypeRule{
34+
resourceType: "google_apigee_environment",
35+
attributeName: "type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Name() string {
41+
return "google_apigee_environment_invalid_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleApigeeEnvironmentInvalidTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleApigeeEnvironmentInvalidTypeRule) 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{"ENVIRONMENT_TYPE_UNSPECIFIED", "BASE", "INTERMEDIATE", "COMPREHENSIVE", ""}, 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_big_query_routine_invalid_routine_type.go

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

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"SCALAR_FUNCTION", "PROCEDURE", "TABLE_VALUED_FUNCTION", ""}, false)
75+
validateFunc := validation.StringInSlice([]string{"SCALAR_FUNCTION", "PROCEDURE", "TABLE_VALUED_FUNCTION"}, false)
7676

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

rules/magicmodules/google_compute_network_endpoint_group_invalid_network_endpoint_type.go

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

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"GCE_VM_IP", "GCE_VM_IP_PORT", "NON_GCP_PRIVATE_IP_PORT", ""}, false)
75+
validateFunc := validation.StringInSlice([]string{"GCE_VM_IP", "GCE_VM_IP_PORT", "NON_GCP_PRIVATE_IP_PORT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT", "SERVERLESS", "PRIVATE_SERVICE_CONNECT", ""}, false)
7676

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

rules/magicmodules/google_compute_router_nat_invalid_nat_ip_allocate_option.go

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

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"MANUAL_ONLY", "AUTO_ONLY"}, false)
75+
validateFunc := validation.StringInSlice([]string{"MANUAL_ONLY", "AUTO_ONLY", ""}, false)
7676

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

0 commit comments

Comments
 (0)