Skip to content

Commit

Permalink
Update Magic Modules (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Apr 9, 2023
1 parent 020c571 commit 892c940
Show file tree
Hide file tree
Showing 151 changed files with 2,394 additions and 1,552 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ----------------------------------------------------------------------------
//
// *** 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"
)

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

resourceType string
attributeName string
}

// NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule returns new rule with default attributes
func NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule() *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule {
return &GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule{
resourceType: "google_access_context_manager_authorized_orgs_desc",
attributeName: "asset_type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAssetTypeRule) 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
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"ASSET_TYPE_DEVICE", "ASSET_TYPE_CREDENTIAL_STRENGTH", ""}, false)

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

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ----------------------------------------------------------------------------
//
// *** 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"
)

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

resourceType string
attributeName string
}

// NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule returns new rule with default attributes
func NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule() *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule {
return &GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule{
resourceType: "google_access_context_manager_authorized_orgs_desc",
attributeName: "authorization_direction",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationDirectionRule) 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
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"AUTHORIZATION_DIRECTION_TO", "AUTHORIZATION_DIRECTION_FROM", ""}, false)

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

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ----------------------------------------------------------------------------
//
// *** 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"
)

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

resourceType string
attributeName string
}

// NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule returns new rule with default attributes
func NewGoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule() *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule {
return &GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule{
resourceType: "google_access_context_manager_authorized_orgs_desc",
attributeName: "authorization_type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleAccessContextManagerAuthorizedOrgsDescInvalidAuthorizationTypeRule) 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
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"AUTHORIZATION_TYPE_TRUST", ""}, false)

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

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ func (r *GoogleAccessContextManagerServicePerimeterInvalidPerimeterTypeRule) Che
continue
}

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

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

err = runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
})
}, nil)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ func (r *GoogleActiveDirectoryDomainTrustInvalidTrustDirectionRule) Check(runner
continue
}

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

validateFunc := validation.StringInSlice([]string{"INBOUND", "OUTBOUND", "BIDIRECTIONAL"}, false)

err = runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
})
}, nil)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ func (r *GoogleActiveDirectoryDomainTrustInvalidTrustTypeRule) Check(runner tfli
continue
}

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

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

err = runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssue(r, err.Error(), attribute.Expr.Range())
if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil {
return err
}
}
return nil
})
}, nil)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ func (r *GoogleAlloydbInstanceInvalidAvailabilityTypeRule) Check(runner tflint.R
continue
}

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

validateFunc := validation.StringInSlice([]string{"AVAILABILITY_TYPE_UNSPECIFIED", "ZONAL", "REGIONAL", ""}, false)

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

0 comments on commit 892c940

Please sign in to comment.