Skip to content

Commit 892c940

Browse files
authored
Update Magic Modules (#262)
1 parent 020c571 commit 892c940

File tree

151 files changed

+2394
-1552
lines changed

Some content is hidden

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

151 files changed

+2394
-1552
lines changed
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+
// GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule checks the pattern is valid
24+
type GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule returns new rule with default attributes
32+
func NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule() *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule {
33+
return &GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule{
34+
resourceType: "google_access_context_manager_authorized_orgs_desc",
35+
attributeName: "asset_type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule) Name() string {
41+
return "google_access_context_manager_authorized_orgs_desc_invalid_asset_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule) 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{"ASSET_TYPE_DEVICE", "ASSET_TYPE_CREDENTIAL_STRENGTH", ""}, 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+
}
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+
// GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule checks the pattern is valid
24+
type GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule returns new rule with default attributes
32+
func NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule() *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule {
33+
return &GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule{
34+
resourceType: "google_access_context_manager_authorized_orgs_desc",
35+
attributeName: "authorization_direction",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule) Name() string {
41+
return "google_access_context_manager_authorized_orgs_desc_invalid_authorization_direction"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule) 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{"AUTHORIZATION_DIRECTION_TO", "AUTHORIZATION_DIRECTION_FROM", ""}, 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+
// GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule checks the pattern is valid
24+
type GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule returns new rule with default attributes
32+
func NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule() *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule {
33+
return &GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule{
34+
resourceType: "google_access_context_manager_authorized_orgs_desc",
35+
attributeName: "authorization_type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule) Name() string {
41+
return "google_access_context_manager_authorized_orgs_desc_invalid_authorization_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule) 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{"AUTHORIZATION_TYPE_TRUST", ""}, 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_access_context_manager_service_perimeter_invalid_perimeter_type.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ func (r *GoogleAccessContextManagerServicePerimeterInvalidPerimeterTypeRule) Che
7171
continue
7272
}
7373

74-
var val string
75-
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
74+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"PERIMETER_TYPE_REGULAR", "PERIMETER_TYPE_BRIDGE", ""}, false)
7676

77-
validateFunc := validation.StringInSlice([]string{"PERIMETER_TYPE_REGULAR", "PERIMETER_TYPE_BRIDGE", ""}, false)
78-
79-
err = runner.EnsureNoError(err, func() error {
8077
_, errors := validateFunc(val, r.attributeName)
8178
for _, err := range errors {
82-
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
8382
}
8483
return nil
85-
})
84+
}, nil)
8685
if err != nil {
8786
return err
8887
}

rules/magicmodules/google_active_directory_domain_trust_invalid_trust_direction.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ func (r *GoogleActiveDirectoryDomainTrustInvalidTrustDirectionRule) Check(runner
7171
continue
7272
}
7373

74-
var val string
75-
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
74+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"INBOUND", "OUTBOUND", "BIDIRECTIONAL"}, false)
7676

77-
validateFunc := validation.StringInSlice([]string{"INBOUND", "OUTBOUND", "BIDIRECTIONAL"}, false)
78-
79-
err = runner.EnsureNoError(err, func() error {
8077
_, errors := validateFunc(val, r.attributeName)
8178
for _, err := range errors {
82-
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
8382
}
8483
return nil
85-
})
84+
}, nil)
8685
if err != nil {
8786
return err
8887
}

rules/magicmodules/google_active_directory_domain_trust_invalid_trust_type.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ func (r *GoogleActiveDirectoryDomainTrustInvalidTrustTypeRule) Check(runner tfli
7171
continue
7272
}
7373

74-
var val string
75-
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
74+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"FOREST", "EXTERNAL"}, false)
7676

77-
validateFunc := validation.StringInSlice([]string{"FOREST", "EXTERNAL"}, false)
78-
79-
err = runner.EnsureNoError(err, func() error {
8077
_, errors := validateFunc(val, r.attributeName)
8178
for _, err := range errors {
82-
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
8382
}
8483
return nil
85-
})
84+
}, nil)
8685
if err != nil {
8786
return err
8887
}

rules/magicmodules/google_alloydb_instance_invalid_availability_type.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ func (r *GoogleAlloydbInstanceInvalidAvailabilityTypeRule) Check(runner tflint.R
7171
continue
7272
}
7373

74-
var val string
75-
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
74+
err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
75+
validateFunc := validation.StringInSlice([]string{"AVAILABILITY_TYPE_UNSPECIFIED", "ZONAL", "REGIONAL", ""}, false)
7676

77-
validateFunc := validation.StringInSlice([]string{"AVAILABILITY_TYPE_UNSPECIFIED", "ZONAL", "REGIONAL", ""}, false)
78-
79-
err = runner.EnsureNoError(err, func() error {
8077
_, errors := validateFunc(val, r.attributeName)
8178
for _, err := range errors {
82-
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
79+
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
80+
return err
81+
}
8382
}
8483
return nil
85-
})
84+
}, nil)
8685
if err != nil {
8786
return err
8887
}

0 commit comments

Comments
 (0)