Skip to content

Commit

Permalink
refactor: add enums values to kafka topic config fields
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Nov 12, 2024
1 parent 7080505 commit 1691b34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions docs/resources/kafka_topic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
29 changes: 17 additions & 12 deletions internal/sdkprovider/service/kafkatopic/kafka_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -79,19 +82,21 @@ 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,
Description: "message.timestamp.difference.max.ms value",
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,
Expand Down

0 comments on commit 1691b34

Please sign in to comment.