Skip to content

Update Magic Modules #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleApigeeEnvironmentInvalidApiProxyTypeRule checks the pattern is valid
type GoogleApigeeEnvironmentInvalidApiProxyTypeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule returns new rule with default attributes
func NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule() *GoogleApigeeEnvironmentInvalidApiProxyTypeRule {
return &GoogleApigeeEnvironmentInvalidApiProxyTypeRule{
resourceType: "google_apigee_environment",
attributeName: "api_proxy_type",
}
}

// Name returns the rule name
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Name() string {
return "google_apigee_environment_invalid_api_proxy_type"
}

// Enabled returns whether the rule is enabled by default
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Severity() tflint.Severity {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *GoogleApigeeEnvironmentInvalidApiProxyTypeRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

validateFunc := validation.StringInSlice([]string{"API_PROXY_TYPE_UNSPECIFIED", "PROGRAMMABLE", "CONFIGURABLE", ""}, false)

err = runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
}
return nil
})
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleApigeeEnvironmentInvalidDeploymentTypeRule checks the pattern is valid
type GoogleApigeeEnvironmentInvalidDeploymentTypeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule returns new rule with default attributes
func NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule() *GoogleApigeeEnvironmentInvalidDeploymentTypeRule {
return &GoogleApigeeEnvironmentInvalidDeploymentTypeRule{
resourceType: "google_apigee_environment",
attributeName: "deployment_type",
}
}

// Name returns the rule name
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Name() string {
return "google_apigee_environment_invalid_deployment_type"
}

// Enabled returns whether the rule is enabled by default
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Severity() tflint.Severity {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *GoogleApigeeEnvironmentInvalidDeploymentTypeRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

validateFunc := validation.StringInSlice([]string{"DEPLOYMENT_TYPE_UNSPECIFIED", "PROXY", "ARCHIVE", ""}, false)

err = runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
}
return nil
})
if err != nil {
return err
}
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package magicmodules

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleSpannerDatabaseInvalidDatabaseDialectRule checks the pattern is valid
type GoogleSpannerDatabaseInvalidDatabaseDialectRule struct {
tflint.DefaultRule

resourceType string
attributeName string
}

// NewGoogleSpannerDatabaseInvalidDatabaseDialectRule returns new rule with default attributes
func NewGoogleSpannerDatabaseInvalidDatabaseDialectRule() *GoogleSpannerDatabaseInvalidDatabaseDialectRule {
return &GoogleSpannerDatabaseInvalidDatabaseDialectRule{
resourceType: "google_spanner_database",
attributeName: "database_dialect",
}
}

// Name returns the rule name
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Name() string {
return "google_spanner_database_invalid_database_dialect"
}

// Enabled returns whether the rule is enabled by default
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Severity() tflint.Severity {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *GoogleSpannerDatabaseInvalidDatabaseDialectRule) Check(runner tflint.Runner) error {
resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: r.attributeName}},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

validateFunc := validation.StringInSlice([]string{"GOOGLE_STANDARD_SQL", "POSTGRESQL", ""}, false)

err = runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
}
return nil
})
if err != nil {
return err
}
}

return nil
}
3 changes: 3 additions & 0 deletions rules/magicmodules/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var Rules = []tflint.Rule{
NewGoogleAccessContextManagerServicePerimeterInvalidPerimeterTypeRule(),
NewGoogleActiveDirectoryDomainTrustInvalidTrustDirectionRule(),
NewGoogleActiveDirectoryDomainTrustInvalidTrustTypeRule(),
NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule(),
NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule(),
NewGoogleApigeeOrganizationInvalidRuntimeTypeRule(),
NewGoogleAppEngineDomainMappingInvalidOverrideStrategyRule(),
NewGoogleAppEngineFirewallRuleInvalidActionRule(),
Expand Down Expand Up @@ -128,6 +130,7 @@ var Rules = []tflint.Rule{
NewGoogleRedisInstanceInvalidTierRule(),
NewGoogleRedisInstanceInvalidTransitEncryptionModeRule(),
NewGoogleSccSourceInvalidDisplayNameRule(),
NewGoogleSpannerDatabaseInvalidDatabaseDialectRule(),
NewGoogleSpannerDatabaseInvalidNameRule(),
NewGoogleSpannerInstanceInvalidNameRule(),
NewGoogleSqlSourceRepresentationInstanceInvalidDatabaseVersionRule(),
Expand Down
2 changes: 1 addition & 1 deletion tools/magic-modules
Submodule magic-modules updated 289 files