Skip to content

Commit 93cb7cf

Browse files
authored
Update Magic Modules (#71)
1 parent c577e74 commit 93cb7cf

5 files changed

+85
-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+
// GoogleApigeeOrganizationInvalidRuntimeTypeRule checks the pattern is valid
24+
type GoogleApigeeOrganizationInvalidRuntimeTypeRule struct {
25+
resourceType string
26+
attributeName string
27+
}
28+
29+
// NewGoogleApigeeOrganizationInvalidRuntimeTypeRule returns new rule with default attributes
30+
func NewGoogleApigeeOrganizationInvalidRuntimeTypeRule() *GoogleApigeeOrganizationInvalidRuntimeTypeRule {
31+
return &GoogleApigeeOrganizationInvalidRuntimeTypeRule{
32+
resourceType: "google_apigee_organization",
33+
attributeName: "runtime_type",
34+
}
35+
}
36+
37+
// Name returns the rule name
38+
func (r *GoogleApigeeOrganizationInvalidRuntimeTypeRule) Name() string {
39+
return "google_apigee_organization_invalid_runtime_type"
40+
}
41+
42+
// Enabled returns whether the rule is enabled by default
43+
func (r *GoogleApigeeOrganizationInvalidRuntimeTypeRule) Enabled() bool {
44+
return true
45+
}
46+
47+
// Severity returns the rule severity
48+
func (r *GoogleApigeeOrganizationInvalidRuntimeTypeRule) Severity() string {
49+
return tflint.ERROR
50+
}
51+
52+
// Link returns the rule reference link
53+
func (r *GoogleApigeeOrganizationInvalidRuntimeTypeRule) Link() string {
54+
return ""
55+
}
56+
57+
// Check checks the pattern is valid
58+
func (r *GoogleApigeeOrganizationInvalidRuntimeTypeRule) 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{"CLOUD", "HYBRID", ""}, 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_sql_source_representation_instance_invalid_database_version.go

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

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

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

rules/magicmodules/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var Rules = []tflint.Rule{
2323
NewGoogleAccessContextManagerServicePerimeterInvalidPerimeterTypeRule(),
2424
NewGoogleActiveDirectoryDomainTrustInvalidTrustDirectionRule(),
2525
NewGoogleActiveDirectoryDomainTrustInvalidTrustTypeRule(),
26+
NewGoogleApigeeOrganizationInvalidRuntimeTypeRule(),
2627
NewGoogleAppEngineDomainMappingInvalidOverrideStrategyRule(),
2728
NewGoogleAppEngineFirewallRuleInvalidActionRule(),
2829
NewGoogleAppEngineFlexibleAppVersionInvalidServingStatusRule(),

rules/magicmodules/validation.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package magicmodules
22

33
import (
4+
"encoding/base64"
45
"fmt"
56
"net"
67
"regexp"
@@ -265,6 +266,14 @@ func validateIpAddress(i interface{}, val string) ([]string, []error) {
265266
return nil, nil
266267
}
267268

269+
func validateBase64String(i interface{}, val string) ([]string, []error) {
270+
_, err := base64.StdEncoding.DecodeString(i.(string))
271+
if err != nil {
272+
return nil, []error{fmt.Errorf("could not decode %q as a valid base64 value. Please use the terraform base64 functions such as base64encode() or filebase64() to supply a valid base64 string", val)}
273+
}
274+
return nil, nil
275+
}
276+
268277
// StringNotInSlice returns a SchemaValidateFunc which tests if the provided value
269278
// is of type string and that it matches none of the element in the invalid slice.
270279
// if ignorecase is true, case is ignored.

tools/magic-modules

Submodule magic-modules updated 2642 files

0 commit comments

Comments
 (0)