Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ var flagRules = []linter.FlagRule{
"include-parent-scopes",
"max-partition-memory-bytes",
"message-send-max-retries",
"metadata-column-naming-scheme",
"private-link-access-point",
"record-failure-strategy",
"remote-api-key",
Expand Down Expand Up @@ -142,6 +143,7 @@ var flagRules = []linter.FlagRule{
"confluent-platform-kafka-cluster",
"max-partition-memory-bytes",
"message-send-max-retries",
"metadata-column-naming-scheme",
"private-link-access-point",
"require-crl-on-client-certificate",
"schema-registry-api-key",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require (
github.com/confluentinc/ccloud-sdk-go-v2/service-quota v0.2.0
github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.7.3
github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1
github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.6.0
github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.7.0
github.com/confluentinc/ccloud-sdk-go-v2/usm v0.1.0
github.com/confluentinc/cmf-sdk-go v0.0.8
github.com/confluentinc/confluent-kafka-go/v2 v2.14.2
Expand Down Expand Up @@ -117,7 +117,7 @@ require (
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.54.0
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f
golang.org/x/oauth2 v0.35.0
golang.org/x/oauth2 v0.36.0
golang.org/x/term v0.45.0
golang.org/x/text v0.40.0
google.golang.org/grpc v1.80.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.7.3 h1:ozdDSJHruQIgtxS5hwz8Rp8p
github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.7.3/go.mod h1:cD0AeCMBAWBesmWxWCMgVYNABYgHJ/ahCj7b4HP2R2I=
github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1 h1:WZJYfgXJrvTIYQpCFps/qHF7T8ekgPlX/SFqx4EY2zQ=
github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1/go.mod h1:kB+MXWYYg9ohrTCb27LlfpTbuexAzyYAmum105ow0ho=
github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.6.0 h1:wrmpI4UJgWZ4rX1EYqUxUQrfsKMRDehQsIWjcMU/bzs=
github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.6.0/go.mod h1:myRmhUEWzpwGqWvdsNk79QH41pkre1G21vmySyGQiWA=
github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.7.0 h1:yf/1TiSCiAT0cD1dBZB6SU+hUAAL+uCezLx5MM9aHCA=
github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.7.0/go.mod h1:A0gPt6EjmzCV+CftXu2TeefIOiha2OTbATVOPp0ccx0=
github.com/confluentinc/ccloud-sdk-go-v2/usm v0.1.0 h1:rF9cKecDCowq+oDWjf8rSpXXZHAnVXowIsT/OXF4MOI=
github.com/confluentinc/ccloud-sdk-go-v2/usm v0.1.0/go.mod h1:umhEDvQp/5h0ALKBpYTQOmFwaWrvilnbE8Rkzh6oJ4Q=
github.com/confluentinc/cmf-sdk-go v0.0.8 h1:ziiV4/lNKh49m7RxwPCDL04OFV54lA3SkeynsQ2SDC8=
Expand Down Expand Up @@ -847,8 +847,8 @@ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ=
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
84 changes: 43 additions & 41 deletions internal/tableflow/command_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,31 @@ const (
)

type topicOut struct {
KafkaCluster string `human:"Kafka Cluster" serialized:"kafka_cluster"`
TopicName string `human:"Topic Name" serialized:"topic_name"`
EnableCompaction bool `human:"Enable Compaction" serialized:"enable_compaction"`
EnablePartitioning bool `human:"Enable Partitioning" serialized:"enable_partitioning"`
Environment string `human:"Environment" serialized:"environment"`
RecordFailureStrategy string `human:"Record Failure Strategy" serialized:"record_failure_strategy"`
ErrorHandling string `human:"Error Handling,omitempty" serialized:"error_handling,omitempty"`
LogTarget string `human:"Log Target,omitempty" serialized:"log_target,omitempty"`
RetentionMs string `human:"Retention Ms" serialized:"retention_ms"`
StorageType string `human:"Storage Type" serialized:"storage_type"`
ProviderIntegrationId string `human:"Provider Integration ID,omitempty" serialized:"provider_integration_id,omitempty"`
BucketName string `human:"Bucket Name,omitempty" serialized:"bucket_name,omitempty"`
BucketRegion string `human:"Bucket Region,omitempty" serialized:"bucket_region,omitempty"`
ContainerName string `human:"Container Name,omitempty" serialized:"container_name,omitempty"`
StorageAccountName string `human:"Storage Account Name,omitempty" serialized:"storage_account_name,omitempty"`
StorageRegion string `human:"Storage Region,omitempty" serialized:"storage_region ,omitempty"`
Suspended bool `human:"Suspended" serialized:"suspended"`
TableFormats string `human:"Table Formats" serialized:"table_formats"`
TablePath string `human:"Table Path" serialized:"table_path"`
Phase string `human:"Phase" serialized:"phase"`
CatalogSyncStatus map[string]string `human:"Catalog Sync Status,omitempty" serialized:"catalog_sync_status,omitempty"`
FailingTableFormat map[string]string `human:"Failing Table Format,omitempty" serialized:"failing_table_format,omitempty"`
ErrorMessage string `human:"Error Message,omitempty" serialized:"error_message,omitempty"`
WriteMode string `human:"Write Mode,omitempty" serialized:"write_mode,omitempty"`
KafkaCluster string `human:"Kafka Cluster" serialized:"kafka_cluster"`
TopicName string `human:"Topic Name" serialized:"topic_name"`
EnableCompaction bool `human:"Enable Compaction" serialized:"enable_compaction"`
EnablePartitioning bool `human:"Enable Partitioning" serialized:"enable_partitioning"`
Environment string `human:"Environment" serialized:"environment"`
RecordFailureStrategy string `human:"Record Failure Strategy" serialized:"record_failure_strategy"`
MetadataColumnNamingScheme string `human:"Metadata Column Naming Scheme,omitempty" serialized:"metadata_column_naming_scheme,omitempty"`
ErrorHandling string `human:"Error Handling,omitempty" serialized:"error_handling,omitempty"`
LogTarget string `human:"Log Target,omitempty" serialized:"log_target,omitempty"`
RetentionMs string `human:"Retention Ms" serialized:"retention_ms"`
StorageType string `human:"Storage Type" serialized:"storage_type"`
ProviderIntegrationId string `human:"Provider Integration ID,omitempty" serialized:"provider_integration_id,omitempty"`
BucketName string `human:"Bucket Name,omitempty" serialized:"bucket_name,omitempty"`
BucketRegion string `human:"Bucket Region,omitempty" serialized:"bucket_region,omitempty"`
ContainerName string `human:"Container Name,omitempty" serialized:"container_name,omitempty"`
StorageAccountName string `human:"Storage Account Name,omitempty" serialized:"storage_account_name,omitempty"`
StorageRegion string `human:"Storage Region,omitempty" serialized:"storage_region ,omitempty"`
Suspended bool `human:"Suspended" serialized:"suspended"`
TableFormats string `human:"Table Formats" serialized:"table_formats"`
TablePath string `human:"Table Path" serialized:"table_path"`
Phase string `human:"Phase" serialized:"phase"`
CatalogSyncStatus map[string]string `human:"Catalog Sync Status,omitempty" serialized:"catalog_sync_status,omitempty"`
FailingTableFormat map[string]string `human:"Failing Table Format,omitempty" serialized:"failing_table_format,omitempty"`
ErrorMessage string `human:"Error Message,omitempty" serialized:"error_message,omitempty"`
WriteMode string `human:"Write Mode,omitempty" serialized:"write_mode,omitempty"`
}

func (c *command) newTopicCommand() *cobra.Command {
Expand Down Expand Up @@ -203,23 +204,24 @@ func printTopicTable(cmd *cobra.Command, topic tableflowv1.TableflowV1TableflowT
strFormats := getFailingTableFormats(topic.Status.GetFailingTableFormats())

out := &topicOut{
KafkaCluster: topic.GetSpec().KafkaCluster.GetId(),
TopicName: topic.Spec.GetDisplayName(),
EnableCompaction: topic.GetSpec().Config.GetEnableCompaction(), // should be read-only & true
EnablePartitioning: topic.GetSpec().Config.GetEnablePartitioning(), // should be read-only & true
TableFormats: strings.Join(topic.Spec.GetTableFormats(), ", "),
Environment: topic.GetSpec().Environment.GetId(),
RetentionMs: topic.GetSpec().Config.GetRetentionMs(),
RecordFailureStrategy: topic.GetSpec().Config.GetRecordFailureStrategy(),
ErrorHandling: getErrorHandlingMode(topic),
LogTarget: topic.GetSpec().Config.GetErrorHandling().TableflowV1ErrorHandlingLog.GetTarget(), // this Get function will return empty string if the ErrorHandling is not LOG
StorageType: storageType,
Suspended: topic.Spec.GetSuspended(),
Phase: topic.Status.GetPhase(),
CatalogSyncStatus: strStatus,
FailingTableFormat: strFormats,
ErrorMessage: topic.Status.GetErrorMessage(),
WriteMode: topic.Status.GetWriteMode(),
KafkaCluster: topic.GetSpec().KafkaCluster.GetId(),
TopicName: topic.Spec.GetDisplayName(),
EnableCompaction: topic.GetSpec().Config.GetEnableCompaction(), // should be read-only & true
EnablePartitioning: topic.GetSpec().Config.GetEnablePartitioning(), // should be read-only & true
TableFormats: strings.Join(topic.Spec.GetTableFormats(), ", "),
Environment: topic.GetSpec().Environment.GetId(),
RetentionMs: topic.GetSpec().Config.GetRetentionMs(),
RecordFailureStrategy: topic.GetSpec().Config.GetRecordFailureStrategy(),
MetadataColumnNamingScheme: topic.GetSpec().Config.GetMetadataColumnNamingScheme(),
ErrorHandling: getErrorHandlingMode(topic),
LogTarget: topic.GetSpec().Config.GetErrorHandling().TableflowV1ErrorHandlingLog.GetTarget(), // this Get function will return empty string if the ErrorHandling is not LOG
StorageType: storageType,
Suspended: topic.Spec.GetSuspended(),
Phase: topic.Status.GetPhase(),
CatalogSyncStatus: strStatus,
FailingTableFormat: strFormats,
ErrorMessage: topic.Status.GetErrorMessage(),
WriteMode: topic.Status.GetWriteMode(),
}

if storageType == byos {
Expand Down
10 changes: 10 additions & 0 deletions internal/tableflow/command_topic_enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
cmd.Flags().String("provider-integration", "", "Specify the provider integration id.")
cmd.Flags().String("bucket-name", "", "Specify the name of the AWS S3 bucket.")
cmd.Flags().String("table-formats", "ICEBERG", "Specify the table formats, one of DELTA or ICEBERG.")
cmd.Flags().String("metadata-column-naming-scheme", "", "Specify the naming scheme for Tableflow's internal metadata columns in the materialized table, one of DEFAULT or PORTABLE.")

Check failure on line 42 in internal/tableflow/command_topic_enable.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "metadata-column-naming-scheme" 3 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3410&issues=448ce017-3a22-473e-bea3-27cfa090372d&open=448ce017-3a22-473e-bea3-27cfa090372d
cmd.Flags().String("storage-account-name", "", "Specify the storage account name for Azure Data Lake.")
cmd.Flags().String("container-name", "", "Specify the container name for Azure Data Lake.")
addErrorHandlingFlags(cmd)
Expand All @@ -53,7 +54,7 @@
return cmd
}

func (c *command) enable(cmd *cobra.Command, args []string) error {

Check failure on line 57 in internal/tableflow/command_topic_enable.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Refactor this method to reduce its Cognitive Complexity from 34 to the 15 allowed.

[S3776] Cognitive Complexity of functions should not be too high See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3410&issues=4a914ece-cb02-4efe-8704-6ac6cf5f8e78&open=4a914ece-cb02-4efe-8704-6ac6cf5f8e78
name := args[0]

environmentId, err := c.Context.EnvironmentId()
Expand All @@ -76,6 +77,11 @@
return err
}

metadataColumnNamingScheme, err := cmd.Flags().GetString("metadata-column-naming-scheme")
if err != nil {
return err
}

errorHandling, err := cmd.Flags().GetString("error-handling")
if err != nil {
return err
Expand Down Expand Up @@ -135,6 +141,10 @@
createTopic.Spec.Config.SetRecordFailureStrategy(recordFailureStrategy)
}

if cmd.Flags().Changed("metadata-column-naming-scheme") {
createTopic.Spec.Config.SetMetadataColumnNamingScheme(strings.ToUpper(metadataColumnNamingScheme))
}

if cmd.Flags().Changed("error-handling") {
if strings.ToUpper(errorHandling) == suspend {
createTopic.Spec.Config.ErrorHandling = &tableflowv1.TableflowV1TableFlowTopicConfigsSpecErrorHandlingOneOf{
Expand Down
35 changes: 18 additions & 17 deletions internal/tableflow/command_topic_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,24 @@ func (c *command) list(cmd *cobra.Command, _ []string) error {
strFormats := getFailingTableFormats(topic.Status.GetFailingTableFormats())

out := &topicOut{
KafkaCluster: topic.GetSpec().KafkaCluster.GetId(),
TopicName: topic.Spec.GetDisplayName(),
EnableCompaction: topic.GetSpec().Config.GetEnableCompaction(), // should be read-only & true
EnablePartitioning: topic.GetSpec().Config.GetEnablePartitioning(), // should be read-only & true
TableFormats: strings.Join(topic.Spec.GetTableFormats(), ", "),
Environment: topic.GetSpec().Environment.GetId(),
RetentionMs: topic.GetSpec().Config.GetRetentionMs(),
RecordFailureStrategy: topic.GetSpec().Config.GetRecordFailureStrategy(),
ErrorHandling: getErrorHandlingMode(topic),
LogTarget: topic.GetSpec().Config.GetErrorHandling().TableflowV1ErrorHandlingLog.GetTarget(), // this Get function will return empty string if the ErrorHandling is not LOG
StorageType: storageType,
Suspended: topic.Spec.GetSuspended(),
Phase: topic.Status.GetPhase(),
CatalogSyncStatus: strStatus,
FailingTableFormat: strFormats,
ErrorMessage: topic.Status.GetErrorMessage(),
WriteMode: topic.Status.GetWriteMode(),
KafkaCluster: topic.GetSpec().KafkaCluster.GetId(),
TopicName: topic.Spec.GetDisplayName(),
EnableCompaction: topic.GetSpec().Config.GetEnableCompaction(), // should be read-only & true
EnablePartitioning: topic.GetSpec().Config.GetEnablePartitioning(), // should be read-only & true
TableFormats: strings.Join(topic.Spec.GetTableFormats(), ", "),
Environment: topic.GetSpec().Environment.GetId(),
RetentionMs: topic.GetSpec().Config.GetRetentionMs(),
RecordFailureStrategy: topic.GetSpec().Config.GetRecordFailureStrategy(),
MetadataColumnNamingScheme: topic.GetSpec().Config.GetMetadataColumnNamingScheme(),
ErrorHandling: getErrorHandlingMode(topic),
LogTarget: topic.GetSpec().Config.GetErrorHandling().TableflowV1ErrorHandlingLog.GetTarget(), // this Get function will return empty string if the ErrorHandling is not LOG
StorageType: storageType,
Suspended: topic.Spec.GetSuspended(),
Phase: topic.Status.GetPhase(),
CatalogSyncStatus: strStatus,
FailingTableFormat: strFormats,
ErrorMessage: topic.Status.GetErrorMessage(),
WriteMode: topic.Status.GetWriteMode(),
}

if storageType == byos {
Expand Down
10 changes: 10 additions & 0 deletions internal/tableflow/command_topic_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

cmd.Flags().String("retention-ms", "", "Specify the Tableflow table retention time in milliseconds.")
cmd.Flags().String("table-formats", "", "Specify the table formats, one of DELTA or ICEBERG.")
cmd.Flags().String("metadata-column-naming-scheme", "", "Specify the naming scheme for Tableflow's internal metadata columns in the materialized table, one of DEFAULT or PORTABLE.")

Check failure on line 35 in internal/tableflow/command_topic_update.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "metadata-column-naming-scheme" 3 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3410&issues=fa19d035-cc44-4c6a-9b22-9f29b938eb3d&open=fa19d035-cc44-4c6a-9b22-9f29b938eb3d
addErrorHandlingFlags(cmd)

pcmd.AddContextFlag(cmd, c.CLICommand)
Expand All @@ -44,7 +45,7 @@
return cmd
}

func (c *command) update(cmd *cobra.Command, args []string) error {

Check failure on line 48 in internal/tableflow/command_topic_update.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Refactor this method to reduce its Cognitive Complexity from 27 to the 15 allowed.

[S3776] Cognitive Complexity of functions should not be too high See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3410&issues=33827b92-90ed-44b1-942e-6f0534b94d54&open=33827b92-90ed-44b1-942e-6f0534b94d54
environmentId, err := c.Context.EnvironmentId()
if err != nil {
return err
Expand All @@ -71,6 +72,11 @@
return err
}

metadataColumnNamingScheme, err := cmd.Flags().GetString("metadata-column-naming-scheme")
if err != nil {
return err
}

errorHandling, err := cmd.Flags().GetString("error-handling")
if err != nil {
return err
Expand Down Expand Up @@ -101,6 +107,10 @@
topicUpdate.Spec.Config.SetRecordFailureStrategy(recordFailureStrategy)
}

if cmd.Flags().Changed("metadata-column-naming-scheme") {
topicUpdate.Spec.Config.SetMetadataColumnNamingScheme(strings.ToUpper(metadataColumnNamingScheme))
}

if cmd.Flags().Changed("error-handling") {
if strings.ToUpper(errorHandling) == suspend {
topicUpdate.Spec.Config.ErrorHandling = &tableflowv1.TableflowV1TableFlowTopicConfigsSpecErrorHandlingOneOf{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"enable_partitioning": true,
"environment": "env-596",
"record_failure_strategy": "SKIP",
"metadata_column_naming_scheme": "PORTABLE",
"retention_ms": "604800000",
"storage_type": "AzureDataLakeStorageGen2",
"provider_integration_id": "cspi-stgce89r7",
Expand Down
Loading