Skip to content

Update Magic Modules #352

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, 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
716 changes: 370 additions & 346 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"
)

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

resourceType string
attributeName string
}

// NewGoogleBigqueryRoutineInvalidDataGovernanceTypeRule returns new rule with default attributes
func NewGoogleBigqueryRoutineInvalidDataGovernanceTypeRule() *GoogleBigqueryRoutineInvalidDataGovernanceTypeRule {
return &GoogleBigqueryRoutineInvalidDataGovernanceTypeRule{
resourceType: "google_bigquery_routine",
attributeName: "data_governance_type",
}
}

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

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

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

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

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

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

resourceType string
attributeName string
}

// NewGoogleBillingBudgetInvalidOwnershipScopeRule returns new rule with default attributes
func NewGoogleBillingBudgetInvalidOwnershipScopeRule() *GoogleBillingBudgetInvalidOwnershipScopeRule {
return &GoogleBillingBudgetInvalidOwnershipScopeRule{
resourceType: "google_billing_budget",
attributeName: "ownership_scope",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleBillingBudgetInvalidOwnershipScopeRule) 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{"OWNERSHIP_SCOPE_UNSPECIFIED", "ALL_USERS", "BILLING_ACCOUNT", ""}, 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"
)

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

resourceType string
attributeName string
}

// NewGoogleCertificateManagerDnsAuthorizationInvalidTypeRule returns new rule with default attributes
func NewGoogleCertificateManagerDnsAuthorizationInvalidTypeRule() *GoogleCertificateManagerDnsAuthorizationInvalidTypeRule {
return &GoogleCertificateManagerDnsAuthorizationInvalidTypeRule{
resourceType: "google_certificate_manager_dns_authorization",
attributeName: "type",
}
}

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

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

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

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

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

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

resourceType string
attributeName string
}

// NewGoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule returns new rule with default attributes
func NewGoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule() *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule {
return &GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule{
resourceType: "google_cloud_quotas_quota_preference",
attributeName: "ignore_safety_checks",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleCloudQuotasQuotaPreferenceInvalidIgnoreSafetyChecksRule) 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{"QUOTA_SAFETY_CHECK_UNSPECIFIED", "QUOTA_DECREASE_BELOW_USAGE", "QUOTA_DECREASE_PERCENTAGE_TOO_HIGH", ""}, 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