Skip to content

Update Magic Modules #64

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
Jan 3, 2021
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
Expand Up @@ -60,7 +60,7 @@ func (r *GoogleComputeAddressInvalidPurposeRule) Check(runner tflint.Runner) err
var val string
err := runner.EvaluateExpr(attribute.Expr, &val)

validateFunc := validation.StringInSlice([]string{"GCE_ENDPOINT", ""}, false)
validateFunc := validation.StringInSlice([]string{"GCE_ENDPOINT", "VPC_PEERING", "SHARED_LOADBALANCER_VIP", ""}, false)

return runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// 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 (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleComputeManagedSslCertificateInvalidTypeRule checks the pattern is valid
type GoogleComputeManagedSslCertificateInvalidTypeRule struct {
resourceType string
attributeName string
}

// NewGoogleComputeManagedSslCertificateInvalidTypeRule returns new rule with default attributes
func NewGoogleComputeManagedSslCertificateInvalidTypeRule() *GoogleComputeManagedSslCertificateInvalidTypeRule {
return &GoogleComputeManagedSslCertificateInvalidTypeRule{
resourceType: "google_compute_managed_ssl_certificate",
attributeName: "type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleComputeManagedSslCertificateInvalidTypeRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val)

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

return runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// 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 (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleNotebooksInstanceInvalidBootDiskTypeRule checks the pattern is valid
type GoogleNotebooksInstanceInvalidBootDiskTypeRule struct {
resourceType string
attributeName string
}

// NewGoogleNotebooksInstanceInvalidBootDiskTypeRule returns new rule with default attributes
func NewGoogleNotebooksInstanceInvalidBootDiskTypeRule() *GoogleNotebooksInstanceInvalidBootDiskTypeRule {
return &GoogleNotebooksInstanceInvalidBootDiskTypeRule{
resourceType: "google_notebooks_instance",
attributeName: "boot_disk_type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleNotebooksInstanceInvalidBootDiskTypeRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val)

validateFunc := validation.StringInSlice([]string{"DISK_TYPE_UNSPECIFIED", "PD_STANDARD", "PD_SSD", "PD_BALANCED", ""}, false)

return runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// 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 (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleNotebooksInstanceInvalidDataDiskTypeRule checks the pattern is valid
type GoogleNotebooksInstanceInvalidDataDiskTypeRule struct {
resourceType string
attributeName string
}

// NewGoogleNotebooksInstanceInvalidDataDiskTypeRule returns new rule with default attributes
func NewGoogleNotebooksInstanceInvalidDataDiskTypeRule() *GoogleNotebooksInstanceInvalidDataDiskTypeRule {
return &GoogleNotebooksInstanceInvalidDataDiskTypeRule{
resourceType: "google_notebooks_instance",
attributeName: "data_disk_type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleNotebooksInstanceInvalidDataDiskTypeRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val)

validateFunc := validation.StringInSlice([]string{"DISK_TYPE_UNSPECIFIED", "PD_STANDARD", "PD_SSD", "PD_BALANCED", ""}, false)

return runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// 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 (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// GoogleNotebooksInstanceInvalidDiskEncryptionRule checks the pattern is valid
type GoogleNotebooksInstanceInvalidDiskEncryptionRule struct {
resourceType string
attributeName string
}

// NewGoogleNotebooksInstanceInvalidDiskEncryptionRule returns new rule with default attributes
func NewGoogleNotebooksInstanceInvalidDiskEncryptionRule() *GoogleNotebooksInstanceInvalidDiskEncryptionRule {
return &GoogleNotebooksInstanceInvalidDiskEncryptionRule{
resourceType: "google_notebooks_instance",
attributeName: "disk_encryption",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleNotebooksInstanceInvalidDiskEncryptionRule) Check(runner tflint.Runner) error {
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val)

validateFunc := validation.StringInSlice([]string{"DISK_ENCRYPTION_UNSPECIFIED", "GMEK", "CMEK", ""}, false)

return runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
for _, err := range errors {
runner.EmitIssueOnExpr(r, err.Error(), attribute.Expr)
}
return nil
})
})
}
4 changes: 4 additions & 0 deletions rules/magicmodules/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var Rules = []tflint.Rule{
NewGoogleComputeInterconnectAttachmentInvalidBandwidthRule(),
NewGoogleComputeInterconnectAttachmentInvalidNameRule(),
NewGoogleComputeInterconnectAttachmentInvalidTypeRule(),
NewGoogleComputeManagedSslCertificateInvalidTypeRule(),
NewGoogleComputeNetworkEndpointGroupInvalidNetworkEndpointTypeRule(),
NewGoogleComputeRegionBackendServiceInvalidLoadBalancingSchemeRule(),
NewGoogleComputeRegionBackendServiceInvalidLocalityLbPolicyRule(),
Expand Down Expand Up @@ -105,6 +106,9 @@ var Rules = []tflint.Rule{
NewGoogleMonitoringMetricDescriptorInvalidValueTypeRule(),
NewGoogleMonitoringSloInvalidCalendarPeriodRule(),
NewGoogleMonitoringSloInvalidSloIdRule(),
NewGoogleNotebooksInstanceInvalidBootDiskTypeRule(),
NewGoogleNotebooksInstanceInvalidDataDiskTypeRule(),
NewGoogleNotebooksInstanceInvalidDiskEncryptionRule(),
NewGoogleOsConfigPatchDeploymentInvalidPatchDeploymentIdRule(),
NewGoogleRedisInstanceInvalidConnectModeRule(),
NewGoogleRedisInstanceInvalidNameRule(),
Expand Down
2 changes: 1 addition & 1 deletion tools/magic-modules
Submodule magic-modules updated 239 files