Skip to content

Commit 72ad658

Browse files
authored
Update Magic Modules (#174)
1 parent 3194c98 commit 72ad658

5 files changed

+280
-1
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+
// GoogleApigeeEnvironmentInvalidApiProxyTypeRule checks the pattern is valid
24+
type GoogleApigeeEnvironmentInvalidApiProxyTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule returns new rule with default attributes
32+
func NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule() *GoogleApigeeEnvironmentInvalidApiProxyTypeRule {
33+
return &GoogleApigeeEnvironmentInvalidApiProxyTypeRule{
34+
resourceType: "google_apigee_environment",
35+
attributeName: "api_proxy_type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Name() string {
41+
return "google_apigee_environment_invalid_api_proxy_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) 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{"API_PROXY_TYPE_UNSPECIFIED", "PROGRAMMABLE", "CONFIGURABLE", ""}, 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+
// GoogleApigeeEnvironmentInvalidDeploymentTypeRule checks the pattern is valid
24+
type GoogleApigeeEnvironmentInvalidDeploymentTypeRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule returns new rule with default attributes
32+
func NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule() *GoogleApigeeEnvironmentInvalidDeploymentTypeRule {
33+
return &GoogleApigeeEnvironmentInvalidDeploymentTypeRule{
34+
resourceType: "google_apigee_environment",
35+
attributeName: "deployment_type",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Name() string {
41+
return "google_apigee_environment_invalid_deployment_type"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) 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{"DEPLOYMENT_TYPE_UNSPECIFIED", "PROXY", "ARCHIVE", ""}, 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+
// GoogleSpannerDatabaseInvalidDatabaseDialectRule checks the pattern is valid
24+
type GoogleSpannerDatabaseInvalidDatabaseDialectRule struct {
25+
tflint.DefaultRule
26+
27+
resourceType string
28+
attributeName string
29+
}
30+
31+
// NewGoogleSpannerDatabaseInvalidDatabaseDialectRule returns new rule with default attributes
32+
func NewGoogleSpannerDatabaseInvalidDatabaseDialectRule() *GoogleSpannerDatabaseInvalidDatabaseDialectRule {
33+
return &GoogleSpannerDatabaseInvalidDatabaseDialectRule{
34+
resourceType: "google_spanner_database",
35+
attributeName: "database_dialect",
36+
}
37+
}
38+
39+
// Name returns the rule name
40+
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Name() string {
41+
return "google_spanner_database_invalid_database_dialect"
42+
}
43+
44+
// Enabled returns whether the rule is enabled by default
45+
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Enabled() bool {
46+
return true
47+
}
48+
49+
// Severity returns the rule severity
50+
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Severity() tflint.Severity {
51+
return tflint.ERROR
52+
}
53+
54+
// Link returns the rule reference link
55+
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Link() string {
56+
return ""
57+
}
58+
59+
// Check checks the pattern is valid
60+
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) 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{"GOOGLE_STANDARD_SQL", "POSTGRESQL", ""}, 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+
}

rules/magicmodules/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var Rules = []tflint.Rule{
2323
NewGoogleAccessContextManagerServicePerimeterInvalidPerimeterTypeRule(),
2424
NewGoogleActiveDirectoryDomainTrustInvalidTrustDirectionRule(),
2525
NewGoogleActiveDirectoryDomainTrustInvalidTrustTypeRule(),
26+
NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule(),
27+
NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule(),
2628
NewGoogleApigeeOrganizationInvalidRuntimeTypeRule(),
2729
NewGoogleAppEngineDomainMappingInvalidOverrideStrategyRule(),
2830
NewGoogleAppEngineFirewallRuleInvalidActionRule(),
@@ -128,6 +130,7 @@ var Rules = []tflint.Rule{
128130
NewGoogleRedisInstanceInvalidTierRule(),
129131
NewGoogleRedisInstanceInvalidTransitEncryptionModeRule(),
130132
NewGoogleSccSourceInvalidDisplayNameRule(),
133+
NewGoogleSpannerDatabaseInvalidDatabaseDialectRule(),
131134
NewGoogleSpannerDatabaseInvalidNameRule(),
132135
NewGoogleSpannerInstanceInvalidNameRule(),
133136
NewGoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule(),

tools/magic-modules

Submodule magic-modules updated 289 files

0 commit comments

Comments
 (0)