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 #372

Merged
merged 1 commit into from
Jul 23, 2024
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
790 changes: 406 additions & 384 deletions rules/magicmodules/api_definition.go

Large diffs are not rendered by default.

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"
)

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

resourceType string
attributeName string
}

// NewGoogleComputeNetworkAttachmentInvalidConnectionPreferenceRule returns new rule with default attributes
func NewGoogleComputeNetworkAttachmentInvalidConnectionPreferenceRule() *GoogleComputeNetworkAttachmentInvalidConnectionPreferenceRule {
return &GoogleComputeNetworkAttachmentInvalidConnectionPreferenceRule{
resourceType: "google_compute_network_attachment",
attributeName: "connection_preference",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleComputeNetworkAttachmentInvalidConnectionPreferenceRule) 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{"ACCEPT_AUTOMATIC", "ACCEPT_MANUAL", "INVALID"}, 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"
)

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

resourceType string
attributeName string
}

// NewGoogleComputeProjectCloudArmorTierInvalidCloudArmorTierRule returns new rule with default attributes
func NewGoogleComputeProjectCloudArmorTierInvalidCloudArmorTierRule() *GoogleComputeProjectCloudArmorTierInvalidCloudArmorTierRule {
return &GoogleComputeProjectCloudArmorTierInvalidCloudArmorTierRule{
resourceType: "google_compute_project_cloud_armor_tier",
attributeName: "cloud_armor_tier",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleComputeProjectCloudArmorTierInvalidCloudArmorTierRule) 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{"CA_STANDARD", "CA_ENTERPRISE_PAYGO"}, 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 *GoogleComputeRegionNetworkEndpointGroupInvalidNetworkEndpointTypeRule)
}

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

_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
Expand Down
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"
)

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

resourceType string
attributeName string
}

// NewGoogleComputeTargetHttpsProxyInvalidTlsEarlyDataRule returns new rule with default attributes
func NewGoogleComputeTargetHttpsProxyInvalidTlsEarlyDataRule() *GoogleComputeTargetHttpsProxyInvalidTlsEarlyDataRule {
return &GoogleComputeTargetHttpsProxyInvalidTlsEarlyDataRule{
resourceType: "google_compute_target_https_proxy",
attributeName: "tls_early_data",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleComputeTargetHttpsProxyInvalidTlsEarlyDataRule) 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{"STRICT", "PERMISSIVE", "DISABLED", ""}, 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"
)

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

resourceType string
attributeName string
}

// NewGoogleSccManagementFolderSecurityHealthAnalyticsCustomModuleInvalidEnablementStateRule returns new rule with default attributes
func NewGoogleSccManagementFolderSecurityHealthAnalyticsCustomModuleInvalidEnablementStateRule() *GoogleSccManagementFolderSecurityHealthAnalyticsCustomModuleInvalidEnablementStateRule {
return &GoogleSccManagementFolderSecurityHealthAnalyticsCustomModuleInvalidEnablementStateRule{
resourceType: "google_scc_management_folder_security_health_analytics_custom_module",
attributeName: "enablement_state",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleSccManagementFolderSecurityHealthAnalyticsCustomModuleInvalidEnablementStateRule) 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{"ENABLED", "DISABLED", ""}, 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
}
Loading
Loading