diff --git a/docs/data-sources/mirrormaker_replication_flow.md b/docs/data-sources/mirrormaker_replication_flow.md index 9f1df74f1..13efd4408 100644 --- a/docs/data-sources/mirrormaker_replication_flow.md +++ b/docs/data-sources/mirrormaker_replication_flow.md @@ -38,7 +38,7 @@ data "aiven_mirrormaker_replication_flow" "f1" { - `emit_heartbeats_enabled` (Boolean) Whether to emit heartbeats to the target cluster. The default value is `false`. - `enable` (Boolean) Enable of disable replication flows for a service. - `id` (String) The ID of this resource. -- `offset_syncs_topic_location` (String) Offset syncs topic location. Possible values are `source` & `target`. There is no default value. +- `offset_syncs_topic_location` (String) Offset syncs topic location. The possible values are `source` and `target`. - `replication_factor` (Number) Replication factor, `>= 1`. - `replication_policy_class` (String) Replication policy class. The possible values are `org.apache.kafka.connect.mirror.DefaultReplicationPolicy` and `org.apache.kafka.connect.mirror.IdentityReplicationPolicy`. The default value is `org.apache.kafka.connect.mirror.DefaultReplicationPolicy`. - `sync_group_offsets_enabled` (Boolean) Sync consumer group offsets. The default value is `false`. diff --git a/docs/data-sources/service_component.md b/docs/data-sources/service_component.md index 90502a298..03bcb9c67 100644 --- a/docs/data-sources/service_component.md +++ b/docs/data-sources/service_component.md @@ -29,11 +29,11 @@ data "aiven_service_component" "sc1" { ### Optional -- `kafka_authentication_method` (String) Kafka authentication method. This is a value specific to the 'kafka' service component -- `route` (String) Network access route +- `kafka_authentication_method` (String) Kafka authentication method. This is a value specific to the 'kafka' service component. The possible values are `certificate` and `sasl`. +- `route` (String) Network access route. The possible values are `dynamic`, `public`, `private` and `privatelink`. - `service_name` (String) Service name - `ssl` (Boolean) Whether the endpoint is encrypted or accepts plaintext. By default endpoints are always encrypted and this property is only included for service components that may disable encryption -- `usage` (String) DNS usage name +- `usage` (String) DNS usage name. The possible values are `disaster_recovery`, `primary` and `replica`. ### Read-Only diff --git a/docs/resources/kafka_topic.md b/docs/resources/kafka_topic.md index 0893f5aeb..e2cb053cd 100644 --- a/docs/resources/kafka_topic.md +++ b/docs/resources/kafka_topic.md @@ -64,8 +64,8 @@ resource "aiven_kafka_topic" "example_topic" { Optional: -- `cleanup_policy` (String) cleanup.policy value -- `compression_type` (String) compression.type value +- `cleanup_policy` (String) cleanup.policy value. The possible values are `delete`, `compact` and `compact,delete`. +- `compression_type` (String) compression.type value. The possible values are `snappy`, `gzip`, `lz4`, `producer`, `uncompressed` and `zstd`. - `delete_retention_ms` (String) delete.retention.ms value - `file_delete_delay_ms` (String) file.delete.delay.ms value - `flush_messages` (String) flush.messages value @@ -76,9 +76,9 @@ Optional: - `max_compaction_lag_ms` (String) max.compaction.lag.ms value - `max_message_bytes` (String) max.message.bytes value - `message_downconversion_enable` (Boolean) message.downconversion.enable value -- `message_format_version` (String) message.format.version value +- `message_format_version` (String) message.format.version value. The possible values are `0.8.0`, `0.8.1`, `0.8.2`, `0.9.0`, `0.10.0`, `0.10.0-IV0`, `0.10.0-IV1`, `0.10.1`, `0.10.1-IV0`, `0.10.1-IV1`, `0.10.1-IV2`, `0.10.2`, `0.10.2-IV0`, `0.11.0`, `0.11.0-IV0`, `0.11.0-IV1`, `0.11.0-IV2`, `1.0`, `1.0-IV0`, `1.1`, `1.1-IV0`, `2.0`, `2.0-IV0`, `2.0-IV1`, `2.1`, `2.1-IV0`, `2.1-IV1`, `2.1-IV2`, `2.2`, `2.2-IV0`, `2.2-IV1`, `2.3`, `2.3-IV0`, `2.3-IV1`, `2.4`, `2.4-IV0`, `2.4-IV1`, `2.5`, `2.5-IV0`, `2.6`, `2.6-IV0`, `2.7`, `2.7-IV0`, `2.7-IV1`, `2.7-IV2`, `2.8`, `2.8-IV0`, `2.8-IV1`, `3.0`, `3.0-IV0`, `3.0-IV1`, `3.1`, `3.1-IV0`, `3.2`, `3.2-IV0`, `3.3`, `3.3-IV0`, `3.3-IV1`, `3.3-IV2`, `3.3-IV3`, `3.4`, `3.4-IV0`, `3.5`, `3.5-IV0`, `3.5-IV1`, `3.5-IV2`, `3.6`, `3.6-IV0`, `3.6-IV1`, `3.6-IV2`, `3.7`, `3.7-IV0`, `3.7-IV1`, `3.7-IV2`, `3.7-IV3`, `3.7-IV4`, `3.8`, `3.8-IV0`, `3.9`, `3.9-IV0` and `3.9-IV1`. - `message_timestamp_difference_max_ms` (String) message.timestamp.difference.max.ms value -- `message_timestamp_type` (String) message.timestamp.type value +- `message_timestamp_type` (String) message.timestamp.type value. The possible values are `CreateTime` and `LogAppendTime`. - `min_cleanable_dirty_ratio` (Number) min.cleanable.dirty.ratio value - `min_compaction_lag_ms` (String) min.compaction.lag.ms value - `min_insync_replicas` (String) min.insync.replicas value diff --git a/docs/resources/mirrormaker_replication_flow.md b/docs/resources/mirrormaker_replication_flow.md index a302e1ca9..71bf00fa5 100644 --- a/docs/resources/mirrormaker_replication_flow.md +++ b/docs/resources/mirrormaker_replication_flow.md @@ -47,7 +47,7 @@ resource "aiven_mirrormaker_replication_flow" "f1" { ### Required - `enable` (Boolean) Enable of disable replication flows for a service. -- `offset_syncs_topic_location` (String) Offset syncs topic location. Possible values are `source` & `target`. There is no default value. +- `offset_syncs_topic_location` (String) Offset syncs topic location. The possible values are `source` and `target`. - `project` (String) The name of the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource. - `replication_policy_class` (String) Replication policy class. The possible values are `org.apache.kafka.connect.mirror.DefaultReplicationPolicy` and `org.apache.kafka.connect.mirror.IdentityReplicationPolicy`. The default value is `org.apache.kafka.connect.mirror.DefaultReplicationPolicy`. - `service_name` (String) The name of the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource. diff --git a/internal/sdkprovider/service/account/account_authentication.go b/internal/sdkprovider/service/account/account_authentication.go index 50c45d5bb..667c75e25 100644 --- a/internal/sdkprovider/service/account/account_authentication.go +++ b/internal/sdkprovider/service/account/account_authentication.go @@ -29,7 +29,7 @@ var aivenAccountAuthenticationSchema = map[string]*schema.Schema{ "type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"internal", "saml"}, false), + ValidateFunc: validation.StringInSlice(accountauthentication.AuthenticationMethodTypeChoices(), false), Description: userconfig.Desc("The account authentication type.").PossibleValuesString(accountauthentication.AuthenticationMethodTypeChoices()...).Build(), }, "enabled": { diff --git a/internal/sdkprovider/service/account/account_team_project.go b/internal/sdkprovider/service/account/account_team_project.go index 425f9d073..2f7341f82 100644 --- a/internal/sdkprovider/service/account/account_team_project.go +++ b/internal/sdkprovider/service/account/account_team_project.go @@ -33,7 +33,7 @@ var aivenAccountTeamProjectSchema = map[string]*schema.Schema{ "team_type": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{"admin", "developer", "operator", "read_only"}, false), + ValidateFunc: validation.StringInSlice(account.TeamTypeChoices(), false), Description: userconfig.Desc("The Account team project type").PossibleValuesString(account.TeamTypeChoices()...).Build(), }, } diff --git a/internal/sdkprovider/service/connectionpool/connection_pool.go b/internal/sdkprovider/service/connectionpool/connection_pool.go index 8666a22af..95afa5987 100644 --- a/internal/sdkprovider/service/connectionpool/connection_pool.go +++ b/internal/sdkprovider/service/connectionpool/connection_pool.go @@ -27,9 +27,9 @@ var aivenConnectionPoolSchema = map[string]*schema.Schema{ "pool_mode": { Type: schema.TypeString, Optional: true, - Default: "transaction", - ValidateFunc: validation.StringInSlice([]string{"session", "transaction", "statement"}, false), - Description: userconfig.Desc("The [operational mode](https://aiven.io/docs/products/postgresql/concepts/pg-connection-pooling#pooling-modes).").DefaultValue("transaction").PossibleValuesString(service.PoolModeTypeChoices()...).Build(), + Default: service.PoolModeTypeTransaction, + ValidateFunc: validation.StringInSlice(service.PoolModeTypeChoices(), false), + Description: userconfig.Desc("The [operational mode](https://aiven.io/docs/products/postgresql/concepts/pg-connection-pooling#pooling-modes).").DefaultValue(service.PoolModeTypeTransaction).PossibleValuesString(service.PoolModeTypeChoices()...).Build(), }, "pool_name": { Type: schema.TypeString, diff --git a/internal/sdkprovider/service/kafka/kafka_acl.go b/internal/sdkprovider/service/kafka/kafka_acl.go index 70c318760..7851678bd 100644 --- a/internal/sdkprovider/service/kafka/kafka_acl.go +++ b/internal/sdkprovider/service/kafka/kafka_acl.go @@ -21,7 +21,7 @@ var aivenKafkaACLSchema = map[string]*schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{"admin", "read", "readwrite", "write"}, false), + ValidateFunc: validation.StringInSlice(kafka.PermissionTypeChoices(), false), Description: userconfig.Desc("Permissions to grant.").ForceNew().PossibleValuesString(kafka.PermissionTypeChoices()...).Build(), }, "topic": { diff --git a/internal/sdkprovider/service/kafka/mirrormaker_replication_flow.go b/internal/sdkprovider/service/kafka/mirrormaker_replication_flow.go index 55110096b..cb85f66c9 100644 --- a/internal/sdkprovider/service/kafka/mirrormaker_replication_flow.go +++ b/internal/sdkprovider/service/kafka/mirrormaker_replication_flow.go @@ -104,8 +104,8 @@ var aivenMirrorMakerReplicationFlowSchema = map[string]*schema.Schema{ "offset_syncs_topic_location": { Type: schema.TypeString, Required: true, - Description: "Offset syncs topic location. Possible values are `source` & `target`. There is no default value.", - ValidateFunc: validation.StringInSlice([]string{"source", "target"}, false), + ValidateFunc: validation.StringInSlice(kafkamirrormaker.OffsetSyncsTopicLocationTypeChoices(), false), + Description: userconfig.Desc("Offset syncs topic location").PossibleValuesString(kafkamirrormaker.OffsetSyncsTopicLocationTypeChoices()...).Build(), }, "config_properties_exclude": { Type: schema.TypeSet, diff --git a/internal/sdkprovider/service/kafkaschema/kafka_schema_registry_acl.go b/internal/sdkprovider/service/kafkaschema/kafka_schema_registry_acl.go index d4c83d9aa..442b65c85 100644 --- a/internal/sdkprovider/service/kafkaschema/kafka_schema_registry_acl.go +++ b/internal/sdkprovider/service/kafkaschema/kafka_schema_registry_acl.go @@ -21,7 +21,7 @@ var aivenKafkaSchemaRegistryACLSchema = map[string]*schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{"schema_registry_read", "schema_registry_write"}, false), + ValidateFunc: validation.StringInSlice(kafkaschemaregistry.PermissionTypeChoices(), false), Description: userconfig.Desc("Kafka Schema Registry permission to grant.").ForceNew().PossibleValuesString(kafkaschemaregistry.PermissionTypeChoices()...).Build(), }, "resource": { diff --git a/internal/sdkprovider/service/kafkatopic/kafka_topic.go b/internal/sdkprovider/service/kafkatopic/kafka_topic.go index dded3022e..4de7b0400 100644 --- a/internal/sdkprovider/service/kafkatopic/kafka_topic.go +++ b/internal/sdkprovider/service/kafkatopic/kafka_topic.go @@ -9,6 +9,7 @@ import ( "strconv" "github.com/aiven/aiven-go-client/v2" + "github.com/aiven/go-client-codegen/handler/kafkatopic" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -29,14 +30,16 @@ var ( var aivenKafkaTopicConfigSchema = map[string]*schema.Schema{ "cleanup_policy": { - Type: schema.TypeString, - Description: "cleanup.policy value", - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(kafkatopic.CleanupPolicyTypeChoices(), false), + Description: userconfig.Desc("cleanup.policy value").PossibleValuesString(kafkatopic.CleanupPolicyTypeChoices()...).Build(), }, "compression_type": { - Type: schema.TypeString, - Description: "compression.type value", - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(kafkatopic.CompressionTypeChoices(), false), + Description: userconfig.Desc("compression.type value").PossibleValuesString(kafkatopic.CompressionTypeChoices()...).Build(), }, "delete_retention_ms": { Type: schema.TypeString, @@ -79,9 +82,10 @@ var aivenKafkaTopicConfigSchema = map[string]*schema.Schema{ Optional: true, }, "message_format_version": { - Type: schema.TypeString, - Description: "message.format.version value", - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(kafkatopic.MessageFormatVersionTypeChoices(), false), + Description: userconfig.Desc("message.format.version value").PossibleValuesString(kafkatopic.MessageFormatVersionTypeChoices()...).Build(), }, "message_timestamp_difference_max_ms": { Type: schema.TypeString, @@ -89,9 +93,10 @@ var aivenKafkaTopicConfigSchema = map[string]*schema.Schema{ Optional: true, }, "message_timestamp_type": { - Type: schema.TypeString, - Description: "message.timestamp.type value", - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(kafkatopic.MessageTimestampTypeChoices(), false), + Description: userconfig.Desc("message.timestamp.type value").PossibleValuesString(kafkatopic.MessageTimestampTypeChoices()...).Build(), }, "min_cleanable_dirty_ratio": { Type: schema.TypeFloat, diff --git a/internal/sdkprovider/service/mysql/mysql_user.go b/internal/sdkprovider/service/mysql/mysql_user.go index 083b33f2b..347e97775 100644 --- a/internal/sdkprovider/service/mysql/mysql_user.go +++ b/internal/sdkprovider/service/mysql/mysql_user.go @@ -36,7 +36,7 @@ var aivenMySQLUserSchema = map[string]*schema.Schema{ Type: schema.TypeString, Optional: true, DiffSuppressFunc: schemautil.EmptyObjectDiffSuppressFunc, - ValidateFunc: validation.StringInSlice([]string{"caching_sha2_password", "mysql_native_password"}, false), + ValidateFunc: validation.StringInSlice(service.AuthenticationTypeChoices(), false), Description: userconfig.Desc("Authentication details.").PossibleValuesString(service.AuthenticationTypeChoices()...).Build(), }, diff --git a/internal/sdkprovider/service/opensearch/opensearch_acl_rule.go b/internal/sdkprovider/service/opensearch/opensearch_acl_rule.go index 9ec5e761f..36cdce3e8 100644 --- a/internal/sdkprovider/service/opensearch/opensearch_acl_rule.go +++ b/internal/sdkprovider/service/opensearch/opensearch_acl_rule.go @@ -33,7 +33,7 @@ var aivenOpenSearchACLRuleSchema = map[string]*schema.Schema{ "permission": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"deny", "admin", "read", "readwrite", "write"}, false), + ValidateFunc: validation.StringInSlice(opensearch.PermissionTypeChoices(), false), Description: userconfig.Desc("The permissions for this ACL entry").PossibleValuesString(opensearch.PermissionTypeChoices()...).Build(), }, } diff --git a/internal/sdkprovider/service/organization/organization_permission.go b/internal/sdkprovider/service/organization/organization_permission.go index f36c86148..5e87bb56f 100644 --- a/internal/sdkprovider/service/organization/organization_permission.go +++ b/internal/sdkprovider/service/organization/organization_permission.go @@ -7,6 +7,7 @@ import ( "github.com/aiven/go-client-codegen/handler/account" "github.com/aiven/go-client-codegen/handler/organization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/aiven/terraform-provider-aiven/internal/common" "github.com/aiven/terraform-provider-aiven/internal/schemautil" @@ -20,9 +21,10 @@ var aivenOrganizationalPermissionSchema = map[string]*schema.Schema{ Required: true, }, "resource_type": { - Type: schema.TypeString, - Required: true, - Description: userconfig.Desc("Resource type.").PossibleValuesString("project").Build(), + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(organization.ResourceTypeChoices(), false), + Description: userconfig.Desc("Resource type.").PossibleValuesString(organization.ResourceTypeChoices()...).Build(), }, "resource_id": { Type: schema.TypeString, diff --git a/internal/sdkprovider/service/servicecomponent/service_component_data_source.go b/internal/sdkprovider/service/servicecomponent/service_component_data_source.go index 32f702bae..1d9ca3dc7 100644 --- a/internal/sdkprovider/service/servicecomponent/service_component_data_source.go +++ b/internal/sdkprovider/service/servicecomponent/service_component_data_source.go @@ -5,11 +5,13 @@ import ( "strconv" "github.com/aiven/aiven-go-client/v2" + "github.com/aiven/go-client-codegen/handler/service" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/aiven/terraform-provider-aiven/internal/schemautil" + "github.com/aiven/terraform-provider-aiven/internal/schemautil/userconfig" ) func DatasourceServiceComponent() *schema.Resource { @@ -31,7 +33,7 @@ func DatasourceServiceComponent() *schema.Resource { Type: schema.TypeString, Required: true, Description: "Service component name", - ValidateFunc: validation.StringInSlice([]string{ + ValidateFunc: validation.StringInSlice([]string{ // fixme: choices are missing from the schema "cassandra", "elasticsearch", "grafana", @@ -52,24 +54,16 @@ func DatasourceServiceComponent() *schema.Resource { }, false), }, "route": { - Type: schema.TypeString, - Optional: true, - Description: "Network access route", - ValidateFunc: validation.StringInSlice([]string{ - "dynamic", - "public", - "private", - "privatelink", - }, false), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(service.RouteTypeChoices(), false), + Description: userconfig.Desc("Network access route").PossibleValuesString(service.RouteTypeChoices()...).Build(), }, "kafka_authentication_method": { - Type: schema.TypeString, - Optional: true, - Description: "Kafka authentication method. This is a value specific to the 'kafka' service component", - ValidateFunc: validation.StringInSlice([]string{ - "certificate", - "sasl", - }, false), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(service.KafkaAuthenticationMethodTypeChoices(), false), + Description: userconfig.Desc("Kafka authentication method. This is a value specific to the 'kafka' service component").PossibleValuesString(service.KafkaAuthenticationMethodTypeChoices()...).Build(), }, "ssl": { Type: schema.TypeBool, @@ -79,15 +73,11 @@ func DatasourceServiceComponent() *schema.Resource { "disable encryption", }, "usage": { - Type: schema.TypeString, - Optional: true, - Description: "DNS usage name", - Default: "primary", - ValidateFunc: validation.StringInSlice([]string{ - "primary", - "replica", - "syncing", - }, false), + Type: schema.TypeString, + Optional: true, + Default: "primary", + ValidateFunc: validation.StringInSlice(service.UsageTypeChoices(), false), + Description: userconfig.Desc("DNS usage name").PossibleValuesString(service.UsageTypeChoices()...).Build(), }, "host": { Type: schema.TypeString,