Skip to content

Commit

Permalink
Update Magic Modules (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Oct 9, 2021
1 parent ef2ecdc commit c12f686
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *GoogleComputeRegionBackendServiceInvalidSessionAffinityRule) Check(runn
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

validateFunc := validation.StringInSlice([]string{"NONE", "CLIENT_IP", "CLIENT_IP_PORT_PROTO", "CLIENT_IP_PROTO", "GENERATED_COOKIE", "HEADER_FIELD", "HTTP_COOKIE", ""}, false)
validateFunc := validation.StringInSlice([]string{"NONE", "CLIENT_IP", "CLIENT_IP_PORT_PROTO", "CLIENT_IP_PROTO", "GENERATED_COOKIE", "HEADER_FIELD", "HTTP_COOKIE", "CLIENT_IP_NO_DESTINATION", ""}, 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 *** 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 (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

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

// NewGoogleComputeSubnetworkInvalidIpv6AccessTypeRule returns new rule with default attributes
func NewGoogleComputeSubnetworkInvalidIpv6AccessTypeRule() *GoogleComputeSubnetworkInvalidIpv6AccessTypeRule {
return &GoogleComputeSubnetworkInvalidIpv6AccessTypeRule{
resourceType: "google_compute_subnetwork",
attributeName: "ipv6_access_type",
}
}

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

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

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

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

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

validateFunc := validation.StringInSlice([]string{"EXTERNAL", ""}, 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
Expand Up @@ -20,47 +20,47 @@ import (
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

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

// NewGoogleDnsRecordSetInvalidTypeRule returns new rule with default attributes
func NewGoogleDnsRecordSetInvalidTypeRule() *GoogleDnsRecordSetInvalidTypeRule {
return &GoogleDnsRecordSetInvalidTypeRule{
resourceType: "google_dns_record_set",
attributeName: "type",
// NewGoogleComputeSubnetworkInvalidStackTypeRule returns new rule with default attributes
func NewGoogleComputeSubnetworkInvalidStackTypeRule() *GoogleComputeSubnetworkInvalidStackTypeRule {
return &GoogleComputeSubnetworkInvalidStackTypeRule{
resourceType: "google_compute_subnetwork",
attributeName: "stack_type",
}
}

// Name returns the rule name
func (r *GoogleDnsRecordSetInvalidTypeRule) Name() string {
return "google_dns_record_set_invalid_type"
func (r *GoogleComputeSubnetworkInvalidStackTypeRule) Name() string {
return "google_compute_subnetwork_invalid_stack_type"
}

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

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

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

// Check checks the pattern is valid
func (r *GoogleDnsRecordSetInvalidTypeRule) Check(runner tflint.Runner) error {
func (r *GoogleComputeSubnetworkInvalidStackTypeRule) 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, nil)

validateFunc := validation.StringInSlice([]string{"A", "AAAA", "CAA", "CNAME", "DNSKEY", "DS", "IPSECVPNKEY", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "SSHFP", "TLSA", "TXT"}, false)
validateFunc := validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false)

return runner.EnsureNoError(err, func() error {
_, errors := validateFunc(val, r.attributeName)
Expand Down
10 changes: 5 additions & 5 deletions rules/magicmodules/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,11 +939,6 @@ var Products = map[string]Product{
{Name: "Google Cloud DNS API", URL: "https://console.cloud.google.com/apis/library/dns.googleapis.com/"},
},
},
"google_dns_record_set": {
APIsRequired: []APIReference{
{Name: "Google Cloud DNS API", URL: "https://console.cloud.google.com/apis/library/dns.googleapis.com/"},
},
},
"google_notebooks_environment": {
APIsRequired: []APIReference{
{Name: "Cloud Notebooks API", URL: "https://console.cloud.google.com/apis/api/notebooks.googleapis.com"},
Expand Down Expand Up @@ -994,6 +989,11 @@ var Products = map[string]Product{
{Name: "Identity and Access Management (IAM) API", URL: "https://console.cloud.google.com/apis/library/iam.googleapis.com/"},
},
},
"google_pubsub_lite_reservation": {
APIsRequired: []APIReference{
{Name: "Cloud Pub/Sub Lite API", URL: "https://console.cloud.google.com/apis/library/pubsublite.googleapis.com/"},
},
},
"google_pubsub_lite_topic": {
APIsRequired: []APIReference{
{Name: "Cloud Pub/Sub Lite API", URL: "https://console.cloud.google.com/apis/library/pubsublite.googleapis.com/"},
Expand Down
3 changes: 2 additions & 1 deletion rules/magicmodules/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ var Rules = []tflint.Rule{
NewGoogleComputeRouterPeerInvalidAdvertiseModeRule(),
NewGoogleComputeSslPolicyInvalidMinTlsVersionRule(),
NewGoogleComputeSslPolicyInvalidProfileRule(),
NewGoogleComputeSubnetworkInvalidIpv6AccessTypeRule(),
NewGoogleComputeSubnetworkInvalidRoleRule(),
NewGoogleComputeSubnetworkInvalidStackTypeRule(),
NewGoogleComputeTargetHttpsProxyInvalidQuicOverrideRule(),
NewGoogleComputeTargetInstanceInvalidNatPolicyRule(),
NewGoogleComputeTargetSslProxyInvalidProxyHeaderRule(),
Expand All @@ -99,7 +101,6 @@ var Rules = []tflint.Rule{
NewGoogleDialogflowEntityTypeInvalidKindRule(),
NewGoogleDialogflowIntentInvalidWebhookStateRule(),
NewGoogleDnsManagedZoneInvalidVisibilityRule(),
NewGoogleDnsRecordSetInvalidTypeRule(),
NewGoogleFilestoreInstanceInvalidTierRule(),
NewGoogleFirestoreIndexInvalidQueryScopeRule(),
NewGoogleHealthcareFhirStoreInvalidVersionRule(),
Expand Down
2 changes: 1 addition & 1 deletion tools/magic-modules
Submodule magic-modules updated 276 files

0 comments on commit c12f686

Please sign in to comment.