From 1cfde9cb99e4743c0938e226c5808dcefd6e13e1 Mon Sep 17 00:00:00 2001 From: wata727 <9624059+wata727@users.noreply.github.com> Date: Mon, 26 May 2025 01:57:31 +0000 Subject: [PATCH] Update Magic Modules --- rules/magicmodules/api_definition.go | 31 +++++++ ...oydb_instance_invalid_activation_policy.go | 91 +++++++++++++++++++ ..._bigquery_routine_invalid_security_mode.go | 91 +++++++++++++++++++ ...run_v2_worker_pool_invalid_launch_stage.go | 91 +++++++++++++++++++ ...nvalid_external_managed_migration_state.go | 91 +++++++++++++++++++ ...ompute_backend_service_invalid_protocol.go | 2 +- ..._managed_backend_bucket_migration_state.go | 91 +++++++++++++++++++ ...region_backend_service_invalid_protocol.go | 2 +- ...ute_region_security_policy_invalid_type.go | 91 +++++++++++++++++++ ...pool_invalid_capacity_provisioning_type.go | 91 +++++++++++++++++++ ...l_invalid_performance_provisioning_type.go | 91 +++++++++++++++++++ ...workforce_pool_provider_key_invalid_use.go | 91 +++++++++++++++++++ ..._backup_vault_invalid_backup_vault_type.go | 91 +++++++++++++++++++ ..._spanner_instance_invalid_instance_type.go | 91 +++++++++++++++++++ ...age_batch_operations_job_invalid_job_id.go | 90 ++++++++++++++++++ rules/magicmodules/provider.go | 12 +++ rules/magicmodules/verify/validation.go | 14 +++ tools/magic-modules | 2 +- 18 files changed, 1151 insertions(+), 3 deletions(-) create mode 100644 rules/magicmodules/google_alloydb_instance_invalid_activation_policy.go create mode 100644 rules/magicmodules/google_bigquery_routine_invalid_security_mode.go create mode 100644 rules/magicmodules/google_cloud_run_v2_worker_pool_invalid_launch_stage.go create mode 100644 rules/magicmodules/google_compute_backend_service_invalid_external_managed_migration_state.go create mode 100644 rules/magicmodules/google_compute_global_forwarding_rule_invalid_external_managed_backend_bucket_migration_state.go create mode 100644 rules/magicmodules/google_compute_region_security_policy_invalid_type.go create mode 100644 rules/magicmodules/google_compute_storage_pool_invalid_capacity_provisioning_type.go create mode 100644 rules/magicmodules/google_compute_storage_pool_invalid_performance_provisioning_type.go create mode 100644 rules/magicmodules/google_iam_workforce_pool_provider_key_invalid_use.go create mode 100644 rules/magicmodules/google_netapp_backup_vault_invalid_backup_vault_type.go create mode 100644 rules/magicmodules/google_spanner_instance_invalid_instance_type.go create mode 100644 rules/magicmodules/google_storage_batch_operations_job_invalid_job_id.go diff --git a/rules/magicmodules/api_definition.go b/rules/magicmodules/api_definition.go index b40c989..fc3a42b 100644 --- a/rules/magicmodules/api_definition.go +++ b/rules/magicmodules/api_definition.go @@ -56,6 +56,8 @@ 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_monitoring_condition": "apigee.googleapis.com", + "google_apigee_security_profile_v2": "apigee.googleapis.com", "google_apigee_sync_authorization": "apigee.googleapis.com", "google_apigee_target_server": "apigee.googleapis.com", "google_apihub_api_hub_instance": "apihub.googleapis.com", @@ -81,6 +83,7 @@ var APIDefinition = map[string]string{ "google_beyondcorp_app_gateway": "beyondcorp.googleapis.com", "google_beyondcorp_application": "beyondcorp.googleapis.com", "google_beyondcorp_security_gateway": "beyondcorp.googleapis.com", + "google_beyondcorp_security_gateway_application": "beyondcorp.googleapis.com", "google_biglake_catalog": "biglake.googleapis.com", "google_biglake_database": "biglake.googleapis.com", "google_biglake_table": "biglake.googleapis.com", @@ -98,7 +101,10 @@ var APIDefinition = map[string]string{ "google_bigquery_reservation": "bigqueryreservation.googleapis.com", "google_bigquery_reservation_assignment": "bigqueryreservation.googleapis.com", "google_bigquery_routine": "bigquery.googleapis.com", + "google_bigquery_row_access_policy": "bigquery.googleapis.com", "google_bigtable_app_profile": "bigtableadmin.googleapis.com", + "google_bigtable_logical_view": "bigtableadmin.googleapis.com", + "google_bigtable_materialized_view": "bigtableadmin.googleapis.com", "google_billing_budget": "billingbudgets.googleapis.com", "google_billing_project_info": "cloudbilling.googleapis.com", "google_binary_authorization_attestor": "binaryauthorization.googleapis.com", @@ -119,6 +125,7 @@ var APIDefinition = map[string]string{ "google_cloud_quotas_quota_preference": "cloudquotas.googleapis.com", "google_cloud_run_v2_job": "run.googleapis.com", "google_cloud_run_v2_service": "run.googleapis.com", + "google_cloud_run_v2_worker_pool": "run.googleapis.com", "google_cloud_scheduler_job": "cloudscheduler.googleapis.com", "google_cloud_tasks_queue": "cloudtasks.googleapis.com", "google_cloudbuild_bitbucket_server_config": "cloudbuild.googleapis.com", @@ -144,6 +151,7 @@ var APIDefinition = map[string]string{ "google_compute_firewall_policy": "compute.googleapis.com", "google_compute_firewall_policy_association": "compute.googleapis.com", "google_compute_firewall_policy_rule": "compute.googleapis.com", + "google_compute_firewall_policy_with_rules": "compute.googleapis.com", "google_compute_forwarding_rule": "compute.googleapis.com", "google_compute_global_address": "compute.googleapis.com", "google_compute_global_forwarding_rule": "compute.googleapis.com", @@ -169,6 +177,7 @@ var APIDefinition = map[string]string{ "google_compute_network_firewall_policy": "compute.googleapis.com", "google_compute_network_firewall_policy_association": "compute.googleapis.com", "google_compute_network_firewall_policy_rule": "compute.googleapis.com", + "google_compute_network_firewall_policy_with_rules": "compute.googleapis.com", "google_compute_network_peering_routes_config": "compute.googleapis.com", "google_compute_node_group": "compute.googleapis.com", "google_compute_node_template": "compute.googleapis.com", @@ -188,7 +197,10 @@ var APIDefinition = map[string]string{ "google_compute_region_network_firewall_policy": "compute.googleapis.com", "google_compute_region_network_firewall_policy_association": "compute.googleapis.com", "google_compute_region_network_firewall_policy_rule": "compute.googleapis.com", + "google_compute_region_network_firewall_policy_with_rules": "compute.googleapis.com", "google_compute_region_per_instance_config": "compute.googleapis.com", + "google_compute_region_security_policy": "compute.googleapis.com", + "google_compute_region_security_policy_rule": "compute.googleapis.com", "google_compute_region_ssl_certificate": "compute.googleapis.com", "google_compute_region_ssl_policy": "compute.googleapis.com", "google_compute_region_target_http_proxy": "compute.googleapis.com", @@ -198,6 +210,7 @@ var APIDefinition = map[string]string{ "google_compute_reservation": "compute.googleapis.com", "google_compute_resize_request": "compute.googleapis.com", "google_compute_resource_policy": "compute.googleapis.com", + "google_compute_resource_policy_attachment": "compute.googleapis.com", "google_compute_route": "compute.googleapis.com", "google_compute_router": "compute.googleapis.com", "google_compute_router_nat": "compute.googleapis.com", @@ -208,6 +221,7 @@ var APIDefinition = map[string]string{ "google_compute_snapshot": "compute.googleapis.com", "google_compute_ssl_certificate": "compute.googleapis.com", "google_compute_ssl_policy": "compute.googleapis.com", + "google_compute_storage_pool": "compute.googleapis.com", "google_compute_subnetwork": "compute.googleapis.com", "google_compute_target_grpc_proxy": "compute.googleapis.com", "google_compute_target_http_proxy": "compute.googleapis.com", @@ -238,8 +252,12 @@ var APIDefinition = map[string]string{ "google_database_migration_service_private_connection": "datamigration.googleapis.com", "google_dataplex_aspect_type": "dataplex.googleapis.com", "google_dataplex_datascan": "dataplex.googleapis.com", + "google_dataplex_entry": "dataplex.googleapis.com", "google_dataplex_entry_group": "dataplex.googleapis.com", "google_dataplex_entry_type": "dataplex.googleapis.com", + "google_dataplex_glossary": "dataplex.googleapis.com", + "google_dataplex_glossary_category": "dataplex.googleapis.com", + "google_dataplex_glossary_term": "dataplex.googleapis.com", "google_dataplex_task": "dataplex.googleapis.com", "google_dataproc_autoscaling_policy": "dataproc.googleapis.com", "google_dataproc_batch": "dataproc.googleapis.com", @@ -291,6 +309,9 @@ var APIDefinition = map[string]string{ "google_firebase_app_check_service_config": "firebaseappcheck.googleapis.com", "google_firebase_app_hosting_backend": "firebaseapphosting.googleapis.com", "google_firebase_app_hosting_build": "firebaseapphosting.googleapis.com", + "google_firebase_app_hosting_default_domain": "firebaseapphosting.googleapis.com", + "google_firebase_app_hosting_domain": "firebaseapphosting.googleapis.com", + "google_firebase_app_hosting_traffic": "firebaseapphosting.googleapis.com", "google_firebase_data_connect_service": "firebasedataconnect.googleapis.com", "google_firestore_backup_schedule": "firestore.googleapis.com", "google_firestore_database": "firestore.googleapis.com", @@ -310,7 +331,9 @@ var APIDefinition = map[string]string{ "google_gemini_release_channel_setting": "cloudaicompanion.googleapis.com", "google_gemini_release_channel_setting_binding": "cloudaicompanion.googleapis.com", "google_gemini_repository_group": "cloudaicompanion.googleapis.com", + "google_gke_backup_backup_channel": "gkebackup.googleapis.com", "google_gke_backup_backup_plan": "gkebackup.googleapis.com", + "google_gke_backup_restore_channel": "gkebackup.googleapis.com", "google_gke_backup_restore_plan": "gkebackup.googleapis.com", "google_gke_hub_feature": "gkehub.googleapis.com", "google_gke_hub_fleet": "gkehub.googleapis.com", @@ -341,6 +364,7 @@ var APIDefinition = map[string]string{ "google_iam_projects_policy_binding": "iam.googleapis.com", "google_iam_workforce_pool": "iam.googleapis.com", "google_iam_workforce_pool_provider": "iam.googleapis.com", + "google_iam_workforce_pool_provider_key": "iam.googleapis.com", "google_iam_workload_identity_pool": "iam.googleapis.com", "google_iam_workload_identity_pool_provider": "iam.googleapis.com", "google_iap_brand": "iap.googleapis.com", @@ -374,6 +398,7 @@ var APIDefinition = map[string]string{ "google_logging_organization_settings": "logging.googleapis.com", "google_looker_instance": "looker.googleapis.com", "google_lustre_instance": "lustre.googleapis.com", + "google_managed_kafka_acl": "managedkafka.googleapis.com", "google_managed_kafka_cluster": "managedkafka.googleapis.com", "google_managed_kafka_topic": "managedkafka.googleapis.com", "google_memcache_instance": "memcache.googleapis.com", @@ -417,6 +442,10 @@ var APIDefinition = map[string]string{ "google_network_security_firewall_endpoint_association": "networksecurity.googleapis.com", "google_network_security_gateway_security_policy": "networksecurity.googleapis.com", "google_network_security_gateway_security_policy_rule": "networksecurity.googleapis.com", + "google_network_security_intercept_deployment": "networksecurity.googleapis.com", + "google_network_security_intercept_deployment_group": "networksecurity.googleapis.com", + "google_network_security_intercept_endpoint_group": "networksecurity.googleapis.com", + "google_network_security_intercept_endpoint_group_association": "networksecurity.googleapis.com", "google_network_security_mirroring_deployment": "networksecurity.googleapis.com", "google_network_security_mirroring_deployment_group": "networksecurity.googleapis.com", "google_network_security_mirroring_endpoint_group": "networksecurity.googleapis.com", @@ -452,6 +481,7 @@ var APIDefinition = map[string]string{ "google_organization_access_approval_settings": "accessapproval.googleapis.com", "google_os_config_patch_deployment": "osconfig.googleapis.com", "google_os_config_v2_policy_orchestrator": "osconfig.googleapis.com", + "google_os_config_v2_policy_orchestrator_for_folder": "osconfig.googleapis.com", "google_os_config_v2_policy_orchestrator_for_organization": "osconfig.googleapis.com", "google_os_login_ssh_public_key": "oslogin.googleapis.com", "google_parallelstore_instance": "parallelstore.googleapis.com", @@ -516,6 +546,7 @@ var APIDefinition = map[string]string{ "google_sql_database": "sqladmin.googleapis.com", "google_sql_source_representation_instance": "sqladmin.googleapis.com", "google_storage_anywhere_cache": "storage.googleapis.com", + "google_storage_batch_operations_job": "storagebatchoperations.googleapis.com", "google_storage_bucket_access_control": "storage.googleapis.com", "google_storage_control_folder_intelligence_config": "storage.googleapis.com", "google_storage_control_organization_intelligence_config": "storage.googleapis.com", diff --git a/rules/magicmodules/google_alloydb_instance_invalid_activation_policy.go b/rules/magicmodules/google_alloydb_instance_invalid_activation_policy.go new file mode 100644 index 0000000..1cc6ce1 --- /dev/null +++ b/rules/magicmodules/google_alloydb_instance_invalid_activation_policy.go @@ -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" +) + +// GoogleAlloydbInstanceInvalidActivationPolicyRule checks the pattern is valid +type GoogleAlloydbInstanceInvalidActivationPolicyRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleAlloydbInstanceInvalidActivationPolicyRule returns new rule with default attributes +func NewGoogleAlloydbInstanceInvalidActivationPolicyRule() *GoogleAlloydbInstanceInvalidActivationPolicyRule { + return &GoogleAlloydbInstanceInvalidActivationPolicyRule{ + resourceType: "google_alloydb_instance", + attributeName: "activation_policy", + } +} + +// Name returns the rule name +func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Name() string { + return "google_alloydb_instance_invalid_activation_policy" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleAlloydbInstanceInvalidActivationPolicyRule) 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{"ACTIVATION_POLICY_UNSPECIFIED", "ALWAYS", "NEVER", ""}, 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 +} diff --git a/rules/magicmodules/google_bigquery_routine_invalid_security_mode.go b/rules/magicmodules/google_bigquery_routine_invalid_security_mode.go new file mode 100644 index 0000000..a25d4c2 --- /dev/null +++ b/rules/magicmodules/google_bigquery_routine_invalid_security_mode.go @@ -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" +) + +// GoogleBigqueryRoutineInvalidSecurityModeRule checks the pattern is valid +type GoogleBigqueryRoutineInvalidSecurityModeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleBigqueryRoutineInvalidSecurityModeRule returns new rule with default attributes +func NewGoogleBigqueryRoutineInvalidSecurityModeRule() *GoogleBigqueryRoutineInvalidSecurityModeRule { + return &GoogleBigqueryRoutineInvalidSecurityModeRule{ + resourceType: "google_bigquery_routine", + attributeName: "security_mode", + } +} + +// Name returns the rule name +func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Name() string { + return "google_bigquery_routine_invalid_security_mode" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleBigqueryRoutineInvalidSecurityModeRule) 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{"DEFINER", "INVOKER", ""}, 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 +} diff --git a/rules/magicmodules/google_cloud_run_v2_worker_pool_invalid_launch_stage.go b/rules/magicmodules/google_cloud_run_v2_worker_pool_invalid_launch_stage.go new file mode 100644 index 0000000..23e68e5 --- /dev/null +++ b/rules/magicmodules/google_cloud_run_v2_worker_pool_invalid_launch_stage.go @@ -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" +) + +// GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule checks the pattern is valid +type GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleCloudRunV2WorkerPoolInvalidLaunchStageRule returns new rule with default attributes +func NewGoogleCloudRunV2WorkerPoolInvalidLaunchStageRule() *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule { + return &GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule{ + resourceType: "google_cloud_run_v2_worker_pool", + attributeName: "launch_stage", + } +} + +// Name returns the rule name +func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Name() string { + return "google_cloud_run_v2_worker_pool_invalid_launch_stage" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleCloudRunV2WorkerPoolInvalidLaunchStageRule) 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{"UNIMPLEMENTED", "PRELAUNCH", "EARLY_ACCESS", "ALPHA", "BETA", "GA", "DEPRECATED", ""}, 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 +} diff --git a/rules/magicmodules/google_compute_backend_service_invalid_external_managed_migration_state.go b/rules/magicmodules/google_compute_backend_service_invalid_external_managed_migration_state.go new file mode 100644 index 0000000..ee5d5b6 --- /dev/null +++ b/rules/magicmodules/google_compute_backend_service_invalid_external_managed_migration_state.go @@ -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" +) + +// GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule checks the pattern is valid +type GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule returns new rule with default attributes +func NewGoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule() *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule { + return &GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule{ + resourceType: "google_compute_backend_service", + attributeName: "external_managed_migration_state", + } +} + +// Name returns the rule name +func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Name() string { + return "google_compute_backend_service_invalid_external_managed_migration_state" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule) 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{"PREPARE", "TEST_BY_PERCENTAGE", "TEST_ALL_TRAFFIC", ""}, 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 +} diff --git a/rules/magicmodules/google_compute_backend_service_invalid_protocol.go b/rules/magicmodules/google_compute_backend_service_invalid_protocol.go index a02f8d7..d4bd84c 100644 --- a/rules/magicmodules/google_compute_backend_service_invalid_protocol.go +++ b/rules/magicmodules/google_compute_backend_service_invalid_protocol.go @@ -72,7 +72,7 @@ func (r *GoogleComputeBackendServiceInvalidProtocolRule) Check(runner tflint.Run } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "GRPC", "UNSPECIFIED", ""}, false) + validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "UDP", "GRPC", "UNSPECIFIED", "H2C", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_global_forwarding_rule_invalid_external_managed_backend_bucket_migration_state.go b/rules/magicmodules/google_compute_global_forwarding_rule_invalid_external_managed_backend_bucket_migration_state.go new file mode 100644 index 0000000..25914e4 --- /dev/null +++ b/rules/magicmodules/google_compute_global_forwarding_rule_invalid_external_managed_backend_bucket_migration_state.go @@ -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" +) + +// GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule checks the pattern is valid +type GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule returns new rule with default attributes +func NewGoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule() *GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule { + return &GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule{ + resourceType: "google_compute_global_forwarding_rule", + attributeName: "external_managed_backend_bucket_migration_state", + } +} + +// Name returns the rule name +func (r *GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule) Name() string { + return "google_compute_global_forwarding_rule_invalid_external_managed_backend_bucket_migration_state" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule) 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{"PREPARE", "TEST_BY_PERCENTAGE", "TEST_ALL_TRAFFIC", ""}, 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 +} diff --git a/rules/magicmodules/google_compute_region_backend_service_invalid_protocol.go b/rules/magicmodules/google_compute_region_backend_service_invalid_protocol.go index 57163ce..9cc15f7 100644 --- a/rules/magicmodules/google_compute_region_backend_service_invalid_protocol.go +++ b/rules/magicmodules/google_compute_region_backend_service_invalid_protocol.go @@ -72,7 +72,7 @@ func (r *GoogleComputeRegionBackendServiceInvalidProtocolRule) Check(runner tfli } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "SSL", "TCP", "UDP", "GRPC", "UNSPECIFIED", ""}, false) + validateFunc := validation.StringInSlice([]string{"HTTP", "HTTPS", "HTTP2", "TCP", "SSL", "UDP", "GRPC", "UNSPECIFIED", "H2C", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_region_security_policy_invalid_type.go b/rules/magicmodules/google_compute_region_security_policy_invalid_type.go new file mode 100644 index 0000000..7a03b20 --- /dev/null +++ b/rules/magicmodules/google_compute_region_security_policy_invalid_type.go @@ -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" +) + +// GoogleComputeRegionSecurityPolicyInvalidTypeRule checks the pattern is valid +type GoogleComputeRegionSecurityPolicyInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeRegionSecurityPolicyInvalidTypeRule returns new rule with default attributes +func NewGoogleComputeRegionSecurityPolicyInvalidTypeRule() *GoogleComputeRegionSecurityPolicyInvalidTypeRule { + return &GoogleComputeRegionSecurityPolicyInvalidTypeRule{ + resourceType: "google_compute_region_security_policy", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleComputeRegionSecurityPolicyInvalidTypeRule) Name() string { + return "google_compute_region_security_policy_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeRegionSecurityPolicyInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeRegionSecurityPolicyInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeRegionSecurityPolicyInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeRegionSecurityPolicyInvalidTypeRule) 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{"CLOUD_ARMOR", "CLOUD_ARMOR_EDGE", "CLOUD_ARMOR_NETWORK", ""}, 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 +} diff --git a/rules/magicmodules/google_compute_storage_pool_invalid_capacity_provisioning_type.go b/rules/magicmodules/google_compute_storage_pool_invalid_capacity_provisioning_type.go new file mode 100644 index 0000000..1d44b04 --- /dev/null +++ b/rules/magicmodules/google_compute_storage_pool_invalid_capacity_provisioning_type.go @@ -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" +) + +// GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule checks the pattern is valid +type GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule returns new rule with default attributes +func NewGoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule() *GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule { + return &GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule{ + resourceType: "google_compute_storage_pool", + attributeName: "capacity_provisioning_type", + } +} + +// Name returns the rule name +func (r *GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule) Name() string { + return "google_compute_storage_pool_invalid_capacity_provisioning_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule) 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{"STANDARD", "ADVANCED", ""}, 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 +} diff --git a/rules/magicmodules/google_compute_storage_pool_invalid_performance_provisioning_type.go b/rules/magicmodules/google_compute_storage_pool_invalid_performance_provisioning_type.go new file mode 100644 index 0000000..bef9e41 --- /dev/null +++ b/rules/magicmodules/google_compute_storage_pool_invalid_performance_provisioning_type.go @@ -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" +) + +// GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule checks the pattern is valid +type GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule returns new rule with default attributes +func NewGoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule() *GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule { + return &GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule{ + resourceType: "google_compute_storage_pool", + attributeName: "performance_provisioning_type", + } +} + +// Name returns the rule name +func (r *GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule) Name() string { + return "google_compute_storage_pool_invalid_performance_provisioning_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule) 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{"STANDARD", "ADVANCED", ""}, 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 +} diff --git a/rules/magicmodules/google_iam_workforce_pool_provider_key_invalid_use.go b/rules/magicmodules/google_iam_workforce_pool_provider_key_invalid_use.go new file mode 100644 index 0000000..7ed80d9 --- /dev/null +++ b/rules/magicmodules/google_iam_workforce_pool_provider_key_invalid_use.go @@ -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" +) + +// GoogleIamWorkforcePoolProviderKeyInvalidUseRule checks the pattern is valid +type GoogleIamWorkforcePoolProviderKeyInvalidUseRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleIamWorkforcePoolProviderKeyInvalidUseRule returns new rule with default attributes +func NewGoogleIamWorkforcePoolProviderKeyInvalidUseRule() *GoogleIamWorkforcePoolProviderKeyInvalidUseRule { + return &GoogleIamWorkforcePoolProviderKeyInvalidUseRule{ + resourceType: "google_iam_workforce_pool_provider_key", + attributeName: "use", + } +} + +// Name returns the rule name +func (r *GoogleIamWorkforcePoolProviderKeyInvalidUseRule) Name() string { + return "google_iam_workforce_pool_provider_key_invalid_use" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleIamWorkforcePoolProviderKeyInvalidUseRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleIamWorkforcePoolProviderKeyInvalidUseRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleIamWorkforcePoolProviderKeyInvalidUseRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleIamWorkforcePoolProviderKeyInvalidUseRule) 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{"ENCRYPTION"}, 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 +} diff --git a/rules/magicmodules/google_netapp_backup_vault_invalid_backup_vault_type.go b/rules/magicmodules/google_netapp_backup_vault_invalid_backup_vault_type.go new file mode 100644 index 0000000..10ac3fa --- /dev/null +++ b/rules/magicmodules/google_netapp_backup_vault_invalid_backup_vault_type.go @@ -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" +) + +// GoogleNetappBackupVaultInvalidBackupVaultTypeRule checks the pattern is valid +type GoogleNetappBackupVaultInvalidBackupVaultTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetappBackupVaultInvalidBackupVaultTypeRule returns new rule with default attributes +func NewGoogleNetappBackupVaultInvalidBackupVaultTypeRule() *GoogleNetappBackupVaultInvalidBackupVaultTypeRule { + return &GoogleNetappBackupVaultInvalidBackupVaultTypeRule{ + resourceType: "google_netapp_backup_vault", + attributeName: "backup_vault_type", + } +} + +// Name returns the rule name +func (r *GoogleNetappBackupVaultInvalidBackupVaultTypeRule) Name() string { + return "google_netapp_backup_vault_invalid_backup_vault_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetappBackupVaultInvalidBackupVaultTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetappBackupVaultInvalidBackupVaultTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetappBackupVaultInvalidBackupVaultTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetappBackupVaultInvalidBackupVaultTypeRule) 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{"BACKUP_VAULT_TYPE_UNSPECIFIED", "IN_REGION", "CROSS_REGION", ""}, 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 +} diff --git a/rules/magicmodules/google_spanner_instance_invalid_instance_type.go b/rules/magicmodules/google_spanner_instance_invalid_instance_type.go new file mode 100644 index 0000000..b42da54 --- /dev/null +++ b/rules/magicmodules/google_spanner_instance_invalid_instance_type.go @@ -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" +) + +// GoogleSpannerInstanceInvalidInstanceTypeRule checks the pattern is valid +type GoogleSpannerInstanceInvalidInstanceTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleSpannerInstanceInvalidInstanceTypeRule returns new rule with default attributes +func NewGoogleSpannerInstanceInvalidInstanceTypeRule() *GoogleSpannerInstanceInvalidInstanceTypeRule { + return &GoogleSpannerInstanceInvalidInstanceTypeRule{ + resourceType: "google_spanner_instance", + attributeName: "instance_type", + } +} + +// Name returns the rule name +func (r *GoogleSpannerInstanceInvalidInstanceTypeRule) Name() string { + return "google_spanner_instance_invalid_instance_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleSpannerInstanceInvalidInstanceTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleSpannerInstanceInvalidInstanceTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleSpannerInstanceInvalidInstanceTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleSpannerInstanceInvalidInstanceTypeRule) 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{"PROVISIONED", "FREE_INSTANCE", ""}, 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 +} diff --git a/rules/magicmodules/google_storage_batch_operations_job_invalid_job_id.go b/rules/magicmodules/google_storage_batch_operations_job_invalid_job_id.go new file mode 100644 index 0000000..0d87903 --- /dev/null +++ b/rules/magicmodules/google_storage_batch_operations_job_invalid_job_id.go @@ -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" +) + +// GoogleStorageBatchOperationsJobInvalidJobIdRule checks the pattern is valid +type GoogleStorageBatchOperationsJobInvalidJobIdRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleStorageBatchOperationsJobInvalidJobIdRule returns new rule with default attributes +func NewGoogleStorageBatchOperationsJobInvalidJobIdRule() *GoogleStorageBatchOperationsJobInvalidJobIdRule { + return &GoogleStorageBatchOperationsJobInvalidJobIdRule{ + resourceType: "google_storage_batch_operations_job", + attributeName: "job_id", + } +} + +// Name returns the rule name +func (r *GoogleStorageBatchOperationsJobInvalidJobIdRule) Name() string { + return "google_storage_batch_operations_job_invalid_job_id" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleStorageBatchOperationsJobInvalidJobIdRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleStorageBatchOperationsJobInvalidJobIdRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleStorageBatchOperationsJobInvalidJobIdRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleStorageBatchOperationsJobInvalidJobIdRule) 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-z0-9]([-a-z0-9]*[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 +} diff --git a/rules/magicmodules/provider.go b/rules/magicmodules/provider.go index bb8b4f4..79820d6 100644 --- a/rules/magicmodules/provider.go +++ b/rules/magicmodules/provider.go @@ -29,6 +29,7 @@ var Rules = []tflint.Rule{ NewGoogleAlloydbBackupInvalidTypeRule(), NewGoogleAlloydbClusterInvalidClusterTypeRule(), NewGoogleAlloydbClusterInvalidSubscriptionTypeRule(), + NewGoogleAlloydbInstanceInvalidActivationPolicyRule(), NewGoogleAlloydbInstanceInvalidAvailabilityTypeRule(), NewGoogleAlloydbInstanceInvalidInstanceTypeRule(), NewGoogleAlloydbUserInvalidUserTypeRule(), @@ -54,6 +55,7 @@ var Rules = []tflint.Rule{ NewGoogleBigqueryRoutineInvalidDeterminismLevelRule(), NewGoogleBigqueryRoutineInvalidLanguageRule(), NewGoogleBigqueryRoutineInvalidRoutineTypeRule(), + NewGoogleBigqueryRoutineInvalidSecurityModeRule(), NewGoogleBillingBudgetInvalidOwnershipScopeRule(), NewGoogleBinaryAuthorizationPolicyInvalidGlobalPolicyEvaluationModeRule(), NewGoogleBlockchainNodeEngineBlockchainNodesInvalidBlockchainTypeRule(), @@ -68,6 +70,7 @@ var Rules = []tflint.Rule{ NewGoogleCloudRunV2JobInvalidLaunchStageRule(), NewGoogleCloudRunV2ServiceInvalidIngressRule(), NewGoogleCloudRunV2ServiceInvalidLaunchStageRule(), + NewGoogleCloudRunV2WorkerPoolInvalidLaunchStageRule(), NewGoogleCloudbuildTriggerInvalidIncludeBuildLogsRule(), NewGoogleComputeAddressInvalidAddressTypeRule(), NewGoogleComputeAddressInvalidIpVersionRule(), @@ -78,6 +81,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeBackendBucketInvalidNameRule(), NewGoogleComputeBackendBucketSignedUrlKeyInvalidNameRule(), NewGoogleComputeBackendServiceInvalidCompressionModeRule(), + NewGoogleComputeBackendServiceInvalidExternalManagedMigrationStateRule(), NewGoogleComputeBackendServiceInvalidIpAddressSelectionPolicyRule(), NewGoogleComputeBackendServiceInvalidLoadBalancingSchemeRule(), NewGoogleComputeBackendServiceInvalidLocalityLbPolicyRule(), @@ -93,6 +97,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeForwardingRuleInvalidNetworkTierRule(), NewGoogleComputeGlobalAddressInvalidAddressTypeRule(), NewGoogleComputeGlobalAddressInvalidIpVersionRule(), + NewGoogleComputeGlobalForwardingRuleInvalidExternalManagedBackendBucketMigrationStateRule(), NewGoogleComputeGlobalForwardingRuleInvalidIpProtocolRule(), NewGoogleComputeGlobalForwardingRuleInvalidIpVersionRule(), NewGoogleComputeGlobalForwardingRuleInvalidLoadBalancingSchemeRule(), @@ -126,6 +131,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeRegionCommitmentInvalidPlanRule(), NewGoogleComputeRegionNetworkEndpointGroupInvalidNetworkEndpointTypeRule(), NewGoogleComputeRegionNetworkFirewallPolicyRuleInvalidDirectionRule(), + NewGoogleComputeRegionSecurityPolicyInvalidTypeRule(), NewGoogleComputeRegionSslPolicyInvalidMinTlsVersionRule(), NewGoogleComputeRegionSslPolicyInvalidProfileRule(), NewGoogleComputeRegionTargetTcpProxyInvalidProxyHeaderRule(), @@ -137,6 +143,8 @@ var Rules = []tflint.Rule{ NewGoogleComputeRouterRoutePolicyInvalidTypeRule(), NewGoogleComputeSslPolicyInvalidMinTlsVersionRule(), NewGoogleComputeSslPolicyInvalidProfileRule(), + NewGoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule(), + NewGoogleComputeStoragePoolInvalidPerformanceProvisioningTypeRule(), NewGoogleComputeSubnetworkInvalidIpv6AccessTypeRule(), NewGoogleComputeSubnetworkInvalidRoleRule(), NewGoogleComputeSubnetworkInvalidStackTypeRule(), @@ -201,6 +209,7 @@ var Rules = []tflint.Rule{ NewGoogleGeminiReleaseChannelSettingBindingInvalidProductRule(), NewGoogleHealthcareFhirStoreInvalidComplexDataTypeReferenceParsingRule(), NewGoogleHealthcareFhirStoreInvalidVersionRule(), + NewGoogleIamWorkforcePoolProviderKeyInvalidUseRule(), NewGoogleIntegrationConnectorsConnectionInvalidEventingEnablementTypeRule(), NewGoogleIntegrationsAuthConfigInvalidVisibilityRule(), NewGoogleKmsCryptoKeyVersionInvalidStateRule(), @@ -220,6 +229,7 @@ var Rules = []tflint.Rule{ NewGoogleMonitoringSloInvalidCalendarPeriodRule(), NewGoogleMonitoringSloInvalidSloIdRule(), NewGoogleMonitoringUptimeCheckConfigInvalidCheckerTypeRule(), + NewGoogleNetappBackupVaultInvalidBackupVaultTypeRule(), NewGoogleNetappStoragePoolInvalidServiceLevelRule(), NewGoogleNetappVolumeInvalidSecurityStyleRule(), NewGoogleNetappVolumeQuotaRuleInvalidTypeRule(), @@ -287,9 +297,11 @@ var Rules = []tflint.Rule{ NewGoogleSpannerDatabaseInvalidNameRule(), NewGoogleSpannerInstanceInvalidDefaultBackupScheduleTypeRule(), NewGoogleSpannerInstanceInvalidEditionRule(), + NewGoogleSpannerInstanceInvalidInstanceTypeRule(), NewGoogleSpannerInstanceInvalidNameRule(), NewGoogleSpannerInstancePartitionInvalidNameRule(), NewGoogleStorageAnywhereCacheInvalidAdmissionPolicyRule(), + NewGoogleStorageBatchOperationsJobInvalidJobIdRule(), NewGoogleStorageBucketAccessControlInvalidRoleRule(), NewGoogleStorageDefaultObjectAccessControlInvalidRoleRule(), NewGoogleStorageHmacKeyInvalidStateRule(), diff --git a/rules/magicmodules/verify/validation.go b/rules/magicmodules/verify/validation.go index 25c0d28..512aa0d 100644 --- a/rules/magicmodules/verify/validation.go +++ b/rules/magicmodules/verify/validation.go @@ -1,3 +1,17 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: Handwritten *** +// +// ---------------------------------------------------------------------------- +// +// This code is generated by Magic Modules using the following: +// +// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/verify/validation.go +// +// DO NOT EDIT this file directly. Any changes made to this file will be +// overwritten during the next generation cycle. +// +// ---------------------------------------------------------------------------- package verify import ( diff --git a/tools/magic-modules b/tools/magic-modules index b863028..ebb7049 160000 --- a/tools/magic-modules +++ b/tools/magic-modules @@ -1 +1 @@ -Subproject commit b863028ebb63b8de85d0607c73d3814d0a2bf1c3 +Subproject commit ebb70496873996523bce3efcf883f7401d6df5db