diff --git a/rules/magicmodules/api_definition.go b/rules/magicmodules/api_definition.go index b9458ab..b0ec11d 100644 --- a/rules/magicmodules/api_definition.go +++ b/rules/magicmodules/api_definition.go @@ -38,6 +38,7 @@ var APIDefinition = map[string]string{ "google_alloydb_instance": "alloydb.googleapis.com", "google_alloydb_user": "alloydb.googleapis.com", "google_apigee_addons_config": "apigee.googleapis.com", + "google_apigee_api_product": "apigee.googleapis.com", "google_apigee_app_group": "apigee.googleapis.com", "google_apigee_control_plane_access": "apigee.googleapis.com", "google_apigee_developer": "apigee.googleapis.com", @@ -56,6 +57,7 @@ var APIDefinition = map[string]string{ "google_apigee_keystores_aliases_self_signed_cert": "apigee.googleapis.com", "google_apigee_nat_address": "apigee.googleapis.com", "google_apigee_organization": "apigee.googleapis.com", + "google_apigee_security_action": "apigee.googleapis.com", "google_apigee_security_monitoring_condition": "apigee.googleapis.com", "google_apigee_security_profile_v2": "apigee.googleapis.com", "google_apigee_sync_authorization": "apigee.googleapis.com", @@ -81,6 +83,7 @@ var APIDefinition = map[string]string{ "google_backup_dr_backup_plan_association": "backupdr.googleapis.com", "google_backup_dr_backup_vault": "backupdr.googleapis.com", "google_backup_dr_management_server": "backupdr.googleapis.com", + "google_backup_dr_service_config": "backupdr.googleapis.com", "google_beyondcorp_app_connection": "beyondcorp.googleapis.com", "google_beyondcorp_app_connector": "beyondcorp.googleapis.com", "google_beyondcorp_app_gateway": "beyondcorp.googleapis.com", @@ -108,6 +111,7 @@ var APIDefinition = map[string]string{ "google_bigtable_app_profile": "bigtableadmin.googleapis.com", "google_bigtable_logical_view": "bigtableadmin.googleapis.com", "google_bigtable_materialized_view": "bigtableadmin.googleapis.com", + "google_bigtable_schema_bundle": "bigtableadmin.googleapis.com", "google_billing_budget": "billingbudgets.googleapis.com", "google_billing_project_info": "cloudbilling.googleapis.com", "google_binary_authorization_attestor": "binaryauthorization.googleapis.com", @@ -282,6 +286,7 @@ var APIDefinition = map[string]string{ "google_developer_connect_account_connector": "developerconnect.googleapis.com", "google_developer_connect_connection": "developerconnect.googleapis.com", "google_developer_connect_git_repository_link": "developerconnect.googleapis.com", + "google_developer_connect_insights_config": "developerconnect.googleapis.com", "google_dialogflow_agent": "dialogflow.googleapis.com", "google_dialogflow_encryption_spec": "dialogflow.googleapis.com", "google_dialogflow_entity_type": "dialogflow.googleapis.com", @@ -355,6 +360,7 @@ var APIDefinition = map[string]string{ "google_gkeonprem_bare_metal_admin_cluster": "gkeonprem.googleapis.com", "google_gkeonprem_bare_metal_cluster": "gkeonprem.googleapis.com", "google_gkeonprem_bare_metal_node_pool": "gkeonprem.googleapis.com", + "google_gkeonprem_vmware_admin_cluster": "gkeonprem.googleapis.com", "google_gkeonprem_vmware_cluster": "gkeonprem.googleapis.com", "google_gkeonprem_vmware_node_pool": "gkeonprem.googleapis.com", "google_healthcare_consent_store": "healthcare.googleapis.com", @@ -394,9 +400,11 @@ var APIDefinition = map[string]string{ "google_integration_connectors_managed_zone": "connectors.googleapis.com", "google_integrations_auth_config": "integrations.googleapis.com", "google_integrations_client": "integrations.googleapis.com", + "google_kms_autokey_config": "cloudkms.googleapis.com", "google_kms_crypto_key": "cloudkms.googleapis.com", "google_kms_crypto_key_version": "cloudkms.googleapis.com", "google_kms_ekm_connection": "cloudkms.googleapis.com", + "google_kms_key_handle": "cloudkms.googleapis.com", "google_kms_key_ring": "cloudkms.googleapis.com", "google_kms_key_ring_import_job": "cloudkms.googleapis.com", "google_kms_secret_ciphertext": "cloudkms.googleapis.com", @@ -417,6 +425,7 @@ var APIDefinition = map[string]string{ "google_migration_center_group": "migrationcenter.googleapis.com", "google_migration_center_preference_set": "migrationcenter.googleapis.com", "google_ml_engine_model": "ml.googleapis.com", + "google_model_armor_floorsetting": "modelarmor.googleapis.com", "google_monitoring_alert_policy": "monitoring.googleapis.com", "google_monitoring_custom_service": "monitoring.googleapis.com", "google_monitoring_group": "monitoring.googleapis.com", @@ -447,6 +456,7 @@ var APIDefinition = map[string]string{ "google_network_management_vpc_flow_logs_config": "networkmanagement.googleapis.com", "google_network_security_address_group": "networksecurity.googleapis.com", "google_network_security_authz_policy": "networksecurity.googleapis.com", + "google_network_security_backend_authentication_config": "networksecurity.googleapis.com", "google_network_security_client_tls_policy": "networksecurity.googleapis.com", "google_network_security_firewall_endpoint": "networksecurity.googleapis.com", "google_network_security_firewall_endpoint_association": "networksecurity.googleapis.com", @@ -486,6 +496,8 @@ var APIDefinition = map[string]string{ "google_oracle_database_autonomous_database": "oracledatabase.googleapis.com", "google_oracle_database_cloud_exadata_infrastructure": "oracledatabase.googleapis.com", "google_oracle_database_cloud_vm_cluster": "oracledatabase.googleapis.com", + "google_oracle_database_odb_network": "oracledatabase.googleapis.com", + "google_oracle_database_odb_subnet": "oracledatabase.googleapis.com", "google_org_policy_custom_constraint": "orgpolicy.googleapis.com", "google_org_policy_policy": "orgpolicy.googleapis.com", "google_organization_access_approval_settings": "accessapproval.googleapis.com", @@ -564,6 +576,7 @@ var APIDefinition = map[string]string{ "google_storage_default_object_access_control": "storage.googleapis.com", "google_storage_folder": "storage.googleapis.com", "google_storage_hmac_key": "storage.googleapis.com", + "google_storage_insights_dataset_config": "storageinsights.googleapis.com", "google_storage_insights_report_config": "storageinsights.googleapis.com", "google_storage_managed_folder": "storage.googleapis.com", "google_storage_object_access_control": "storage.googleapis.com", diff --git a/rules/magicmodules/google_apigee_api_product_invalid_approval_type.go b/rules/magicmodules/google_apigee_api_product_invalid_approval_type.go new file mode 100644 index 0000000..51b7d2b --- /dev/null +++ b/rules/magicmodules/google_apigee_api_product_invalid_approval_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" +) + +// GoogleApigeeApiProductInvalidApprovalTypeRule checks the pattern is valid +type GoogleApigeeApiProductInvalidApprovalTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleApigeeApiProductInvalidApprovalTypeRule returns new rule with default attributes +func NewGoogleApigeeApiProductInvalidApprovalTypeRule() *GoogleApigeeApiProductInvalidApprovalTypeRule { + return &GoogleApigeeApiProductInvalidApprovalTypeRule{ + resourceType: "google_apigee_api_product", + attributeName: "approval_type", + } +} + +// Name returns the rule name +func (r *GoogleApigeeApiProductInvalidApprovalTypeRule) Name() string { + return "google_apigee_api_product_invalid_approval_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleApigeeApiProductInvalidApprovalTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleApigeeApiProductInvalidApprovalTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleApigeeApiProductInvalidApprovalTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleApigeeApiProductInvalidApprovalTypeRule) Check(runner tflint.Runner) error { + resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{ + Attributes: []hclext.AttributeSchema{{Name: r.attributeName}}, + }, nil) + if err != nil { + return err + } + + for _, resource := range resources.Blocks { + attribute, exists := resource.Body.Attributes[r.attributeName] + if !exists { + continue + } + + err := runner.EvaluateExpr(attribute.Expr, func(val string) error { + validateFunc := validation.StringInSlice([]string{"auto", "manual", ""}, false) + + _, errors := validateFunc(val, r.attributeName) + for _, err := range errors { + if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil { + return err + } + } + return nil + }, nil) + if err != nil { + return err + } + } + + return nil +} diff --git a/rules/magicmodules/google_apigee_api_product_invalid_name.go b/rules/magicmodules/google_apigee_api_product_invalid_name.go new file mode 100644 index 0000000..0c9d8fd --- /dev/null +++ b/rules/magicmodules/google_apigee_api_product_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" +) + +// GoogleApigeeApiProductInvalidNameRule checks the pattern is valid +type GoogleApigeeApiProductInvalidNameRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleApigeeApiProductInvalidNameRule returns new rule with default attributes +func NewGoogleApigeeApiProductInvalidNameRule() *GoogleApigeeApiProductInvalidNameRule { + return &GoogleApigeeApiProductInvalidNameRule{ + resourceType: "google_apigee_api_product", + attributeName: "name", + } +} + +// Name returns the rule name +func (r *GoogleApigeeApiProductInvalidNameRule) Name() string { + return "google_apigee_api_product_invalid_name" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleApigeeApiProductInvalidNameRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleApigeeApiProductInvalidNameRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleApigeeApiProductInvalidNameRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleApigeeApiProductInvalidNameRule) Check(runner tflint.Runner) error { + resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{ + Attributes: []hclext.AttributeSchema{{Name: r.attributeName}}, + }, nil) + if err != nil { + return err + } + + for _, resource := range resources.Blocks { + attribute, exists := resource.Body.Attributes[r.attributeName] + if !exists { + continue + } + + err := runner.EvaluateExpr(attribute.Expr, func(val string) error { + validateFunc := validateRegexp(`^[a-z][a-z0-9._\-$ %]*$`) + + _, errors := validateFunc(val, r.attributeName) + for _, err := range errors { + if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil { + return err + } + } + return nil + }, nil) + if err != nil { + return err + } + } + + return nil +} diff --git a/rules/magicmodules/google_apigee_api_product_invalid_quota_counter_scope.go b/rules/magicmodules/google_apigee_api_product_invalid_quota_counter_scope.go new file mode 100644 index 0000000..2a7ca0b --- /dev/null +++ b/rules/magicmodules/google_apigee_api_product_invalid_quota_counter_scope.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" +) + +// GoogleApigeeApiProductInvalidQuotaCounterScopeRule checks the pattern is valid +type GoogleApigeeApiProductInvalidQuotaCounterScopeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleApigeeApiProductInvalidQuotaCounterScopeRule returns new rule with default attributes +func NewGoogleApigeeApiProductInvalidQuotaCounterScopeRule() *GoogleApigeeApiProductInvalidQuotaCounterScopeRule { + return &GoogleApigeeApiProductInvalidQuotaCounterScopeRule{ + resourceType: "google_apigee_api_product", + attributeName: "quota_counter_scope", + } +} + +// Name returns the rule name +func (r *GoogleApigeeApiProductInvalidQuotaCounterScopeRule) Name() string { + return "google_apigee_api_product_invalid_quota_counter_scope" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleApigeeApiProductInvalidQuotaCounterScopeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleApigeeApiProductInvalidQuotaCounterScopeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleApigeeApiProductInvalidQuotaCounterScopeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleApigeeApiProductInvalidQuotaCounterScopeRule) Check(runner tflint.Runner) error { + resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{ + Attributes: []hclext.AttributeSchema{{Name: r.attributeName}}, + }, nil) + if err != nil { + return err + } + + for _, resource := range resources.Blocks { + attribute, exists := resource.Body.Attributes[r.attributeName] + if !exists { + continue + } + + err := runner.EvaluateExpr(attribute.Expr, func(val string) error { + validateFunc := validation.StringInSlice([]string{"QUOTA_COUNTER_SCOPE_UNSPECIFIED", "PROXY", "OPERATION", ""}, false) + + _, errors := validateFunc(val, r.attributeName) + for _, err := range errors { + if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil { + return err + } + } + return nil + }, nil) + if err != nil { + return err + } + } + + return nil +} diff --git a/rules/magicmodules/google_apigee_security_action_invalid_state.go b/rules/magicmodules/google_apigee_security_action_invalid_state.go new file mode 100644 index 0000000..fee5a45 --- /dev/null +++ b/rules/magicmodules/google_apigee_security_action_invalid_state.go @@ -0,0 +1,91 @@ +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package magicmodules + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/terraform-linters/tflint-plugin-sdk/hclext" + "github.com/terraform-linters/tflint-plugin-sdk/tflint" +) + +// GoogleApigeeSecurityActionInvalidStateRule checks the pattern is valid +type GoogleApigeeSecurityActionInvalidStateRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleApigeeSecurityActionInvalidStateRule returns new rule with default attributes +func NewGoogleApigeeSecurityActionInvalidStateRule() *GoogleApigeeSecurityActionInvalidStateRule { + return &GoogleApigeeSecurityActionInvalidStateRule{ + resourceType: "google_apigee_security_action", + attributeName: "state", + } +} + +// Name returns the rule name +func (r *GoogleApigeeSecurityActionInvalidStateRule) Name() string { + return "google_apigee_security_action_invalid_state" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleApigeeSecurityActionInvalidStateRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleApigeeSecurityActionInvalidStateRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleApigeeSecurityActionInvalidStateRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleApigeeSecurityActionInvalidStateRule) 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{"ENABLED", "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_backup_dr_backup_vault_invalid_backup_retention_inheritance.go b/rules/magicmodules/google_backup_dr_backup_vault_invalid_backup_retention_inheritance.go new file mode 100644 index 0000000..a9045fa --- /dev/null +++ b/rules/magicmodules/google_backup_dr_backup_vault_invalid_backup_retention_inheritance.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" +) + +// GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule checks the pattern is valid +type GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule returns new rule with default attributes +func NewGoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule() *GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule { + return &GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule{ + resourceType: "google_backup_dr_backup_vault", + attributeName: "backup_retention_inheritance", + } +} + +// Name returns the rule name +func (r *GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule) Name() string { + return "google_backup_dr_backup_vault_invalid_backup_retention_inheritance" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule) Check(runner tflint.Runner) error { + resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{ + Attributes: []hclext.AttributeSchema{{Name: r.attributeName}}, + }, nil) + if err != nil { + return err + } + + for _, resource := range resources.Blocks { + attribute, exists := resource.Body.Attributes[r.attributeName] + if !exists { + continue + } + + err := runner.EvaluateExpr(attribute.Expr, func(val string) error { + validateFunc := validation.StringInSlice([]string{"BACKUP_RETENTION_INHERITANCE_UNSPECIFIED", "INHERIT_VAULT_RETENTION", "MATCH_BACKUP_EXPIRE_TIME", ""}, false) + + _, errors := validateFunc(val, r.attributeName) + for _, err := range errors { + if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil { + return err + } + } + return nil + }, nil) + if err != nil { + return err + } + } + + return nil +} diff --git a/rules/magicmodules/google_bigquery_analytics_hub_data_exchange_invalid_discovery_type.go b/rules/magicmodules/google_bigquery_analytics_hub_data_exchange_invalid_discovery_type.go new file mode 100644 index 0000000..bf5db8a --- /dev/null +++ b/rules/magicmodules/google_bigquery_analytics_hub_data_exchange_invalid_discovery_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" +) + +// GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule checks the pattern is valid +type GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule returns new rule with default attributes +func NewGoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule() *GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule { + return &GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule{ + resourceType: "google_bigquery_analytics_hub_data_exchange", + attributeName: "discovery_type", + } +} + +// Name returns the rule name +func (r *GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule) Name() string { + return "google_bigquery_analytics_hub_data_exchange_invalid_discovery_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule) 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{"DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC", ""}, false) + + _, errors := validateFunc(val, r.attributeName) + for _, err := range errors { + if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil { + return err + } + } + return nil + }, nil) + if err != nil { + return err + } + } + + return nil +} diff --git a/rules/magicmodules/google_bigquery_analytics_hub_listing_invalid_discovery_type.go b/rules/magicmodules/google_bigquery_analytics_hub_listing_invalid_discovery_type.go new file mode 100644 index 0000000..02f183a --- /dev/null +++ b/rules/magicmodules/google_bigquery_analytics_hub_listing_invalid_discovery_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" +) + +// GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule checks the pattern is valid +type GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule returns new rule with default attributes +func NewGoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule() *GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule { + return &GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule{ + resourceType: "google_bigquery_analytics_hub_listing", + attributeName: "discovery_type", + } +} + +// Name returns the rule name +func (r *GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule) Name() string { + return "google_bigquery_analytics_hub_listing_invalid_discovery_type" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule) 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{"DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC", ""}, false) + + _, errors := validateFunc(val, r.attributeName) + for _, err := range errors { + if err := runner.EmitIssue(r, err.Error(), attribute.Expr.Range()); err != nil { + return err + } + } + return nil + }, nil) + if err != nil { + return err + } + } + + return nil +} diff --git a/rules/magicmodules/google_compute_backend_bucket_invalid_load_balancing_scheme.go b/rules/magicmodules/google_compute_backend_bucket_invalid_load_balancing_scheme.go new file mode 100644 index 0000000..622a495 --- /dev/null +++ b/rules/magicmodules/google_compute_backend_bucket_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" +) + +// GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule checks the pattern is valid +type GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleComputeBackendBucketInvalidLoadBalancingSchemeRule returns new rule with default attributes +func NewGoogleComputeBackendBucketInvalidLoadBalancingSchemeRule() *GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule { + return &GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule{ + resourceType: "google_compute_backend_bucket", + attributeName: "load_balancing_scheme", + } +} + +// Name returns the rule name +func (r *GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule) Name() string { + return "google_compute_backend_bucket_invalid_load_balancing_scheme" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleComputeBackendBucketInvalidLoadBalancingSchemeRule) 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{"INTERNAL_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/google_discovery_engine_recommendation_engine_invalid_industry_vertical.go b/rules/magicmodules/google_discovery_engine_recommendation_engine_invalid_industry_vertical.go new file mode 100644 index 0000000..73cd2a4 --- /dev/null +++ b/rules/magicmodules/google_discovery_engine_recommendation_engine_invalid_industry_vertical.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" +) + +// GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule checks the pattern is valid +type GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule returns new rule with default attributes +func NewGoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule() *GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule { + return &GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule{ + resourceType: "google_discovery_engine_recommendation_engine", + attributeName: "industry_vertical", + } +} + +// Name returns the rule name +func (r *GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule) Name() string { + return "google_discovery_engine_recommendation_engine_invalid_industry_vertical" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule) 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{"GENERIC", "MEDIA", ""}, 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_looker_instance_invalid_platform_edition.go b/rules/magicmodules/google_looker_instance_invalid_platform_edition.go index 8f83e00..3e78b76 100644 --- a/rules/magicmodules/google_looker_instance_invalid_platform_edition.go +++ b/rules/magicmodules/google_looker_instance_invalid_platform_edition.go @@ -72,7 +72,7 @@ func (r *GoogleLookerInstanceInvalidPlatformEditionRule) Check(runner tflint.Run } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"LOOKER_CORE_TRIAL", "LOOKER_CORE_STANDARD", "LOOKER_CORE_STANDARD_ANNUAL", "LOOKER_CORE_ENTERPRISE_ANNUAL", "LOOKER_CORE_EMBED_ANNUAL", "LOOKER_CORE_NONPROD_STANDARD_ANNUAL", "LOOKER_CORE_NONPROD_ENTERPRISE_ANNUAL", "LOOKER_CORE_NONPROD_EMBED_ANNUAL", ""}, false) + validateFunc := validation.StringInSlice([]string{"LOOKER_CORE_TRIAL", "LOOKER_CORE_STANDARD", "LOOKER_CORE_STANDARD_ANNUAL", "LOOKER_CORE_ENTERPRISE_ANNUAL", "LOOKER_CORE_EMBED_ANNUAL", "LOOKER_CORE_NONPROD_STANDARD_ANNUAL", "LOOKER_CORE_NONPROD_ENTERPRISE_ANNUAL", "LOOKER_CORE_NONPROD_EMBED_ANNUAL", "LOOKER_CORE_TRIAL_STANDARD", "LOOKER_CORE_TRIAL_ENTERPRISE", "LOOKER_CORE_TRIAL_EMBED", ""}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/google_network_security_backend_authentication_config_invalid_well_known_roots.go b/rules/magicmodules/google_network_security_backend_authentication_config_invalid_well_known_roots.go new file mode 100644 index 0000000..fc69478 --- /dev/null +++ b/rules/magicmodules/google_network_security_backend_authentication_config_invalid_well_known_roots.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" +) + +// GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule checks the pattern is valid +type GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule struct { + tflint.DefaultRule + + resourceType string + attributeName string +} + +// NewGoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule returns new rule with default attributes +func NewGoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule() *GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule { + return &GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule{ + resourceType: "google_network_security_backend_authentication_config", + attributeName: "well_known_roots", + } +} + +// Name returns the rule name +func (r *GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule) Name() string { + return "google_network_security_backend_authentication_config_invalid_well_known_roots" +} + +// Enabled returns whether the rule is enabled by default +func (r *GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule) Enabled() bool { + return true +} + +// Severity returns the rule severity +func (r *GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule) Severity() tflint.Severity { + return tflint.ERROR +} + +// Link returns the rule reference link +func (r *GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule) Link() string { + return "" +} + +// Check checks the pattern is valid +func (r *GoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule) 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", "PUBLIC_ROOTS", ""}, 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_vmwareengine_network_peering_invalid_peer_network_type.go b/rules/magicmodules/google_vmwareengine_network_peering_invalid_peer_network_type.go index 109443d..abb56bf 100644 --- a/rules/magicmodules/google_vmwareengine_network_peering_invalid_peer_network_type.go +++ b/rules/magicmodules/google_vmwareengine_network_peering_invalid_peer_network_type.go @@ -72,7 +72,7 @@ func (r *GoogleVmwareengineNetworkPeeringInvalidPeerNetworkTypeRule) Check(runne } err := runner.EvaluateExpr(attribute.Expr, func(val string) error { - validateFunc := validation.StringInSlice([]string{"STANDARD", "VMWARE_ENGINE_NETWORK", "PRIVATE_SERVICES_ACCESS", "NETAPP_CLOUD_VOLUMES", "THIRD_PARTY_SERVICE", "DELL_POWERSCALE"}, false) + validateFunc := validation.StringInSlice([]string{"STANDARD", "VMWARE_ENGINE_NETWORK", "PRIVATE_SERVICES_ACCESS", "NETAPP_CLOUD_VOLUMES", "THIRD_PARTY_SERVICE", "DELL_POWERSCALE", "GOOGLE_CLOUD_NETAPP_VOLUMES"}, false) _, errors := validateFunc(val, r.attributeName) for _, err := range errors { diff --git a/rules/magicmodules/provider.go b/rules/magicmodules/provider.go index 6e36810..ef20cb7 100644 --- a/rules/magicmodules/provider.go +++ b/rules/magicmodules/provider.go @@ -33,23 +33,30 @@ var Rules = []tflint.Rule{ NewGoogleAlloydbInstanceInvalidAvailabilityTypeRule(), NewGoogleAlloydbInstanceInvalidInstanceTypeRule(), NewGoogleAlloydbUserInvalidUserTypeRule(), + NewGoogleApigeeApiProductInvalidApprovalTypeRule(), + NewGoogleApigeeApiProductInvalidNameRule(), + NewGoogleApigeeApiProductInvalidQuotaCounterScopeRule(), NewGoogleApigeeAppGroupInvalidStatusRule(), NewGoogleApigeeEnvironmentInvalidApiProxyTypeRule(), NewGoogleApigeeEnvironmentInvalidDeploymentTypeRule(), NewGoogleApigeeEnvironmentInvalidTypeRule(), NewGoogleApigeeOrganizationInvalidRetentionRule(), NewGoogleApigeeOrganizationInvalidRuntimeTypeRule(), + NewGoogleApigeeSecurityActionInvalidStateRule(), NewGoogleApigeeTargetServerInvalidProtocolRule(), NewGoogleAppEngineDomainMappingInvalidOverrideStrategyRule(), NewGoogleAppEngineFirewallRuleInvalidActionRule(), NewGoogleAppEngineFlexibleAppVersionInvalidServingStatusRule(), NewGoogleArtifactRegistryRepositoryInvalidModeRule(), NewGoogleBackupDrBackupVaultInvalidAccessRestrictionRule(), + NewGoogleBackupDrBackupVaultInvalidBackupRetentionInheritanceRule(), NewGoogleBackupDrManagementServerInvalidTypeRule(), NewGoogleBeyondcorpAppGatewayInvalidHostTypeRule(), NewGoogleBeyondcorpAppGatewayInvalidTypeRule(), NewGoogleBeyondcorpSecurityGatewayInvalidLocationRule(), NewGoogleBiglakeTableInvalidTypeRule(), + NewGoogleBigqueryAnalyticsHubDataExchangeInvalidDiscoveryTypeRule(), + NewGoogleBigqueryAnalyticsHubListingInvalidDiscoveryTypeRule(), NewGoogleBigqueryDatapolicyDataPolicyInvalidDataPolicyTypeRule(), NewGoogleBigqueryRoutineInvalidDataGovernanceTypeRule(), NewGoogleBigqueryRoutineInvalidDeterminismLevelRule(), @@ -78,6 +85,7 @@ var Rules = []tflint.Rule{ NewGoogleComputeAddressInvalidNameRule(), NewGoogleComputeAddressInvalidNetworkTierRule(), NewGoogleComputeBackendBucketInvalidCompressionModeRule(), + NewGoogleComputeBackendBucketInvalidLoadBalancingSchemeRule(), NewGoogleComputeBackendBucketInvalidNameRule(), NewGoogleComputeBackendBucketSignedUrlKeyInvalidNameRule(), NewGoogleComputeBackendServiceInvalidCompressionModeRule(), @@ -186,6 +194,7 @@ var Rules = []tflint.Rule{ NewGoogleDiscoveryEngineChatEngineInvalidIndustryVerticalRule(), NewGoogleDiscoveryEngineDataStoreInvalidContentConfigRule(), NewGoogleDiscoveryEngineDataStoreInvalidIndustryVerticalRule(), + NewGoogleDiscoveryEngineRecommendationEngineInvalidIndustryVerticalRule(), NewGoogleDiscoveryEngineSearchEngineInvalidIndustryVerticalRule(), NewGoogleDiscoveryEngineTargetSiteInvalidTypeRule(), NewGoogleDnsManagedZoneInvalidVisibilityRule(), @@ -244,6 +253,7 @@ var Rules = []tflint.Rule{ NewGoogleNetworkConnectivityRegionalEndpointInvalidAccessTypeRule(), NewGoogleNetworkSecurityAddressGroupInvalidTypeRule(), NewGoogleNetworkSecurityAuthzPolicyInvalidActionRule(), + NewGoogleNetworkSecurityBackendAuthenticationConfigInvalidWellKnownRootsRule(), NewGoogleNetworkSecurityGatewaySecurityPolicyRuleInvalidBasicProfileRule(), NewGoogleNetworkSecuritySecurityProfileInvalidTypeRule(), NewGoogleNetworkSecurityTlsInspectionPolicyInvalidMinTlsVersionRule(), diff --git a/rules/magicmodules/verify/validation.go b/rules/magicmodules/verify/validation.go index 512aa0d..9b9908d 100644 --- a/rules/magicmodules/verify/validation.go +++ b/rules/magicmodules/verify/validation.go @@ -88,16 +88,6 @@ var ( Rfc6996Asn32BitMin = int64(4200000000) Rfc6996Asn32BitMax = int64(4294967294) GcpRouterPartnerAsn = int64(16550) - - // Format of GCS Bucket Name - // https://cloud.google.com/storage/docs/naming-buckets - GCSNameValidChars = "^[a-z0-9_.-]*$" - GCSNameStartEndChars = "^[a-z|0-9].*[a-z|0-9]$" - GCSNameLength = "^.{3,222}" - GCSNameLengthSplit = "^.{1,63}$" - GCSNameCidr = "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$" - GCSNameGoogPrefix = "^goog.*$" - GCSNameContainsGoogle = "^.*google.*$" ) var Rfc1918Networks = []string{ @@ -113,44 +103,6 @@ func ValidateGCEName(v interface{}, k string) (ws []string, errors []error) { return ValidateRegexp(re)(v, k) } -// validateGCSName ensures the name of a gcs bucket matches the requirements for GCS Buckets -// https://cloud.google.com/storage/docs/naming-buckets -func ValidateGCSName(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - - if !regexp.MustCompile(GCSNameValidChars).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value can only contain lowercase letters, numeric characters, dashes (-), underscores (_), and dots (.)", value)) - } - - if !regexp.MustCompile(GCSNameStartEndChars).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value must start and end with a number or letter", value)) - } - - if !regexp.MustCompile(GCSNameLength).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value must contain 3-63 characters. Names containing dots can contain up to 222 characters, but each dot-separated component can be no longer than 63 characters", value)) - } - - for _, str := range strings.Split(value, ".") { - if !regexp.MustCompile(GCSNameLengthSplit).MatchString(str) { - errors = append(errors, fmt.Errorf("%q name value must contain 3-63 characters. Names containing dots can contain up to 222 characters, but each dot-separated component can be no longer than 63 characters", value)) - } - } - - if regexp.MustCompile(GCSNameCidr).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value cannot be represented as an IP address in dotted-decimal notation (for example, 192.168.5.4)", value)) - } - - if regexp.MustCompile(GCSNameGoogPrefix).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value cannot begin with the \"goog\" prefix", value)) - } - - if regexp.MustCompile(GCSNameContainsGoogle).MatchString(strings.ReplaceAll(value, "0", "o")) { - errors = append(errors, fmt.Errorf("%q name value cannot contain \"google\" or close misspellings, such as \"g00gle\"", value)) - } - - return -} - // Ensure that the BGP ASN value of Cloud Router is a valid value as per RFC6996 or a value of 16550 func ValidateRFC6996Asn(v interface{}, k string) (ws []string, errors []error) { value := int64(v.(int)) diff --git a/tools/magic-modules b/tools/magic-modules index 69b6d56..6237444 160000 --- a/tools/magic-modules +++ b/tools/magic-modules @@ -1 +1 @@ -Subproject commit 69b6d5621627c0770b94dfd2d7ba9cc7c5ec8d4d +Subproject commit 62374448239144522cafb523c504026584265f09