diff --git a/rules/magicmodules/api_definition.go b/rules/magicmodules/api_definition.go index 724531a7..2a366136 100644 --- a/rules/magicmodules/api_definition.go +++ b/rules/magicmodules/api_definition.go @@ -94,6 +94,7 @@ var APIDefinition = map[string]string{ "google_beyondcorp_security_gateway_application": "beyondcorp.googleapis.com", "google_biglake_catalog": "biglake.googleapis.com", "google_biglake_database": "biglake.googleapis.com", + "google_biglake_iceberg_catalog": "biglake.googleapis.com", "google_biglake_table": "biglake.googleapis.com", "google_bigquery_analytics_hub_data_exchange": "analyticshub.googleapis.com", "google_bigquery_analytics_hub_listing": "analyticshub.googleapis.com", @@ -126,6 +127,14 @@ var APIDefinition = map[string]string{ "google_certificate_manager_certificate_map_entry": "certificatemanager.googleapis.com", "google_certificate_manager_dns_authorization": "certificatemanager.googleapis.com", "google_certificate_manager_trust_config": "certificatemanager.googleapis.com", + "google_ces_agent": "ces.googleapis.com", + "google_ces_app": "ces.googleapis.com", + "google_ces_app_version": "ces.googleapis.com", + "google_ces_deployment": "ces.googleapis.com", + "google_ces_example": "ces.googleapis.com", + "google_ces_guardrail": "ces.googleapis.com", + "google_ces_tool": "ces.googleapis.com", + "google_ces_toolset": "ces.googleapis.com", "google_cloud_asset_folder_feed": "cloudasset.googleapis.com", "google_cloud_asset_organization_feed": "cloudasset.googleapis.com", "google_cloud_asset_project_feed": "cloudasset.googleapis.com", @@ -139,6 +148,7 @@ var APIDefinition = map[string]string{ "google_cloud_scheduler_job": "cloudscheduler.googleapis.com", "google_cloud_security_compliance_cloud_control": "cloudsecuritycompliance.googleapis.com", "google_cloud_security_compliance_framework": "cloudsecuritycompliance.googleapis.com", + "google_cloud_security_compliance_framework_deployment": "cloudsecuritycompliance.googleapis.com", "google_cloud_tasks_queue": "cloudtasks.googleapis.com", "google_cloudbuild_bitbucket_server_config": "cloudbuild.googleapis.com", "google_cloudbuild_trigger": "cloudbuild.googleapis.com", @@ -156,6 +166,7 @@ var APIDefinition = map[string]string{ "google_compute_backend_bucket_signed_url_key": "compute.googleapis.com", "google_compute_backend_service": "compute.googleapis.com", "google_compute_backend_service_signed_url_key": "compute.googleapis.com", + "google_compute_cross_site_network": "compute.googleapis.com", "google_compute_disk": "compute.googleapis.com", "google_compute_disk_resource_policy_attachment": "compute.googleapis.com", "google_compute_external_vpn_gateway": "compute.googleapis.com", @@ -195,6 +206,7 @@ var APIDefinition = map[string]string{ "google_compute_network_peering_routes_config": "compute.googleapis.com", "google_compute_node_group": "compute.googleapis.com", "google_compute_node_template": "compute.googleapis.com", + "google_compute_organization_security_policy": "compute.googleapis.com", "google_compute_packet_mirroring": "compute.googleapis.com", "google_compute_per_instance_config": "compute.googleapis.com", "google_compute_preview_feature": "compute.googleapis.com", @@ -248,6 +260,7 @@ var APIDefinition = map[string]string{ "google_compute_url_map": "compute.googleapis.com", "google_compute_vpn_gateway": "compute.googleapis.com", "google_compute_vpn_tunnel": "compute.googleapis.com", + "google_compute_wire_group": "compute.googleapis.com", "google_contact_center_insights_analysis_rule": "contactcenterinsights.googleapis.com", "google_contact_center_insights_view": "contactcenterinsights.googleapis.com", "google_container_analysis_note": "containeranalysis.googleapis.com", @@ -299,7 +312,9 @@ var APIDefinition = map[string]string{ "google_dialogflow_encryption_spec": "dialogflow.googleapis.com", "google_dialogflow_entity_type": "dialogflow.googleapis.com", "google_dialogflow_fulfillment": "dialogflow.googleapis.com", + "google_dialogflow_generator": "dialogflow.googleapis.com", "google_dialogflow_intent": "dialogflow.googleapis.com", + "google_dialogflow_version": "dialogflow.googleapis.com", "google_dns_managed_zone": "dns.googleapis.com", "google_dns_policy": "dns.googleapis.com", "google_dns_response_policy": "dns.googleapis.com", @@ -391,6 +406,7 @@ var APIDefinition = map[string]string{ "google_iam_workforce_pool_provider": "iam.googleapis.com", "google_iam_workforce_pool_provider_key": "iam.googleapis.com", "google_iam_workforce_pool_provider_scim_tenant": "iam.googleapis.com", + "google_iam_workforce_pool_provider_scim_token": "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", @@ -451,6 +467,7 @@ var APIDefinition = map[string]string{ "google_netapp_backup": "netapp.googleapis.com", "google_netapp_backup_policy": "netapp.googleapis.com", "google_netapp_backup_vault": "netapp.googleapis.com", + "google_netapp_host_group": "netapp.googleapis.com", "google_netapp_kmsconfig": "netapp.googleapis.com", "google_netapp_storage_pool": "netapp.googleapis.com", "google_netapp_volume": "netapp.googleapis.com", @@ -465,6 +482,7 @@ var APIDefinition = map[string]string{ "google_network_connectivity_service_connection_policy": "networkconnectivity.googleapis.com", "google_network_connectivity_spoke": "networkconnectivity.googleapis.com", "google_network_management_connectivity_test": "networkmanagement.googleapis.com", + "google_network_management_organization_vpc_flow_logs_config": "networkmanagement.googleapis.com", "google_network_management_vpc_flow_logs_config": "networkmanagement.googleapis.com", "google_network_security_address_group": "networksecurity.googleapis.com", "google_network_security_authz_policy": "networksecurity.googleapis.com", @@ -495,9 +513,19 @@ var APIDefinition = map[string]string{ "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_edge_extension": "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_multicast_consumer_association": "networkservices.googleapis.com", + "google_network_services_multicast_domain": "networkservices.googleapis.com", + "google_network_services_multicast_domain_activation": "networkservices.googleapis.com", + "google_network_services_multicast_domain_group": "networkservices.googleapis.com", + "google_network_services_multicast_group_consumer_activation": "networkservices.googleapis.com", + "google_network_services_multicast_group_producer_activation": "networkservices.googleapis.com", + "google_network_services_multicast_group_range": "networkservices.googleapis.com", + "google_network_services_multicast_group_range_activation": "networkservices.googleapis.com", + "google_network_services_multicast_producer_association": "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", @@ -509,6 +537,7 @@ var APIDefinition = map[string]string{ "google_oracle_database_cloud_exadata_infrastructure": "oracledatabase.googleapis.com", "google_oracle_database_cloud_vm_cluster": "oracledatabase.googleapis.com", "google_oracle_database_db_system": "oracledatabase.googleapis.com", + "google_oracle_database_exascale_db_storage_vault": "oracledatabase.googleapis.com", "google_oracle_database_odb_network": "oracledatabase.googleapis.com", "google_oracle_database_odb_subnet": "oracledatabase.googleapis.com", "google_org_policy_custom_constraint": "orgpolicy.googleapis.com", @@ -572,6 +601,9 @@ var APIDefinition = map[string]string{ "google_secure_source_manager_repository": "securesourcemanager.googleapis.com", "google_securityposture_posture": "securityposture.googleapis.com", "google_securityposture_posture_deployment": "securityposture.googleapis.com", + "google_service_directory_endpoint": "servicedirectory.googleapis.com", + "google_service_directory_namespace": "servicedirectory.googleapis.com", + "google_service_directory_service": "servicedirectory.googleapis.com", "google_service_networking_vpc_service_controls": "servicenetworking.googleapis.com", "google_site_verification_web_resource": "www.googleapis.com", "google_sourcerepo_repository": "sourcerepo.googleapis.com", diff --git a/rules/magicmodules/google_biglake_iceberg_catalog_invalid_catalog_type.go b/rules/magicmodules/google_biglake_iceberg_catalog_invalid_catalog_type.go new file mode 100644 index 00000000..ba3bda0c --- /dev/null +++ b/rules/magicmodules/google_biglake_iceberg_catalog_invalid_catalog_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" +) + +// GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule checks the pattern is valid +type GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleBiglakeIcebergCatalogInvalidCatalogTypeRule returns new rule with default attributes +func NewGoogleBiglakeIcebergCatalogInvalidCatalogTypeRule() *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule { + return &GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule{ + resourceType: "google_biglake_iceberg_catalog", + attributeName: "catalog_type", + } +} + +// Name returns the rule name +func (r *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule) Name() string { + return "google_biglake_iceberg_catalog_invalid_catalog_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleBiglakeIcebergCatalogInvalidCatalogTypeRule) 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{"CATALOG_TYPE_GCS_BUCKET"}, 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_biglake_iceberg_catalog_invalid_credential_mode.go b/rules/magicmodules/google_biglake_iceberg_catalog_invalid_credential_mode.go new file mode 100644 index 00000000..29c71bff --- /dev/null +++ b/rules/magicmodules/google_biglake_iceberg_catalog_invalid_credential_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" +) + +// GoogleBiglakeIcebergCatalogInvalidCredentialModeRule checks the pattern is valid +type GoogleBiglakeIcebergCatalogInvalidCredentialModeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleBiglakeIcebergCatalogInvalidCredentialModeRule returns new rule with default attributes +func NewGoogleBiglakeIcebergCatalogInvalidCredentialModeRule() *GoogleBiglakeIcebergCatalogInvalidCredentialModeRule { + return &GoogleBiglakeIcebergCatalogInvalidCredentialModeRule{ + resourceType: "google_biglake_iceberg_catalog", + attributeName: "credential_mode", + } +} + +// Name returns the rule name +func (r *GoogleBiglakeIcebergCatalogInvalidCredentialModeRule) Name() string { + return "google_biglake_iceberg_catalog_invalid_credential_mode" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleBiglakeIcebergCatalogInvalidCredentialModeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleBiglakeIcebergCatalogInvalidCredentialModeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleBiglakeIcebergCatalogInvalidCredentialModeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleBiglakeIcebergCatalogInvalidCredentialModeRule) 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{"CREDENTIAL_MODE_END_USER", "CREDENTIAL_MODE_VENDED_CREDENTIALS", ""}, 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_cross_site_network_invalid_name.go b/rules/magicmodules/google_compute_cross_site_network_invalid_name.go new file mode 100644 index 00000000..e93de9bd --- /dev/null +++ b/rules/magicmodules/google_compute_cross_site_network_invalid_name.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" +) + +// GoogleComputeCrossSiteNetworkInvalidNameRule checks the pattern is valid +type GoogleComputeCrossSiteNetworkInvalidNameRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeCrossSiteNetworkInvalidNameRule returns new rule with default attributes +func NewGoogleComputeCrossSiteNetworkInvalidNameRule() *GoogleComputeCrossSiteNetworkInvalidNameRule { + return &GoogleComputeCrossSiteNetworkInvalidNameRule{ + resourceType: "google_compute_cross_site_network", + attributeName: "name", + } +} + +// Name returns the rule name +func (r *GoogleComputeCrossSiteNetworkInvalidNameRule) Name() string { + return "google_compute_cross_site_network_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeCrossSiteNetworkInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeCrossSiteNetworkInvalidNameRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeCrossSiteNetworkInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeCrossSiteNetworkInvalidNameRule) Check(runner tflint.Runner) error { + resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{ + Attributes: []hclext.AttributeSchema{{Name: r.attributeName}}, + }, nil) + if err != nil { + return err + } + + for _, resource := range resources.Blocks { + attribute, exists := resource.Body.Attributes[r.attributeName] + if !exists { + continue + } + + err := runner.EvaluateExpr(attribute.Expr, func(val string) error { + validateFunc := validateRegexp(`^[a-z]([-a-z0-9]*[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/google_compute_organization_security_policy_invalid_type.go b/rules/magicmodules/google_compute_organization_security_policy_invalid_type.go new file mode 100644 index 00000000..fc257fe7 --- /dev/null +++ b/rules/magicmodules/google_compute_organization_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" +) + +// GoogleComputeOrganizationSecurityPolicyInvalidTypeRule checks the pattern is valid +type GoogleComputeOrganizationSecurityPolicyInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeOrganizationSecurityPolicyInvalidTypeRule returns new rule with default attributes +func NewGoogleComputeOrganizationSecurityPolicyInvalidTypeRule() *GoogleComputeOrganizationSecurityPolicyInvalidTypeRule { + return &GoogleComputeOrganizationSecurityPolicyInvalidTypeRule{ + resourceType: "google_compute_organization_security_policy", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleComputeOrganizationSecurityPolicyInvalidTypeRule) Name() string { + return "google_compute_organization_security_policy_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeOrganizationSecurityPolicyInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeOrganizationSecurityPolicyInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeOrganizationSecurityPolicyInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeOrganizationSecurityPolicyInvalidTypeRule) 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{"FIREWALL", "CLOUD_ARMOR", "CLOUD_ARMOR_EDGE", "CLOUD_ARMOR_INTERNAL_SERVICE", "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_public_advertised_prefix_invalid_ipv6_access_type.go b/rules/magicmodules/google_compute_public_advertised_prefix_invalid_ipv6_access_type.go new file mode 100644 index 00000000..c3093ca9 --- /dev/null +++ b/rules/magicmodules/google_compute_public_advertised_prefix_invalid_ipv6_access_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" +) + +// GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule checks the pattern is valid +type GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule returns new rule with default attributes +func NewGoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule() *GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule { + return &GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule{ + resourceType: "google_compute_public_advertised_prefix", + attributeName: "ipv6_access_type", + } +} + +// Name returns the rule name +func (r *GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule) Name() string { + return "google_compute_public_advertised_prefix_invalid_ipv6_access_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule) 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{"EXTERNAL", "INTERNAL", ""}, 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_public_delegated_prefix_invalid_mode.go b/rules/magicmodules/google_compute_public_delegated_prefix_invalid_mode.go index a11f4b1f..8f1109b2 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", "EXTERNAL_IPV6_SUBNETWORK_CREATION", ""}, false) + validateFunc := validation.StringInSlice([]string{"DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION", "EXTERNAL_IPV6_SUBNETWORK_CREATION", "INTERNAL_IPV6_SUBNETWORK_CREATION", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_compute_snapshot_invalid_snapshot_type.go b/rules/magicmodules/google_compute_snapshot_invalid_snapshot_type.go new file mode 100644 index 00000000..8d34959f --- /dev/null +++ b/rules/magicmodules/google_compute_snapshot_invalid_snapshot_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" +) + +// GoogleComputeSnapshotInvalidSnapshotTypeRule checks the pattern is valid +type GoogleComputeSnapshotInvalidSnapshotTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeSnapshotInvalidSnapshotTypeRule returns new rule with default attributes +func NewGoogleComputeSnapshotInvalidSnapshotTypeRule() *GoogleComputeSnapshotInvalidSnapshotTypeRule { + return &GoogleComputeSnapshotInvalidSnapshotTypeRule{ + resourceType: "google_compute_snapshot", + attributeName: "snapshot_type", + } +} + +// Name returns the rule name +func (r *GoogleComputeSnapshotInvalidSnapshotTypeRule) Name() string { + return "google_compute_snapshot_invalid_snapshot_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeSnapshotInvalidSnapshotTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeSnapshotInvalidSnapshotTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeSnapshotInvalidSnapshotTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeSnapshotInvalidSnapshotTypeRule) 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{"ARCHIVE", "STANDARD", ""}, 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_wire_group_invalid_name.go b/rules/magicmodules/google_compute_wire_group_invalid_name.go new file mode 100644 index 00000000..9f32523d --- /dev/null +++ b/rules/magicmodules/google_compute_wire_group_invalid_name.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" +) + +// GoogleComputeWireGroupInvalidNameRule checks the pattern is valid +type GoogleComputeWireGroupInvalidNameRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeWireGroupInvalidNameRule returns new rule with default attributes +func NewGoogleComputeWireGroupInvalidNameRule() *GoogleComputeWireGroupInvalidNameRule { + return &GoogleComputeWireGroupInvalidNameRule{ + resourceType: "google_compute_wire_group", + attributeName: "name", + } +} + +// Name returns the rule name +func (r *GoogleComputeWireGroupInvalidNameRule) Name() string { + return "google_compute_wire_group_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeWireGroupInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeWireGroupInvalidNameRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeWireGroupInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeWireGroupInvalidNameRule) Check(runner tflint.Runner) error { + resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{ + Attributes: []hclext.AttributeSchema{{Name: r.attributeName}}, + }, nil) + if err != nil { + return err + } + + for _, resource := range resources.Blocks { + attribute, exists := resource.Body.Attributes[r.attributeName] + if !exists { + continue + } + + err := runner.EvaluateExpr(attribute.Expr, func(val string) error { + validateFunc := validateRegexp(`^[a-z]([-a-z0-9]*[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/google_dialogflow_generator_invalid_trigger_event.go b/rules/magicmodules/google_dialogflow_generator_invalid_trigger_event.go new file mode 100644 index 00000000..d1962a93 --- /dev/null +++ b/rules/magicmodules/google_dialogflow_generator_invalid_trigger_event.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" +) + +// GoogleDialogflowGeneratorInvalidTriggerEventRule checks the pattern is valid +type GoogleDialogflowGeneratorInvalidTriggerEventRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleDialogflowGeneratorInvalidTriggerEventRule returns new rule with default attributes +func NewGoogleDialogflowGeneratorInvalidTriggerEventRule() *GoogleDialogflowGeneratorInvalidTriggerEventRule { + return &GoogleDialogflowGeneratorInvalidTriggerEventRule{ + resourceType: "google_dialogflow_generator", + attributeName: "trigger_event", + } +} + +// Name returns the rule name +func (r *GoogleDialogflowGeneratorInvalidTriggerEventRule) Name() string { + return "google_dialogflow_generator_invalid_trigger_event" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleDialogflowGeneratorInvalidTriggerEventRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleDialogflowGeneratorInvalidTriggerEventRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleDialogflowGeneratorInvalidTriggerEventRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleDialogflowGeneratorInvalidTriggerEventRule) 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{"END_OF_UTTERANCE", "MANUAL_CALL", "CUSTOMER_MESSAGE", "AGENT_MESSAGE", ""}, 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_discovery_engine_control_invalid_solution_type.go b/rules/magicmodules/google_discovery_engine_control_invalid_solution_type.go new file mode 100644 index 00000000..ea617460 --- /dev/null +++ b/rules/magicmodules/google_discovery_engine_control_invalid_solution_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" +) + +// GoogleDiscoveryEngineControlInvalidSolutionTypeRule checks the pattern is valid +type GoogleDiscoveryEngineControlInvalidSolutionTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleDiscoveryEngineControlInvalidSolutionTypeRule returns new rule with default attributes +func NewGoogleDiscoveryEngineControlInvalidSolutionTypeRule() *GoogleDiscoveryEngineControlInvalidSolutionTypeRule { + return &GoogleDiscoveryEngineControlInvalidSolutionTypeRule{ + resourceType: "google_discovery_engine_control", + attributeName: "solution_type", + } +} + +// Name returns the rule name +func (r *GoogleDiscoveryEngineControlInvalidSolutionTypeRule) Name() string { + return "google_discovery_engine_control_invalid_solution_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleDiscoveryEngineControlInvalidSolutionTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleDiscoveryEngineControlInvalidSolutionTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleDiscoveryEngineControlInvalidSolutionTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleDiscoveryEngineControlInvalidSolutionTypeRule) 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{"SOLUTION_TYPE_RECOMMENDATION", "SOLUTION_TYPE_SEARCH", "SOLUTION_TYPE_CHAT", "SOLUTION_TYPE_GENERATIVE_CHAT"}, 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_host_group_invalid_os_type.go b/rules/magicmodules/google_netapp_host_group_invalid_os_type.go new file mode 100644 index 00000000..d98430b9 --- /dev/null +++ b/rules/magicmodules/google_netapp_host_group_invalid_os_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" +) + +// GoogleNetappHostGroupInvalidOsTypeRule checks the pattern is valid +type GoogleNetappHostGroupInvalidOsTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetappHostGroupInvalidOsTypeRule returns new rule with default attributes +func NewGoogleNetappHostGroupInvalidOsTypeRule() *GoogleNetappHostGroupInvalidOsTypeRule { + return &GoogleNetappHostGroupInvalidOsTypeRule{ + resourceType: "google_netapp_host_group", + attributeName: "os_type", + } +} + +// Name returns the rule name +func (r *GoogleNetappHostGroupInvalidOsTypeRule) Name() string { + return "google_netapp_host_group_invalid_os_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetappHostGroupInvalidOsTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetappHostGroupInvalidOsTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetappHostGroupInvalidOsTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetappHostGroupInvalidOsTypeRule) 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{"LINUX", "WINDOWS", "ESXI"}, 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_host_group_invalid_type.go b/rules/magicmodules/google_netapp_host_group_invalid_type.go new file mode 100644 index 00000000..b551fc8b --- /dev/null +++ b/rules/magicmodules/google_netapp_host_group_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" +) + +// GoogleNetappHostGroupInvalidTypeRule checks the pattern is valid +type GoogleNetappHostGroupInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetappHostGroupInvalidTypeRule returns new rule with default attributes +func NewGoogleNetappHostGroupInvalidTypeRule() *GoogleNetappHostGroupInvalidTypeRule { + return &GoogleNetappHostGroupInvalidTypeRule{ + resourceType: "google_netapp_host_group", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleNetappHostGroupInvalidTypeRule) Name() string { + return "google_netapp_host_group_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetappHostGroupInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetappHostGroupInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetappHostGroupInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetappHostGroupInvalidTypeRule) 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{"ISCSI_INITIATOR"}, 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_storage_pool_invalid_type.go b/rules/magicmodules/google_netapp_storage_pool_invalid_type.go new file mode 100644 index 00000000..4b7c4bc0 --- /dev/null +++ b/rules/magicmodules/google_netapp_storage_pool_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" +) + +// GoogleNetappStoragePoolInvalidTypeRule checks the pattern is valid +type GoogleNetappStoragePoolInvalidTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetappStoragePoolInvalidTypeRule returns new rule with default attributes +func NewGoogleNetappStoragePoolInvalidTypeRule() *GoogleNetappStoragePoolInvalidTypeRule { + return &GoogleNetappStoragePoolInvalidTypeRule{ + resourceType: "google_netapp_storage_pool", + attributeName: "type", + } +} + +// Name returns the rule name +func (r *GoogleNetappStoragePoolInvalidTypeRule) Name() string { + return "google_netapp_storage_pool_invalid_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetappStoragePoolInvalidTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetappStoragePoolInvalidTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetappStoragePoolInvalidTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetappStoragePoolInvalidTypeRule) 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{"STORAGE_POOL_TYPE_UNSPECIFIED", "FILE", "UNIFIED", ""}, 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_management_organization_vpc_flow_logs_config_invalid_cross_project_metadata.go b/rules/magicmodules/google_network_management_organization_vpc_flow_logs_config_invalid_cross_project_metadata.go new file mode 100644 index 00000000..6d5a6444 --- /dev/null +++ b/rules/magicmodules/google_network_management_organization_vpc_flow_logs_config_invalid_cross_project_metadata.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" +) + +// GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule checks the pattern is valid +type GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule returns new rule with default attributes +func NewGoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule() *GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule { + return &GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule{ + resourceType: "google_network_management_organization_vpc_flow_logs_config", + attributeName: "cross_project_metadata", + } +} + +// Name returns the rule name +func (r *GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule) Name() string { + return "google_network_management_organization_vpc_flow_logs_config_invalid_cross_project_metadata" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule) 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{"CROSS_PROJECT_METADATA_ENABLED", "CROSS_PROJECT_METADATA_DISABLED", ""}, 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_lb_edge_extension_invalid_load_balancing_scheme.go b/rules/magicmodules/google_network_services_lb_edge_extension_invalid_load_balancing_scheme.go new file mode 100644 index 00000000..3fe1f0c8 --- /dev/null +++ b/rules/magicmodules/google_network_services_lb_edge_extension_invalid_load_balancing_scheme.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" +) + +// GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule checks the pattern is valid +type GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule returns new rule with default attributes +func NewGoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule() *GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule { + return &GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule{ + resourceType: "google_network_services_lb_edge_extension", + attributeName: "load_balancing_scheme", + } +} + +// Name returns the rule name +func (r *GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule) Name() string { + return "google_network_services_lb_edge_extension_invalid_load_balancing_scheme" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule) 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{"EXTERNAL_MANAGED"}, 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 90537afa..64b7933c 100644 --- a/rules/magicmodules/provider.go +++ b/rules/magicmodules/provider.go @@ -55,6 +55,8 @@ var Rules = []tflint.Rule{ NewGoogleBeyondcorpAppGatewayInvalidTypeRule(), NewGoogleBeyondcorpSecurityGatewayApplicationInvalidSchemaRule(), NewGoogleBeyondcorpSecurityGatewayInvalidLocationRule(), + NewGoogleBiglakeIcebergCatalogInvalidCatalogTypeRule(), + NewGoogleBiglakeIcebergCatalogInvalidCredentialModeRule(), NewGoogleBiglakeTableInvalidTypeRule(), NewGoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule(), NewGoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule(), @@ -97,6 +99,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeBackendServiceInvalidProtocolRule(), NewGoogleComputeBackendServiceInvalidSessionAffinityRule(), NewGoogleComputeBackendServiceSignedUrlKeyInvalidNameRule(), + NewGoogleComputeCrossSiteNetworkInvalidNameRule(), NewGoogleComputeExternalVpnGatewayInvalidRedundancyTypeRule(), NewGoogleComputeFirewallInvalidDirectionRule(), NewGoogleComputeFirewallPolicyRuleInvalidDirectionRule(), @@ -132,8 +135,10 @@ var Rules = []tflint.Rule{ NewGoogleComputeNetworkFirewallPolicyWithRulesInvalidPolicyTypeRule(), NewGoogleComputeNetworkInvalidNetworkFirewallPolicyEnforcementOrderRule(), NewGoogleComputeNodeTemplateInvalidCpuOvercommitTypeRule(), + NewGoogleComputeOrganizationSecurityPolicyInvalidTypeRule(), NewGoogleComputePreviewFeatureInvalidActivationStatusRule(), NewGoogleComputeProjectCloudArmorTierInvalidCloudArmorTierRule(), + NewGoogleComputePublicAdvertisedPrefixInvalidIpv6AccessTypeRule(), NewGoogleComputePublicAdvertisedPrefixInvalidPdpScopeRule(), NewGoogleComputePublicDelegatedPrefixInvalidModeRule(), NewGoogleComputeRegionBackendServiceInvalidIpAddressSelectionPolicyRule(), @@ -158,6 +163,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeRouterNatInvalidSourceSubnetworkIpRangesToNat64Rule(), NewGoogleComputeRouterNatInvalidTypeRule(), NewGoogleComputeRouterRoutePolicyInvalidTypeRule(), + NewGoogleComputeSnapshotInvalidSnapshotTypeRule(), NewGoogleComputeSslPolicyInvalidMinTlsVersionRule(), NewGoogleComputeSslPolicyInvalidProfileRule(), NewGoogleComputeStoragePoolInvalidCapacityProvisioningTypeRule(), @@ -170,6 +176,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeTargetInstanceInvalidNatPolicyRule(), NewGoogleComputeTargetSslProxyInvalidProxyHeaderRule(), NewGoogleComputeTargetTcpProxyInvalidProxyHeaderRule(), + NewGoogleComputeWireGroupInvalidNameRule(), NewGoogleDataCatalogEntryGroupInvalidEntryGroupIdRule(), NewGoogleDataCatalogEntryInvalidTypeRule(), NewGoogleDataCatalogEntryInvalidUserSpecifiedSystemRule(), @@ -198,8 +205,10 @@ var Rules = []tflint.Rule{ NewGoogleDialogflowCxSecuritySettingsInvalidRedactionStrategyRule(), NewGoogleDialogflowCxSecuritySettingsInvalidRetentionStrategyRule(), NewGoogleDialogflowEntityTypeInvalidKindRule(), + NewGoogleDialogflowGeneratorInvalidTriggerEventRule(), NewGoogleDialogflowIntentInvalidWebhookStateRule(), NewGoogleDiscoveryEngineChatEngineInvalidIndustryVerticalRule(), + NewGoogleDiscoveryEngineControlInvalidSolutionTypeRule(), NewGoogleDiscoveryEngineDataStoreInvalidContentConfigRule(), NewGoogleDiscoveryEngineDataStoreInvalidIndustryVerticalRule(), NewGoogleDiscoveryEngineLicenseConfigInvalidSubscriptionTermRule(), @@ -251,8 +260,11 @@ var Rules = []tflint.Rule{ NewGoogleMonitoringSloInvalidSloIdRule(), NewGoogleMonitoringUptimeCheckConfigInvalidCheckerTypeRule(), NewGoogleNetappBackupVaultInvalidBackupVaultTypeRule(), + NewGoogleNetappHostGroupInvalidOsTypeRule(), + NewGoogleNetappHostGroupInvalidTypeRule(), NewGoogleNetappStoragePoolInvalidQosTypeRule(), NewGoogleNetappStoragePoolInvalidServiceLevelRule(), + NewGoogleNetappStoragePoolInvalidTypeRule(), NewGoogleNetappVolumeInvalidSecurityStyleRule(), NewGoogleNetappVolumeQuotaRuleInvalidTypeRule(), NewGoogleNetappVolumeReplicationInvalidReplicationScheduleRule(), @@ -263,6 +275,7 @@ var Rules = []tflint.Rule{ NewGoogleNetworkConnectivityInternalRangeInvalidUsageRule(), NewGoogleNetworkConnectivityPolicyBasedRouteInvalidNextHopOtherRoutesRule(), NewGoogleNetworkConnectivityRegionalEndpointInvalidAccessTypeRule(), + NewGoogleNetworkManagementOrganizationVpcFlowLogsConfigInvalidCrossProjectMetadataRule(), NewGoogleNetworkSecurityAddressGroupInvalidTypeRule(), NewGoogleNetworkSecurityAuthzPolicyInvalidActionRule(), NewGoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule(), @@ -279,6 +292,7 @@ var Rules = []tflint.Rule{ NewGoogleNetworkServicesGatewayInvalidRoutingModeRule(), NewGoogleNetworkServicesGatewayInvalidTypeRule(), NewGoogleNetworkServicesGrpcRouteInvalidLocationRule(), + NewGoogleNetworkServicesLbEdgeExtensionInvalidLoadBalancingSchemeRule(), NewGoogleNetworkServicesLbRouteExtensionInvalidLoadBalancingSchemeRule(), NewGoogleNetworkServicesLbTrafficExtensionInvalidLoadBalancingSchemeRule(), NewGoogleNetworkServicesMeshInvalidLocationRule(), diff --git a/tools/magic-modules b/tools/magic-modules index d3a48f39..402ef40d 160000 --- a/tools/magic-modules +++ b/tools/magic-modules @@ -1 +1 @@ -Subproject commit d3a48f39aaea4df5b18c2ebfe91a036a55ff54af +Subproject commit 402ef40d8fc9c3c3e02fee7074783e772faea868