Skip to content

Commit 4b56d1b

Browse files
authored
Update Magic Modules (#79)
1 parent 9b4718a commit 4b56d1b

File tree

5 files changed

+960
-2
lines changed

5 files changed

+960
-2
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
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+
hcl "github.com/hashicorp/hcl/v2"
19+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
20+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
21+
)
22+
23+
// GoogleApigeeInstanceInvalidPeeringCidrRangeRule checks the pattern is valid
24+
type GoogleApigeeInstanceInvalidPeeringCidrRangeRule struct {
25+
resourceType string
26+
attributeName string
27+
}
28+
29+
// NewGoogleApigeeInstanceInvalidPeeringCidrRangeRule returns new rule with default attributes
30+
func NewGoogleApigeeInstanceInvalidPeeringCidrRangeRule() *GoogleApigeeInstanceInvalidPeeringCidrRangeRule {
31+
return &GoogleApigeeInstanceInvalidPeeringCidrRangeRule{
32+
resourceType: "google_apigee_instance",
33+
attributeName: "peering_cidr_range",
34+
}
35+
}
36+
37+
// Name returns the rule name
38+
func (r *GoogleApigeeInstanceInvalidPeeringCidrRangeRule) Name() string {
39+
return "google_apigee_instance_invalid_peering_cidr_range"
40+
}
41+
42+
// Enabled returns whether the rule is enabled by default
43+
func (r *GoogleApigeeInstanceInvalidPeeringCidrRangeRule) Enabled() bool {
44+
return true
45+
}
46+
47+
// Severity returns the rule severity
48+
func (r *GoogleApigeeInstanceInvalidPeeringCidrRangeRule) Severity() string {
49+
return tflint.ERROR
50+
}
51+
52+
// Link returns the rule reference link
53+
func (r *GoogleApigeeInstanceInvalidPeeringCidrRangeRule) Link() string {
54+
return ""
55+
}
56+
57+
// Check checks the pattern is valid
58+
func (r *GoogleApigeeInstanceInvalidPeeringCidrRangeRule) Check(runner tflint.Runner) error {
59+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
60+
var val string
61+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
62+
63+
validateFunc := validation.StringInSlice([]string{"SLASH_16", "SLASH_20", ""}, false)
64+
65+
return runner.EnsureNoError(err, func() error {
66+
_, errors := validateFunc(val, r.attributeName)
67+
for _, err := range errors {
68+
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr)
69+
}
70+
return nil
71+
})
72+
})
73+
}

rules/magicmodules/google_compute_global_address_invalid_purpose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (r *GoogleComputeGlobalAddressInvalidPurposeRule) Check(runner tflint.Runne
6060
var val string
6161
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
6262

63-
validateFunc := validation.StringInSlice([]string{"VPC_PEERING", ""}, false)
63+
validateFunc := validation.StringInSlice([]string{"VPC_PEERING", "PRIVATE_SERVICE_CONNECT", ""}, false)
6464

6565
return runner.EnsureNoError(err, func() error {
6666
_, errors := validateFunc(val, r.attributeName)

0 commit comments

Comments
 (0)