diff --git a/rules/magicmodules/api_definition.go b/rules/magicmodules/api_definition.go index 6f4bb1e..b40c989 100644 --- a/rules/magicmodules/api_definition.go +++ b/rules/magicmodules/api_definition.go @@ -39,7 +39,9 @@ var APIDefinition = map[string]string{ "google_alloydb_user": "alloydb.googleapis.com", "google_apigee_addons_config": "apigee.googleapis.com", "google_apigee_app_group": "apigee.googleapis.com", + "google_apigee_control_plane_access": "apigee.googleapis.com", "google_apigee_developer": "apigee.googleapis.com", + "google_apigee_dns_zone": "apigee.googleapis.com", "google_apigee_endpoint_attachment": "apigee.googleapis.com", "google_apigee_env_keystore": "apigee.googleapis.com", "google_apigee_env_references": "apigee.googleapis.com", @@ -57,6 +59,7 @@ var APIDefinition = map[string]string{ "google_apigee_sync_authorization": "apigee.googleapis.com", "google_apigee_target_server": "apigee.googleapis.com", "google_apihub_api_hub_instance": "apihub.googleapis.com", + "google_apihub_host_project_registration": "apihub.googleapis.com", "google_app_engine_application_url_dispatch_rules": "appengine.googleapis.com", "google_app_engine_domain_mapping": "appengine.googleapis.com", "google_app_engine_firewall_rule": "appengine.googleapis.com", @@ -124,6 +127,7 @@ var APIDefinition = map[string]string{ "google_cloudbuildv2_repository": "cloudbuild.googleapis.com", "google_clouddeploy_automation": "clouddeploy.googleapis.com", "google_clouddeploy_custom_target_type": "clouddeploy.googleapis.com", + "google_clouddeploy_deploy_policy": "clouddeploy.googleapis.com", "google_clouddomains_registration": "domains.googleapis.com", "google_cloudfunctions2_function": "cloudfunctions.googleapis.com", "google_composer_user_workloads_config_map": "composer.googleapis.com", @@ -137,6 +141,7 @@ var APIDefinition = map[string]string{ "google_compute_disk_resource_policy_attachment": "compute.googleapis.com", "google_compute_external_vpn_gateway": "compute.googleapis.com", "google_compute_firewall": "compute.googleapis.com", + "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_forwarding_rule": "compute.googleapis.com", @@ -152,6 +157,7 @@ var APIDefinition = map[string]string{ "google_compute_instance_group_membership": "compute.googleapis.com", "google_compute_instance_group_named_port": "compute.googleapis.com", "google_compute_instance_settings": "compute.googleapis.com", + "google_compute_instant_snapshot": "compute.googleapis.com", "google_compute_interconnect": "compute.googleapis.com", "google_compute_interconnect_attachment": "compute.googleapis.com", "google_compute_managed_ssl_certificate": "compute.googleapis.com", @@ -196,6 +202,7 @@ var APIDefinition = map[string]string{ "google_compute_router": "compute.googleapis.com", "google_compute_router_nat": "compute.googleapis.com", "google_compute_router_nat_address": "compute.googleapis.com", + "google_compute_router_route_policy": "compute.googleapis.com", "google_compute_security_policy_rule": "compute.googleapis.com", "google_compute_service_attachment": "compute.googleapis.com", "google_compute_snapshot": "compute.googleapis.com", @@ -245,6 +252,7 @@ var APIDefinition = map[string]string{ "google_datastream_private_connection": "datastream.googleapis.com", "google_datastream_stream": "datastream.googleapis.com", "google_deployment_manager_deployment": "www.googleapis.com", + "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_dialogflow_agent": "dialogflow.googleapis.com", @@ -264,7 +272,12 @@ var APIDefinition = map[string]string{ "google_edgenetwork_network": "edgenetwork.googleapis.com", "google_edgenetwork_subnet": "edgenetwork.googleapis.com", "google_essential_contacts_contact": "essentialcontacts.googleapis.com", + "google_eventarc_channel": "eventarc.googleapis.com", + "google_eventarc_enrollment": "eventarc.googleapis.com", + "google_eventarc_google_api_source": "eventarc.googleapis.com", "google_eventarc_google_channel_config": "eventarc.googleapis.com", + "google_eventarc_message_bus": "eventarc.googleapis.com", + "google_eventarc_pipeline": "eventarc.googleapis.com", "google_eventarc_trigger": "eventarc.googleapis.com", "google_filestore_backup": "file.googleapis.com", "google_filestore_instance": "file.googleapis.com", @@ -276,6 +289,8 @@ var APIDefinition = map[string]string{ "google_firebase_app_check_recaptcha_enterprise_config": "firebaseappcheck.googleapis.com", "google_firebase_app_check_recaptcha_v3_config": "firebaseappcheck.googleapis.com", "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_data_connect_service": "firebasedataconnect.googleapis.com", "google_firestore_backup_schedule": "firestore.googleapis.com", "google_firestore_database": "firestore.googleapis.com", @@ -284,8 +299,12 @@ var APIDefinition = map[string]string{ "google_firestore_index": "firestore.googleapis.com", "google_folder_access_approval_settings": "accessapproval.googleapis.com", "google_gemini_code_repository_index": "cloudaicompanion.googleapis.com", + "google_gemini_code_tools_setting": "cloudaicompanion.googleapis.com", + "google_gemini_code_tools_setting_binding": "cloudaicompanion.googleapis.com", "google_gemini_data_sharing_with_google_setting": "cloudaicompanion.googleapis.com", + "google_gemini_data_sharing_with_google_setting_binding": "cloudaicompanion.googleapis.com", "google_gemini_gemini_gcp_enablement_setting": "cloudaicompanion.googleapis.com", + "google_gemini_gemini_gcp_enablement_setting_binding": "cloudaicompanion.googleapis.com", "google_gemini_logging_setting": "cloudaicompanion.googleapis.com", "google_gemini_logging_setting_binding": "cloudaicompanion.googleapis.com", "google_gemini_release_channel_setting": "cloudaicompanion.googleapis.com", @@ -315,6 +334,8 @@ var APIDefinition = map[string]string{ "google_iam_access_boundary_policy": "iam.googleapis.com", "google_iam_deny_policy": "iam.googleapis.com", "google_iam_folders_policy_binding": "iam.googleapis.com", + "google_iam_oauth_client": "iam.googleapis.com", + "google_iam_oauth_client_credential": "iam.googleapis.com", "google_iam_organizations_policy_binding": "iam.googleapis.com", "google_iam_principal_access_boundary_policy": "iam.googleapis.com", "google_iam_projects_policy_binding": "iam.googleapis.com", @@ -352,10 +373,12 @@ var APIDefinition = map[string]string{ "google_logging_metric": "logging.googleapis.com", "google_logging_organization_settings": "logging.googleapis.com", "google_looker_instance": "looker.googleapis.com", + "google_lustre_instance": "lustre.googleapis.com", "google_managed_kafka_cluster": "managedkafka.googleapis.com", "google_managed_kafka_topic": "managedkafka.googleapis.com", "google_memcache_instance": "memcache.googleapis.com", "google_memorystore_instance": "memorystore.googleapis.com", + "google_memorystore_instance_desired_user_created_endpoints": "memorystore.googleapis.com", "google_migration_center_group": "migrationcenter.googleapis.com", "google_migration_center_preference_set": "migrationcenter.googleapis.com", "google_ml_engine_model": "ml.googleapis.com", @@ -394,6 +417,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_mirroring_deployment": "networksecurity.googleapis.com", + "google_network_security_mirroring_deployment_group": "networksecurity.googleapis.com", + "google_network_security_mirroring_endpoint_group": "networksecurity.googleapis.com", + "google_network_security_mirroring_endpoint_group_association": "networksecurity.googleapis.com", "google_network_security_security_profile": "networksecurity.googleapis.com", "google_network_security_security_profile_group": "networksecurity.googleapis.com", "google_network_security_server_tls_policy": "networksecurity.googleapis.com", @@ -403,9 +430,16 @@ var APIDefinition = map[string]string{ "google_network_services_edge_cache_keyset": "networkservices.googleapis.com", "google_network_services_edge_cache_origin": "networkservices.googleapis.com", "google_network_services_edge_cache_service": "networkservices.googleapis.com", + "google_network_services_endpoint_policy": "networkservices.googleapis.com", "google_network_services_gateway": "networkservices.googleapis.com", + "google_network_services_grpc_route": "networkservices.googleapis.com", + "google_network_services_http_route": "networkservices.googleapis.com", "google_network_services_lb_route_extension": "networkservices.googleapis.com", "google_network_services_lb_traffic_extension": "networkservices.googleapis.com", + "google_network_services_mesh": "networkservices.googleapis.com", + "google_network_services_service_binding": "networkservices.googleapis.com", + "google_network_services_tcp_route": "networkservices.googleapis.com", + "google_network_services_tls_route": "networkservices.googleapis.com", "google_notebooks_environment": "notebooks.googleapis.com", "google_notebooks_instance": "notebooks.googleapis.com", "google_notebooks_location": "notebooks.googleapis.com", @@ -417,8 +451,12 @@ var APIDefinition = map[string]string{ "google_org_policy_policy": "orgpolicy.googleapis.com", "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_organization": "osconfig.googleapis.com", "google_os_login_ssh_public_key": "oslogin.googleapis.com", "google_parallelstore_instance": "parallelstore.googleapis.com", + "google_parameter_manager_parameter": "parametermanager.googleapis.com", + "google_parameter_manager_parameter_version": "parametermanager.googleapis.com", "google_privateca_ca_pool": "privateca.googleapis.com", "google_privateca_certificate": "privateca.googleapis.com", "google_privateca_certificate_authority": "privateca.googleapis.com", @@ -479,6 +517,9 @@ var APIDefinition = map[string]string{ "google_sql_source_representation_instance": "sqladmin.googleapis.com", "google_storage_anywhere_cache": "storage.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", + "google_storage_control_project_intelligence_config": "storage.googleapis.com", "google_storage_default_object_access_control": "storage.googleapis.com", "google_storage_folder": "storage.googleapis.com", "google_storage_hmac_key": "storage.googleapis.com", diff --git a/rules/magicmodules/google_compute_backend_service_invalid_locality_lb_policy.go b/rules/magicmodules/google_compute_backend_service_invalid_locality_lb_policy.go index 43864b5..f46b880 100644 --- a/rules/magicmodules/google_compute_backend_service_invalid_locality_lb_policy.go +++ b/rules/magicmodules/google_compute_backend_service_invalid_locality_lb_policy.go @@ -72,7 +72,7 @@ func (r *GoogleComputeBackendServiceInvalidLocalityLbPolicyRule) Check(runner tf } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"ROUND_ROBIN", "LEAST_REQUEST", "RING_HASH", "RANDOM", "ORIGINAL_DESTINATION", "MAGLEV", "WEIGHTED_MAGLEV", ""}, false) + validateFunc := validation.StringInSlice([]string{"ROUND_ROBIN", "LEAST_REQUEST", "RING_HASH", "RANDOM", "ORIGINAL_DESTINATION", "MAGLEV", "WEIGHTED_MAGLEV", "WEIGHTED_ROUND_ROBIN", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_interconnect_invalid_link_type.go b/rules/magicmodules/google_compute_interconnect_invalid_link_type.go index eef89f7..cbfcce5 100644 --- a/rules/magicmodules/google_compute_interconnect_invalid_link_type.go +++ b/rules/magicmodules/google_compute_interconnect_invalid_link_type.go @@ -72,7 +72,7 @@ func (r *GoogleComputeInterconnectInvalidLinkTypeRule) Check(runner tflint.Runne } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"LINK_TYPE_ETHERNET_10G_LR", "LINK_TYPE_ETHERNET_100G_LR"}, false) + validateFunc := validation.StringInSlice([]string{"LINK_TYPE_ETHERNET_10G_LR", "LINK_TYPE_ETHERNET_100G_LR", "LINK_TYPE_ETHERNET_400G_LR4"}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_public_delegated_prefix_invalid_mode.go b/rules/magicmodules/google_compute_public_delegated_prefix_invalid_mode.go index 5c040cc..a11f4b1 100644 --- a/rules/magicmodules/google_compute_public_delegated_prefix_invalid_mode.go +++ b/rules/magicmodules/google_compute_public_delegated_prefix_invalid_mode.go @@ -72,7 +72,7 @@ func (r *GoogleComputePublicDelegatedPrefixInvalidModeRule) Check(runner tflint. } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION", ""}, false) + validateFunc := validation.StringInSlice([]string{"DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION", "EXTERNAL_IPV6_SUBNETWORK_CREATION", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_region_backend_service_invalid_locality_lb_policy.go b/rules/magicmodules/google_compute_region_backend_service_invalid_locality_lb_policy.go index b880699..4c51dc2 100644 --- a/rules/magicmodules/google_compute_region_backend_service_invalid_locality_lb_policy.go +++ b/rules/magicmodules/google_compute_region_backend_service_invalid_locality_lb_policy.go @@ -72,7 +72,7 @@ func (r *GoogleComputeRegionBackendServiceInvalidLocalityLbPolicyRule) Check(run } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"ROUND_ROBIN", "LEAST_REQUEST", "RING_HASH", "RANDOM", "ORIGINAL_DESTINATION", "MAGLEV", "WEIGHTED_MAGLEV", ""}, false) + validateFunc := validation.StringInSlice([]string{"ROUND_ROBIN", "LEAST_REQUEST", "RING_HASH", "RANDOM", "ORIGINAL_DESTINATION", "MAGLEV", "WEIGHTED_MAGLEV", "WEIGHTED_ROUND_ROBIN", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_router_nat_invalid_type.go b/rules/magicmodules/google_compute_router_nat_invalid_type.go new file mode 100644 index 0000000..9439f43 --- /dev/null +++ b/rules/magicmodules/google_compute_router_nat_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" +) + +// GoogleComputeRouterNatInvalidTypeRule checks the pattern is valid +type GoogleComputeRouterNatInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeRouterNatInvalidTypeRule returns new rule with default attributes +func NewGoogleComputeRouterNatInvalidTypeRule() *GoogleComputeRouterNatInvalidTypeRule { + return &GoogleComputeRouterNatInvalidTypeRule{ + resourceType: "google_compute_router_nat", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleComputeRouterNatInvalidTypeRule) Name() string { + return "google_compute_router_nat_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeRouterNatInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeRouterNatInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeRouterNatInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeRouterNatInvalidTypeRule) 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{"PUBLIC", "PRIVATE", ""}, 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_router_route_policy_invalid_type.go b/rules/magicmodules/google_compute_router_route_policy_invalid_type.go new file mode 100644 index 0000000..2e91f1a --- /dev/null +++ b/rules/magicmodules/google_compute_router_route_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" +) + +// GoogleComputeRouterRoutePolicyInvalidTypeRule checks the pattern is valid +type GoogleComputeRouterRoutePolicyInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeRouterRoutePolicyInvalidTypeRule returns new rule with default attributes +func NewGoogleComputeRouterRoutePolicyInvalidTypeRule() *GoogleComputeRouterRoutePolicyInvalidTypeRule { + return &GoogleComputeRouterRoutePolicyInvalidTypeRule{ + resourceType: "google_compute_router_route_policy", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleComputeRouterRoutePolicyInvalidTypeRule) Name() string { + return "google_compute_router_route_policy_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeRouterRoutePolicyInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeRouterRoutePolicyInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeRouterRoutePolicyInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeRouterRoutePolicyInvalidTypeRule) 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{"ROUTE_POLICY_TYPE_IMPORT", "ROUTE_POLICY_TYPE_EXPORT", ""}, 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_target_https_proxy_invalid_tls_early_data.go b/rules/magicmodules/google_compute_target_https_proxy_invalid_tls_early_data.go index be62987..512d393 100644 --- a/rules/magicmodules/google_compute_target_https_proxy_invalid_tls_early_data.go +++ b/rules/magicmodules/google_compute_target_https_proxy_invalid_tls_early_data.go @@ -72,7 +72,7 @@ func (r *GoogleComputeTargetHttpsProxyInvalidTlsEarlyDataRule) Check(runner tfli } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"STRICT", "PERMISSIVE", "DISABLED", ""}, false) + validateFunc := validation.StringInSlice([]string{"STRICT", "PERMISSIVE", "UNRESTRICTED", "DISABLED", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_firebase_app_hosting_backend_invalid_serving_locality.go b/rules/magicmodules/google_firebase_app_hosting_backend_invalid_serving_locality.go new file mode 100644 index 0000000..8d38476 --- /dev/null +++ b/rules/magicmodules/google_firebase_app_hosting_backend_invalid_serving_locality.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" +) + +// GoogleFirebaseAppHostingBackendInvalidServingLocalityRule checks the pattern is valid +type GoogleFirebaseAppHostingBackendInvalidServingLocalityRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleFirebaseAppHostingBackendInvalidServingLocalityRule returns new rule with default attributes +func NewGoogleFirebaseAppHostingBackendInvalidServingLocalityRule() *GoogleFirebaseAppHostingBackendInvalidServingLocalityRule { + return &GoogleFirebaseAppHostingBackendInvalidServingLocalityRule{ + resourceType: "google_firebase_app_hosting_backend", + attributeName: "serving_locality", + } +} + +// Name returns the rule name +func (r *GoogleFirebaseAppHostingBackendInvalidServingLocalityRule) Name() string { + return "google_firebase_app_hosting_backend_invalid_serving_locality" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleFirebaseAppHostingBackendInvalidServingLocalityRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleFirebaseAppHostingBackendInvalidServingLocalityRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleFirebaseAppHostingBackendInvalidServingLocalityRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleFirebaseAppHostingBackendInvalidServingLocalityRule) 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{"REGIONAL_STRICT", "GLOBAL_ACCESS"}, 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_firestore_database_invalid_database_edition.go b/rules/magicmodules/google_firestore_database_invalid_database_edition.go new file mode 100644 index 0000000..57da165 --- /dev/null +++ b/rules/magicmodules/google_firestore_database_invalid_database_edition.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" +) + +// GoogleFirestoreDatabaseInvalidDatabaseEditionRule checks the pattern is valid +type GoogleFirestoreDatabaseInvalidDatabaseEditionRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleFirestoreDatabaseInvalidDatabaseEditionRule returns new rule with default attributes +func NewGoogleFirestoreDatabaseInvalidDatabaseEditionRule() *GoogleFirestoreDatabaseInvalidDatabaseEditionRule { + return &GoogleFirestoreDatabaseInvalidDatabaseEditionRule{ + resourceType: "google_firestore_database", + attributeName: "database_edition", + } +} + +// Name returns the rule name +func (r *GoogleFirestoreDatabaseInvalidDatabaseEditionRule) Name() string { + return "google_firestore_database_invalid_database_edition" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleFirestoreDatabaseInvalidDatabaseEditionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleFirestoreDatabaseInvalidDatabaseEditionRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleFirestoreDatabaseInvalidDatabaseEditionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleFirestoreDatabaseInvalidDatabaseEditionRule) 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", "ENTERPRISE", ""}, 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_firestore_index_invalid_api_scope.go b/rules/magicmodules/google_firestore_index_invalid_api_scope.go index a865cea..eba7020 100644 --- a/rules/magicmodules/google_firestore_index_invalid_api_scope.go +++ b/rules/magicmodules/google_firestore_index_invalid_api_scope.go @@ -72,7 +72,7 @@ func (r *GoogleFirestoreIndexInvalidApiScopeRule) Check(runner tflint.Runner) er } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"ANY_API", "DATASTORE_MODE_API", ""}, false) + validateFunc := validation.StringInSlice([]string{"ANY_API", "DATASTORE_MODE_API", "MONGODB_COMPATIBLE_API", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_firestore_index_invalid_density.go b/rules/magicmodules/google_firestore_index_invalid_density.go new file mode 100644 index 0000000..898d0d8 --- /dev/null +++ b/rules/magicmodules/google_firestore_index_invalid_density.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" +) + +// GoogleFirestoreIndexInvalidDensityRule checks the pattern is valid +type GoogleFirestoreIndexInvalidDensityRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleFirestoreIndexInvalidDensityRule returns new rule with default attributes +func NewGoogleFirestoreIndexInvalidDensityRule() *GoogleFirestoreIndexInvalidDensityRule { + return &GoogleFirestoreIndexInvalidDensityRule{ + resourceType: "google_firestore_index", + attributeName: "density", + } +} + +// Name returns the rule name +func (r *GoogleFirestoreIndexInvalidDensityRule) Name() string { + return "google_firestore_index_invalid_density" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleFirestoreIndexInvalidDensityRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleFirestoreIndexInvalidDensityRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleFirestoreIndexInvalidDensityRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleFirestoreIndexInvalidDensityRule) 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{"SPARSE_ALL", "SPARSE_ANY", "DENSE", ""}, 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_gemini_code_tools_setting_binding_invalid_product.go b/rules/magicmodules/google_gemini_code_tools_setting_binding_invalid_product.go new file mode 100644 index 0000000..b10fe1d --- /dev/null +++ b/rules/magicmodules/google_gemini_code_tools_setting_binding_invalid_product.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" +) + +// GoogleGeminiCodeToolsSettingBindingInvalidProductRule checks the pattern is valid +type GoogleGeminiCodeToolsSettingBindingInvalidProductRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleGeminiCodeToolsSettingBindingInvalidProductRule returns new rule with default attributes +func NewGoogleGeminiCodeToolsSettingBindingInvalidProductRule() *GoogleGeminiCodeToolsSettingBindingInvalidProductRule { + return &GoogleGeminiCodeToolsSettingBindingInvalidProductRule{ + resourceType: "google_gemini_code_tools_setting_binding", + attributeName: "product", + } +} + +// Name returns the rule name +func (r *GoogleGeminiCodeToolsSettingBindingInvalidProductRule) Name() string { + return "google_gemini_code_tools_setting_binding_invalid_product" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleGeminiCodeToolsSettingBindingInvalidProductRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleGeminiCodeToolsSettingBindingInvalidProductRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleGeminiCodeToolsSettingBindingInvalidProductRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleGeminiCodeToolsSettingBindingInvalidProductRule) 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{"GEMINI_CODE_ASSIST", ""}, 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_gemini_data_sharing_with_google_setting_binding_invalid_product.go b/rules/magicmodules/google_gemini_data_sharing_with_google_setting_binding_invalid_product.go new file mode 100644 index 0000000..2f1ba70 --- /dev/null +++ b/rules/magicmodules/google_gemini_data_sharing_with_google_setting_binding_invalid_product.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" +) + +// GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule checks the pattern is valid +type GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule returns new rule with default attributes +func NewGoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule() *GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule { + return &GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule{ + resourceType: "google_gemini_data_sharing_with_google_setting_binding", + attributeName: "product", + } +} + +// Name returns the rule name +func (r *GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule) Name() string { + return "google_gemini_data_sharing_with_google_setting_binding_invalid_product" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule) 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{"GEMINI_CLOUD_ASSIST", ""}, 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_gemini_gemini_gcp_enablement_setting_binding_invalid_product.go b/rules/magicmodules/google_gemini_gemini_gcp_enablement_setting_binding_invalid_product.go new file mode 100644 index 0000000..d606c80 --- /dev/null +++ b/rules/magicmodules/google_gemini_gemini_gcp_enablement_setting_binding_invalid_product.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" +) + +// GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule checks the pattern is valid +type GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule returns new rule with default attributes +func NewGoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule() *GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule { + return &GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule{ + resourceType: "google_gemini_gemini_gcp_enablement_setting_binding", + attributeName: "product", + } +} + +// Name returns the rule name +func (r *GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule) Name() string { + return "google_gemini_gemini_gcp_enablement_setting_binding_invalid_product" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule) 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{"GEMINI_IN_BIGQUERY", ""}, 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_gemini_logging_setting_binding_invalid_product.go b/rules/magicmodules/google_gemini_logging_setting_binding_invalid_product.go index dde7aec..1f12408 100644 --- a/rules/magicmodules/google_gemini_logging_setting_binding_invalid_product.go +++ b/rules/magicmodules/google_gemini_logging_setting_binding_invalid_product.go @@ -72,7 +72,7 @@ func (r *GoogleGeminiLoggingSettingBindingInvalidProductRule) Check(runner tflin } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"GEMINI_CLOUD_ASSIST", "GEMINI_CODE_ASSIST", ""}, false) + validateFunc := validation.StringInSlice([]string{"GEMINI_CODE_ASSIST", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_kms_key_ring_import_job_invalid_import_method.go b/rules/magicmodules/google_kms_key_ring_import_job_invalid_import_method.go index 9afa95d..d24aa68 100644 --- a/rules/magicmodules/google_kms_key_ring_import_job_invalid_import_method.go +++ b/rules/magicmodules/google_kms_key_ring_import_job_invalid_import_method.go @@ -72,7 +72,7 @@ func (r *GoogleKmsKeyRingImportJobInvalidImportMethodRule) Check(runner tflint.R } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"RSA_OAEP_3072_SHA1_AES_256", "RSA_OAEP_4096_SHA1_AES_256"}, false) + validateFunc := validation.StringInSlice([]string{"RSA_OAEP_3072_SHA1_AES_256", "RSA_OAEP_4096_SHA1_AES_256", "RSA_OAEP_3072_SHA256_AES_256", "RSA_OAEP_4096_SHA256_AES_256", "RSA_OAEP_3072_SHA256", "RSA_OAEP_4096_SHA256"}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_network_connectivity_hub_invalid_policy_mode.go b/rules/magicmodules/google_network_connectivity_hub_invalid_policy_mode.go new file mode 100644 index 0000000..771fcca --- /dev/null +++ b/rules/magicmodules/google_network_connectivity_hub_invalid_policy_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" +) + +// GoogleNetworkConnectivityHubInvalidPolicyModeRule checks the pattern is valid +type GoogleNetworkConnectivityHubInvalidPolicyModeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkConnectivityHubInvalidPolicyModeRule returns new rule with default attributes +func NewGoogleNetworkConnectivityHubInvalidPolicyModeRule() *GoogleNetworkConnectivityHubInvalidPolicyModeRule { + return &GoogleNetworkConnectivityHubInvalidPolicyModeRule{ + resourceType: "google_network_connectivity_hub", + attributeName: "policy_mode", + } +} + +// Name returns the rule name +func (r *GoogleNetworkConnectivityHubInvalidPolicyModeRule) Name() string { + return "google_network_connectivity_hub_invalid_policy_mode" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkConnectivityHubInvalidPolicyModeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkConnectivityHubInvalidPolicyModeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkConnectivityHubInvalidPolicyModeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkConnectivityHubInvalidPolicyModeRule) 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{"CUSTOM", "PRESET", ""}, 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_network_services_endpoint_policy_invalid_type.go b/rules/magicmodules/google_network_services_endpoint_policy_invalid_type.go new file mode 100644 index 0000000..57a13d7 --- /dev/null +++ b/rules/magicmodules/google_network_services_endpoint_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" +) + +// GoogleNetworkServicesEndpointPolicyInvalidTypeRule checks the pattern is valid +type GoogleNetworkServicesEndpointPolicyInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkServicesEndpointPolicyInvalidTypeRule returns new rule with default attributes +func NewGoogleNetworkServicesEndpointPolicyInvalidTypeRule() *GoogleNetworkServicesEndpointPolicyInvalidTypeRule { + return &GoogleNetworkServicesEndpointPolicyInvalidTypeRule{ + resourceType: "google_network_services_endpoint_policy", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleNetworkServicesEndpointPolicyInvalidTypeRule) Name() string { + return "google_network_services_endpoint_policy_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkServicesEndpointPolicyInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkServicesEndpointPolicyInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkServicesEndpointPolicyInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkServicesEndpointPolicyInvalidTypeRule) 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{"SIDECAR_PROXY", "GRPC_SERVER"}, 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_network_services_gateway_invalid_envoy_headers.go b/rules/magicmodules/google_network_services_gateway_invalid_envoy_headers.go new file mode 100644 index 0000000..97f912d --- /dev/null +++ b/rules/magicmodules/google_network_services_gateway_invalid_envoy_headers.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" +) + +// GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule checks the pattern is valid +type GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkServicesGatewayInvalidEnvoyHeadersRule returns new rule with default attributes +func NewGoogleNetworkServicesGatewayInvalidEnvoyHeadersRule() *GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule { + return &GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule{ + resourceType: "google_network_services_gateway", + attributeName: "envoy_headers", + } +} + +// Name returns the rule name +func (r *GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule) Name() string { + return "google_network_services_gateway_invalid_envoy_headers" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkServicesGatewayInvalidEnvoyHeadersRule) 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{"NONE", "DEBUG_HEADERS", ""}, 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_network_services_gateway_invalid_ip_version.go b/rules/magicmodules/google_network_services_gateway_invalid_ip_version.go new file mode 100644 index 0000000..573b6c1 --- /dev/null +++ b/rules/magicmodules/google_network_services_gateway_invalid_ip_version.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" +) + +// GoogleNetworkServicesGatewayInvalidIpVersionRule checks the pattern is valid +type GoogleNetworkServicesGatewayInvalidIpVersionRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkServicesGatewayInvalidIpVersionRule returns new rule with default attributes +func NewGoogleNetworkServicesGatewayInvalidIpVersionRule() *GoogleNetworkServicesGatewayInvalidIpVersionRule { + return &GoogleNetworkServicesGatewayInvalidIpVersionRule{ + resourceType: "google_network_services_gateway", + attributeName: "ip_version", + } +} + +// Name returns the rule name +func (r *GoogleNetworkServicesGatewayInvalidIpVersionRule) Name() string { + return "google_network_services_gateway_invalid_ip_version" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkServicesGatewayInvalidIpVersionRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkServicesGatewayInvalidIpVersionRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkServicesGatewayInvalidIpVersionRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkServicesGatewayInvalidIpVersionRule) 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{"IPV4", "IPV6", ""}, 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_network_services_gateway_invalid_type.go b/rules/magicmodules/google_network_services_gateway_invalid_type.go index 742e327..faeb627 100644 --- a/rules/magicmodules/google_network_services_gateway_invalid_type.go +++ b/rules/magicmodules/google_network_services_gateway_invalid_type.go @@ -72,7 +72,7 @@ func (r *GoogleNetworkServicesGatewayInvalidTypeRule) Check(runner tflint.Runner } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"TYPE_UNSPECIFIED", "OPEN_MESH", "SECURE_WEB_GATEWAY"}, false) + validateFunc := validation.StringInSlice([]string{"OPEN_MESH", "SECURE_WEB_GATEWAY"}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_network_services_grpc_route_invalid_location.go b/rules/magicmodules/google_network_services_grpc_route_invalid_location.go new file mode 100644 index 0000000..fad3e63 --- /dev/null +++ b/rules/magicmodules/google_network_services_grpc_route_invalid_location.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" +) + +// GoogleNetworkServicesGrpcRouteInvalidLocationRule checks the pattern is valid +type GoogleNetworkServicesGrpcRouteInvalidLocationRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkServicesGrpcRouteInvalidLocationRule returns new rule with default attributes +func NewGoogleNetworkServicesGrpcRouteInvalidLocationRule() *GoogleNetworkServicesGrpcRouteInvalidLocationRule { + return &GoogleNetworkServicesGrpcRouteInvalidLocationRule{ + resourceType: "google_network_services_grpc_route", + attributeName: "location", + } +} + +// Name returns the rule name +func (r *GoogleNetworkServicesGrpcRouteInvalidLocationRule) Name() string { + return "google_network_services_grpc_route_invalid_location" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkServicesGrpcRouteInvalidLocationRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkServicesGrpcRouteInvalidLocationRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkServicesGrpcRouteInvalidLocationRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkServicesGrpcRouteInvalidLocationRule) 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(`^global$`) + + _, 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_network_services_mesh_invalid_location.go b/rules/magicmodules/google_network_services_mesh_invalid_location.go new file mode 100644 index 0000000..b431ac5 --- /dev/null +++ b/rules/magicmodules/google_network_services_mesh_invalid_location.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" +) + +// GoogleNetworkServicesMeshInvalidLocationRule checks the pattern is valid +type GoogleNetworkServicesMeshInvalidLocationRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkServicesMeshInvalidLocationRule returns new rule with default attributes +func NewGoogleNetworkServicesMeshInvalidLocationRule() *GoogleNetworkServicesMeshInvalidLocationRule { + return &GoogleNetworkServicesMeshInvalidLocationRule{ + resourceType: "google_network_services_mesh", + attributeName: "location", + } +} + +// Name returns the rule name +func (r *GoogleNetworkServicesMeshInvalidLocationRule) Name() string { + return "google_network_services_mesh_invalid_location" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkServicesMeshInvalidLocationRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkServicesMeshInvalidLocationRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkServicesMeshInvalidLocationRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkServicesMeshInvalidLocationRule) 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(`^global$`) + + _, 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_parameter_manager_parameter_invalid_format.go b/rules/magicmodules/google_parameter_manager_parameter_invalid_format.go new file mode 100644 index 0000000..c74a9d0 --- /dev/null +++ b/rules/magicmodules/google_parameter_manager_parameter_invalid_format.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" +) + +// GoogleParameterManagerParameterInvalidFormatRule checks the pattern is valid +type GoogleParameterManagerParameterInvalidFormatRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleParameterManagerParameterInvalidFormatRule returns new rule with default attributes +func NewGoogleParameterManagerParameterInvalidFormatRule() *GoogleParameterManagerParameterInvalidFormatRule { + return &GoogleParameterManagerParameterInvalidFormatRule{ + resourceType: "google_parameter_manager_parameter", + attributeName: "format", + } +} + +// Name returns the rule name +func (r *GoogleParameterManagerParameterInvalidFormatRule) Name() string { + return "google_parameter_manager_parameter_invalid_format" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleParameterManagerParameterInvalidFormatRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleParameterManagerParameterInvalidFormatRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleParameterManagerParameterInvalidFormatRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleParameterManagerParameterInvalidFormatRule) 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{"UNFORMATTED", "YAML", "JSON", ""}, 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_parameter_manager_regional_parameter_invalid_format.go b/rules/magicmodules/google_parameter_manager_regional_parameter_invalid_format.go new file mode 100644 index 0000000..54ac253 --- /dev/null +++ b/rules/magicmodules/google_parameter_manager_regional_parameter_invalid_format.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" +) + +// GoogleParameterManagerRegionalParameterInvalidFormatRule checks the pattern is valid +type GoogleParameterManagerRegionalParameterInvalidFormatRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleParameterManagerRegionalParameterInvalidFormatRule returns new rule with default attributes +func NewGoogleParameterManagerRegionalParameterInvalidFormatRule() *GoogleParameterManagerRegionalParameterInvalidFormatRule { + return &GoogleParameterManagerRegionalParameterInvalidFormatRule{ + resourceType: "google_parameter_manager_regional_parameter", + attributeName: "format", + } +} + +// Name returns the rule name +func (r *GoogleParameterManagerRegionalParameterInvalidFormatRule) Name() string { + return "google_parameter_manager_regional_parameter_invalid_format" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleParameterManagerRegionalParameterInvalidFormatRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleParameterManagerRegionalParameterInvalidFormatRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleParameterManagerRegionalParameterInvalidFormatRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleParameterManagerRegionalParameterInvalidFormatRule) 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{"UNFORMATTED", "YAML", "JSON", ""}, 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_workflows_workflow_invalid_execution_history_level.go b/rules/magicmodules/google_workflows_workflow_invalid_execution_history_level.go new file mode 100644 index 0000000..52b4341 --- /dev/null +++ b/rules/magicmodules/google_workflows_workflow_invalid_execution_history_level.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" +) + +// GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule checks the pattern is valid +type GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule returns new rule with default attributes +func NewGoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule() *GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule { + return &GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule{ + resourceType: "google_workflows_workflow", + attributeName: "execution_history_level", + } +} + +// Name returns the rule name +func (r *GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule) Name() string { + return "google_workflows_workflow_invalid_execution_history_level" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule) 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{"EXECUTION_HISTORY_LEVEL_UNSPECIFIED", "EXECUTION_HISTORY_BASIC", "EXECUTION_HISTORY_DETAILED", ""}, 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/provider.go b/rules/magicmodules/provider.go index 7064a97..bb8b4f4 100644 --- a/rules/magicmodules/provider.go +++ b/rules/magicmodules/provider.go @@ -133,6 +133,8 @@ var Rules = []tflint.Rule{ NewGoogleComputeRouterNatInvalidAutoNetworkTierRule(), NewGoogleComputeRouterNatInvalidNatIpAllocateOptionRule(), NewGoogleComputeRouterNatInvalidSourceSubnetworkIpRangesToNatRule(), + NewGoogleComputeRouterNatInvalidTypeRule(), + NewGoogleComputeRouterRoutePolicyInvalidTypeRule(), NewGoogleComputeSslPolicyInvalidMinTlsVersionRule(), NewGoogleComputeSslPolicyInvalidProfileRule(), NewGoogleComputeSubnetworkInvalidIpv6AccessTypeRule(), @@ -182,13 +184,19 @@ var Rules = []tflint.Rule{ NewGoogleEdgecontainerClusterInvalidReleaseChannelRule(), NewGoogleFilestoreInstanceInvalidProtocolRule(), NewGoogleFirebaseAppCheckServiceConfigInvalidEnforcementModeRule(), + NewGoogleFirebaseAppHostingBackendInvalidServingLocalityRule(), NewGoogleFirestoreDatabaseInvalidAppEngineIntegrationModeRule(), NewGoogleFirestoreDatabaseInvalidConcurrencyModeRule(), + NewGoogleFirestoreDatabaseInvalidDatabaseEditionRule(), NewGoogleFirestoreDatabaseInvalidDeleteProtectionStateRule(), NewGoogleFirestoreDatabaseInvalidPointInTimeRecoveryEnablementRule(), NewGoogleFirestoreDatabaseInvalidTypeRule(), NewGoogleFirestoreIndexInvalidApiScopeRule(), + NewGoogleFirestoreIndexInvalidDensityRule(), NewGoogleFirestoreIndexInvalidQueryScopeRule(), + NewGoogleGeminiCodeToolsSettingBindingInvalidProductRule(), + NewGoogleGeminiDataSharingWithGoogleSettingBindingInvalidProductRule(), + NewGoogleGeminiGeminiGcpEnablementSettingBindingInvalidProductRule(), NewGoogleGeminiLoggingSettingBindingInvalidProductRule(), NewGoogleGeminiReleaseChannelSettingBindingInvalidProductRule(), NewGoogleHealthcareFhirStoreInvalidComplexDataTypeReferenceParsingRule(), @@ -217,6 +225,7 @@ var Rules = []tflint.Rule{ NewGoogleNetappVolumeQuotaRuleInvalidTypeRule(), NewGoogleNetappVolumeReplicationInvalidReplicationScheduleRule(), NewGoogleNetworkConnectivityGroupInvalidNameRule(), + NewGoogleNetworkConnectivityHubInvalidPolicyModeRule(), NewGoogleNetworkConnectivityHubInvalidPresetTopologyRule(), NewGoogleNetworkConnectivityInternalRangeInvalidPeeringRule(), NewGoogleNetworkConnectivityInternalRangeInvalidUsageRule(), @@ -231,16 +240,23 @@ var Rules = []tflint.Rule{ NewGoogleNetworkServicesAuthzExtensionInvalidLoadBalancingSchemeRule(), NewGoogleNetworkServicesAuthzExtensionInvalidWireFormatRule(), NewGoogleNetworkServicesEdgeCacheOriginInvalidProtocolRule(), + NewGoogleNetworkServicesEndpointPolicyInvalidTypeRule(), + NewGoogleNetworkServicesGatewayInvalidEnvoyHeadersRule(), + NewGoogleNetworkServicesGatewayInvalidIpVersionRule(), NewGoogleNetworkServicesGatewayInvalidRoutingModeRule(), NewGoogleNetworkServicesGatewayInvalidTypeRule(), + NewGoogleNetworkServicesGrpcRouteInvalidLocationRule(), NewGoogleNetworkServicesLbRouteExtensionInvalidLoadBalancingSchemeRule(), NewGoogleNetworkServicesLbTrafficExtensionInvalidLoadBalancingSchemeRule(), + NewGoogleNetworkServicesMeshInvalidLocationRule(), NewGoogleNotebooksInstanceInvalidBootDiskTypeRule(), NewGoogleNotebooksInstanceInvalidDataDiskTypeRule(), NewGoogleNotebooksInstanceInvalidDiskEncryptionRule(), NewGoogleNotebooksInstanceInvalidNicTypeRule(), NewGoogleOrgPolicyCustomConstraintInvalidActionTypeRule(), NewGoogleOsConfigPatchDeploymentInvalidPatchDeploymentIdRule(), + NewGoogleParameterManagerParameterInvalidFormatRule(), + NewGoogleParameterManagerRegionalParameterInvalidFormatRule(), NewGooglePrivatecaCaPoolInvalidTierRule(), NewGooglePrivatecaCertificateAuthorityInvalidTypeRule(), NewGooglePubsubSchemaInvalidTypeRule(), @@ -285,4 +301,5 @@ var Rules = []tflint.Rule{ NewGoogleVmwareengineNetworkPeeringInvalidPeerNetworkTypeRule(), NewGoogleVmwareenginePrivateCloudInvalidTypeRule(), NewGoogleWorkflowsWorkflowInvalidCallLogLevelRule(), + NewGoogleWorkflowsWorkflowInvalidExecutionHistoryLevelRule(), } diff --git a/rules/magicmodules/verify/validation.go b/rules/magicmodules/verify/validation.go index 3967336..25c0d28 100644 --- a/rules/magicmodules/verify/validation.go +++ b/rules/magicmodules/verify/validation.go @@ -337,6 +337,14 @@ func ValidateBase64String(i interface{}, val string) ([]string, []error) { return nil, nil } +func ValidateBase64URLString(i interface{}, val string) ([]string, []error) { + _, err := base64.URLEncoding.DecodeString(i.(string)) + if err != nil { + return nil, []error{fmt.Errorf("could not decode %q as a valid base64URL value.", val)} + } + return nil, nil +} + // StringNotInSlice returns a SchemaValidateFunc which tests if the provided value // is of type string and that it matches none of the element in the invalid slice. // if ignorecase is true, case is ignored. diff --git a/tools/magic-modules b/tools/magic-modules index 6faa546..b863028 160000 --- a/tools/magic-modules +++ b/tools/magic-modules @@ -1 +1 @@ -Subproject commit 6faa546e32a7d2b2c417f676abae0e759f405fca +Subproject commit b863028ebb63b8de85d0607c73d3814d0a2bf1c3