Skip to content
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

Update Magic Modules #297

Merged
merged 1 commit into from
Sep 10, 2023
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
91 changes: 91 additions & 0 deletions rules/magicmodules/google_apigee_target_server_invalid_protocol.go
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"
)

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

resourceType string
attributeName string
}

// NewGoogleApigeeTargetServerInvalidProtocolRule returns new rule with default attributes
func NewGoogleApigeeTargetServerInvalidProtocolRule() *GoogleApigeeTargetServerInvalidProtocolRule {
return &GoogleApigeeTargetServerInvalidProtocolRule{
resourceType: "google_apigee_target_server",
attributeName: "protocol",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleApigeeTargetServerInvalidProtocolRule) 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{"HTTP", "HTTP2", "GRPC_TARGET", "GRPC", "EXTERNAL_CALLOUT", ""}, 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
}
91 changes: 91 additions & 0 deletions rules/magicmodules/google_biglake_table_invalid_type.go
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"
)

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

resourceType string
attributeName string
}

// NewGoogleBiglakeTableInvalidTypeRule returns new rule with default attributes
func NewGoogleBiglakeTableInvalidTypeRule() *GoogleBiglakeTableInvalidTypeRule {
return &GoogleBiglakeTableInvalidTypeRule{
resourceType: "google_biglake_table",
attributeName: "type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleBiglakeTableInvalidTypeRule) 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{"HIVE", ""}, 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
}
91 changes: 91 additions & 0 deletions rules/magicmodules/google_compute_address_invalid_ip_version.go
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"
)

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

resourceType string
attributeName string
}

// NewGoogleComputeAddressInvalidIpVersionRule returns new rule with default attributes
func NewGoogleComputeAddressInvalidIpVersionRule() *GoogleComputeAddressInvalidIpVersionRule {
return &GoogleComputeAddressInvalidIpVersionRule{
resourceType: "google_compute_address",
attributeName: "ip_version",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleComputeAddressInvalidIpVersionRule) 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{"IPV4", "IPV6", ""}, 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"
)

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

resourceType string
attributeName string
}

// NewGoogleComputeAddressInvalidIpv6EndpointTypeRule returns new rule with default attributes
func NewGoogleComputeAddressInvalidIpv6EndpointTypeRule() *GoogleComputeAddressInvalidIpv6EndpointTypeRule {
return &GoogleComputeAddressInvalidIpv6EndpointTypeRule{
resourceType: "google_compute_address",
attributeName: "ipv6_endpoint_type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleComputeAddressInvalidIpv6EndpointTypeRule) 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{"VM", "NETLB", ""}, 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 @@ -72,7 +72,7 @@ func (r *GoogleComputeBackendServiceInvalidLoadBalancingSchemeRule) Check(runner
}

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

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *GoogleComputeBackendServiceInvalidProtocolRule) Check(runner tflint.Run
}

err := runner.EvaluateExpr(attribute.Expr, func(val string) error {
validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", ""}, false)
validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", "UNSPECIFIED", ""}, false)

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
Expand Down
Loading
Loading