Skip to content

Commit 0584383

Browse files
authored
Update Magic Modules (#389)
1 parent 08ccd82 commit 0584383

File tree

52 files changed

+3496
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3496
-181
lines changed

rules/magicmodules/api_definition.go

Lines changed: 207 additions & 125 deletions
Large diffs are not rendered by default.
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-
// GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule checks the pattern is valid
24-
type GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule struct {
23+
// GoogleAlloydbClusterInvalidSubscriptionTypeRule checks the pattern is valid
24+
type GoogleAlloydbClusterInvalidSubscriptionTypeRule struct {
2525
tflint.DefaultRule
2626

2727
resourceType string
2828
attributeName string
2929
}
3030

31-
// NewGoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule returns new rule with default attributes
32-
func NewGoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule() *GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule {
33-
return &GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule{
34-
resourceType: "google_sql_source_representation_instance",
35-
attributeName: "database_version",
31+
// NewGoogleAlloydbClusterInvalidSubscriptionTypeRule returns new rule with default attributes
32+
func NewGoogleAlloydbClusterInvalidSubscriptionTypeRule() *GoogleAlloydbClusterInvalidSubscriptionTypeRule {
33+
return &GoogleAlloydbClusterInvalidSubscriptionTypeRule{
34+
resourceType: "google_alloydb_cluster",
35+
attributeName: "subscription_type",
3636
}
3737
}
3838

3939
// Name returns the rule name
40-
func (r *GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule) Name() string {
41-
return "google_sql_source_representation_instance_invalid_database_version"
40+
func (r *GoogleAlloydbClusterInvalidSubscriptionTypeRule) Name() string {
41+
return "google_alloydb_cluster_invalid_subscription_type"
4242
}
4343

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

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

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

5959
// Check checks the pattern is valid
60-
func (r *GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule) Check(runner tflint.Runner) error {
60+
func (r *GoogleAlloydbClusterInvalidSubscriptionTypeRule) 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 *GoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule) Check(
7272
}
7373

7474
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75-
validateFunc := validation.StringInSlice([]string{"MYSQL_5_6", "MYSQL_5_7", "MYSQL_8_0", "POSTGRES_9_6", "POSTGRES_10", "POSTGRES_11", "POSTGRES_12", "POSTGRES_13", "POSTGRES_14"}, false)
75+
validateFunc := validation.StringInSlice([]string{"TRIAL", "STANDARD", ""}, 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+
// GoogleApigeeAppGroupInvalidStatusRule checks the pattern is valid
24+
type GoogleApigeeAppGroupInvalidStatusRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleApigeeAppGroupInvalidStatusRule returns new rule with default attributes
32+
func NewGoogleApigeeAppGroupInvalidStatusRule() *GoogleApigeeAppGroupInvalidStatusRule {
33+
return &GoogleApigeeAppGroupInvalidStatusRule{
34+
resourceType: "google_apigee_app_group",
35+
attributeName: "status",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleApigeeAppGroupInvalidStatusRule) Name() string {
41+
return "google_apigee_app_group_invalid_status"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleApigeeAppGroupInvalidStatusRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleApigeeAppGroupInvalidStatusRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleApigeeAppGroupInvalidStatusRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleApigeeAppGroupInvalidStatusRule) 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{"active", "inactive", ""}, 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+
// GoogleBackupDrBackupVaultInvalidAccessRestrictionRule checks the pattern is valid
24+
type GoogleBackupDrBackupVaultInvalidAccessRestrictionRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleBackupDrBackupVaultInvalidAccessRestrictionRule returns new rule with default attributes
32+
func NewGoogleBackupDrBackupVaultInvalidAccessRestrictionRule() *GoogleBackupDrBackupVaultInvalidAccessRestrictionRule {
33+
return &GoogleBackupDrBackupVaultInvalidAccessRestrictionRule{
34+
resourceType: "google_backup_dr_backup_vault",
35+
attributeName: "access_restriction",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleBackupDrBackupVaultInvalidAccessRestrictionRule) Name() string {
41+
return "google_backup_dr_backup_vault_invalid_access_restriction"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleBackupDrBackupVaultInvalidAccessRestrictionRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleBackupDrBackupVaultInvalidAccessRestrictionRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleBackupDrBackupVaultInvalidAccessRestrictionRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleBackupDrBackupVaultInvalidAccessRestrictionRule) 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{"ACCESS_RESTRICTION_UNSPECIFIED", "WITHIN_PROJECT", "WITHIN_ORGANIZATION", "UNRESTRICTED", "WITHIN_ORG_BUT_UNRESTRICTED_FOR_BA", ""}, 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+
// GoogleBackupDrManagementServerInvalidTypeRule checks the pattern is valid
24+
type GoogleBackupDrManagementServerInvalidTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleBackupDrManagementServerInvalidTypeRule returns new rule with default attributes
32+
func NewGoogleBackupDrManagementServerInvalidTypeRule() *GoogleBackupDrManagementServerInvalidTypeRule {
33+
return &GoogleBackupDrManagementServerInvalidTypeRule{
34+
resourceType: "google_backup_dr_management_server",
35+
attributeName: "type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleBackupDrManagementServerInvalidTypeRule) Name() string {
41+
return "google_backup_dr_management_server_invalid_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleBackupDrManagementServerInvalidTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleBackupDrManagementServerInvalidTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleBackupDrManagementServerInvalidTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleBackupDrManagementServerInvalidTypeRule) 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{"BACKUP_RESTORE", ""}, 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+
}

0 commit comments

Comments
 (0)