Skip to content
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
13 changes: 13 additions & 0 deletions rules/magicmodules/api_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var APIDefinition = map[string]string{
"google_alloydb_instance": "alloydb.googleapis.com",
"google_alloydb_user": "alloydb.googleapis.com",
"google_apigee_addons_config": "apigee.googleapis.com",
"google_apigee_api_product": "apigee.googleapis.com",
"google_apigee_app_group": "apigee.googleapis.com",
"google_apigee_control_plane_access": "apigee.googleapis.com",
"google_apigee_developer": "apigee.googleapis.com",
Expand All @@ -56,6 +57,7 @@ var APIDefinition = map[string]string{
"google_apigee_keystores_aliases_self_signed_cert": "apigee.googleapis.com",
"google_apigee_nat_address": "apigee.googleapis.com",
"google_apigee_organization": "apigee.googleapis.com",
"google_apigee_security_action": "apigee.googleapis.com",
"google_apigee_security_monitoring_condition": "apigee.googleapis.com",
"google_apigee_security_profile_v2": "apigee.googleapis.com",
"google_apigee_sync_authorization": "apigee.googleapis.com",
Expand All @@ -81,6 +83,7 @@ var APIDefinition = map[string]string{
"google_backup_dr_backup_plan_association": "backupdr.googleapis.com",
"google_backup_dr_backup_vault": "backupdr.googleapis.com",
"google_backup_dr_management_server": "backupdr.googleapis.com",
"google_backup_dr_service_config": "backupdr.googleapis.com",
"google_beyondcorp_app_connection": "beyondcorp.googleapis.com",
"google_beyondcorp_app_connector": "beyondcorp.googleapis.com",
"google_beyondcorp_app_gateway": "beyondcorp.googleapis.com",
Expand Down Expand Up @@ -108,6 +111,7 @@ var APIDefinition = map[string]string{
"google_bigtable_app_profile": "bigtableadmin.googleapis.com",
"google_bigtable_logical_view": "bigtableadmin.googleapis.com",
"google_bigtable_materialized_view": "bigtableadmin.googleapis.com",
"google_bigtable_schema_bundle": "bigtableadmin.googleapis.com",
"google_billing_budget": "billingbudgets.googleapis.com",
"google_billing_project_info": "cloudbilling.googleapis.com",
"google_binary_authorization_attestor": "binaryauthorization.googleapis.com",
Expand Down Expand Up @@ -282,6 +286,7 @@ var APIDefinition = map[string]string{
"google_developer_connect_account_connector": "developerconnect.googleapis.com",
"google_developer_connect_connection": "developerconnect.googleapis.com",
"google_developer_connect_git_repository_link": "developerconnect.googleapis.com",
"google_developer_connect_insights_config": "developerconnect.googleapis.com",
"google_dialogflow_agent": "dialogflow.googleapis.com",
"google_dialogflow_encryption_spec": "dialogflow.googleapis.com",
"google_dialogflow_entity_type": "dialogflow.googleapis.com",
Expand Down Expand Up @@ -355,6 +360,7 @@ var APIDefinition = map[string]string{
"google_gkeonprem_bare_metal_admin_cluster": "gkeonprem.googleapis.com",
"google_gkeonprem_bare_metal_cluster": "gkeonprem.googleapis.com",
"google_gkeonprem_bare_metal_node_pool": "gkeonprem.googleapis.com",
"google_gkeonprem_vmware_admin_cluster": "gkeonprem.googleapis.com",
"google_gkeonprem_vmware_cluster": "gkeonprem.googleapis.com",
"google_gkeonprem_vmware_node_pool": "gkeonprem.googleapis.com",
"google_healthcare_consent_store": "healthcare.googleapis.com",
Expand Down Expand Up @@ -394,9 +400,11 @@ var APIDefinition = map[string]string{
"google_integration_connectors_managed_zone": "connectors.googleapis.com",
"google_integrations_auth_config": "integrations.googleapis.com",
"google_integrations_client": "integrations.googleapis.com",
"google_kms_autokey_config": "cloudkms.googleapis.com",
"google_kms_crypto_key": "cloudkms.googleapis.com",
"google_kms_crypto_key_version": "cloudkms.googleapis.com",
"google_kms_ekm_connection": "cloudkms.googleapis.com",
"google_kms_key_handle": "cloudkms.googleapis.com",
"google_kms_key_ring": "cloudkms.googleapis.com",
"google_kms_key_ring_import_job": "cloudkms.googleapis.com",
"google_kms_secret_ciphertext": "cloudkms.googleapis.com",
Expand All @@ -417,6 +425,7 @@ var APIDefinition = map[string]string{
"google_migration_center_group": "migrationcenter.googleapis.com",
"google_migration_center_preference_set": "migrationcenter.googleapis.com",
"google_ml_engine_model": "ml.googleapis.com",
"google_model_armor_floorsetting": "modelarmor.googleapis.com",
"google_monitoring_alert_policy": "monitoring.googleapis.com",
"google_monitoring_custom_service": "monitoring.googleapis.com",
"google_monitoring_group": "monitoring.googleapis.com",
Expand Down Expand Up @@ -447,6 +456,7 @@ var APIDefinition = map[string]string{
"google_network_management_vpc_flow_logs_config": "networkmanagement.googleapis.com",
"google_network_security_address_group": "networksecurity.googleapis.com",
"google_network_security_authz_policy": "networksecurity.googleapis.com",
"google_network_security_backend_authentication_config": "networksecurity.googleapis.com",
"google_network_security_client_tls_policy": "networksecurity.googleapis.com",
"google_network_security_firewall_endpoint": "networksecurity.googleapis.com",
"google_network_security_firewall_endpoint_association": "networksecurity.googleapis.com",
Expand Down Expand Up @@ -486,6 +496,8 @@ var APIDefinition = map[string]string{
"google_oracle_database_autonomous_database": "oracledatabase.googleapis.com",
"google_oracle_database_cloud_exadata_infrastructure": "oracledatabase.googleapis.com",
"google_oracle_database_cloud_vm_cluster": "oracledatabase.googleapis.com",
"google_oracle_database_odb_network": "oracledatabase.googleapis.com",
"google_oracle_database_odb_subnet": "oracledatabase.googleapis.com",
"google_org_policy_custom_constraint": "orgpolicy.googleapis.com",
"google_org_policy_policy": "orgpolicy.googleapis.com",
"google_organization_access_approval_settings": "accessapproval.googleapis.com",
Expand Down Expand Up @@ -564,6 +576,7 @@ var APIDefinition = map[string]string{
"google_storage_default_object_access_control": "storage.googleapis.com",
"google_storage_folder": "storage.googleapis.com",
"google_storage_hmac_key": "storage.googleapis.com",
"google_storage_insights_dataset_config": "storageinsights.googleapis.com",
"google_storage_insights_report_config": "storageinsights.googleapis.com",
"google_storage_managed_folder": "storage.googleapis.com",
"google_storage_object_access_control": "storage.googleapis.com",
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"
)

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

resourceType string
attributeName string
}

// NewGoogleApigeeApiProductInvalidApprovalTypeRule returns new rule with default attributes
func NewGoogleApigeeApiProductInvalidApprovalTypeRule() *GoogleApigeeApiProductInvalidApprovalTypeRule {
return &GoogleApigeeApiProductInvalidApprovalTypeRule{
resourceType: "google_apigee_api_product",
attributeName: "approval_type",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleApigeeApiProductInvalidApprovalTypeRule) 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{"auto", "manual", ""}, 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
}
90 changes: 90 additions & 0 deletions rules/magicmodules/google_apigee_api_product_invalid_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// ----------------------------------------------------------------------------
//
// *** 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/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

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

resourceType string
attributeName string
}

// NewGoogleApigeeApiProductInvalidNameRule returns new rule with default attributes
func NewGoogleApigeeApiProductInvalidNameRule() *GoogleApigeeApiProductInvalidNameRule {
return &GoogleApigeeApiProductInvalidNameRule{
resourceType: "google_apigee_api_product",
attributeName: "name",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleApigeeApiProductInvalidNameRule) 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 := validateRegexp(`^[a-z][a-z0-9._\-$ %]*$`)

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

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

resourceType string
attributeName string
}

// NewGoogleApigeeApiProductInvalidQuotaCounterScopeRule returns new rule with default attributes
func NewGoogleApigeeApiProductInvalidQuotaCounterScopeRule() *GoogleApigeeApiProductInvalidQuotaCounterScopeRule {
return &GoogleApigeeApiProductInvalidQuotaCounterScopeRule{
resourceType: "google_apigee_api_product",
attributeName: "quota_counter_scope",
}
}

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

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

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

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

// Check checks the pattern is valid
func (r *GoogleApigeeApiProductInvalidQuotaCounterScopeRule) 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_COUNTER_SCOPE_UNSPECIFIED", "PROXY", "OPERATION", ""}, 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