@@ -19,23 +19,25 @@ const (
1919)
2020
2121type topicOut struct {
22- KafkaCluster string `human:"Kafka Cluster" serialized:"kafka_cluster"`
23- TopicName string `human:"Topic Name" serialized:"topic_name"`
24- EnableCompaction bool `human:"Enable Compaction" serialized:"enable_compaction"`
25- EnablePartitioning bool `human:"Enable Partitioning" serialized:"enable_partitioning"`
26- Environment string `human:"Environment" serialized:"environment"`
27- RecordFailureStrategy string `human:"Record Failure Strategy" serialized:"record_failure_strategy"`
28- RetentionMs string `human:"Retention Ms" serialized:"retention_ms"`
29- StorageType string `human:"Storage Type" serialized:"storage_type"`
30- ProviderIntegrationId string `human:"Provider Integration ID,omitempty" serialized:"provider_integration_id,omitempty"`
31- BucketName string `human:"Bucket Name,omitempty" serialized:"bucket_name,omitempty"`
32- BucketRegion string `human:"Bucket Region,omitempty" serialized:"bucket_region,omitempty"`
33- Suspended bool `human:"Suspended" serialized:"suspended"`
34- TableFormats string `human:"Table Formats" serialized:"table_formats"`
35- TablePath string `human:"Table Path" serialized:"table_path"`
36- Phase string `human:"Phase" serialized:"phase"`
37- ErrorMessage string `human:"Error Message,omitempty" serialized:"error_message,omitempty"`
38- WriteMode string `human:"Write Mode,omitempty" serialized:"write_mode,omitempty"`
22+ KafkaCluster string `human:"Kafka Cluster" serialized:"kafka_cluster"`
23+ TopicName string `human:"Topic Name" serialized:"topic_name"`
24+ EnableCompaction bool `human:"Enable Compaction" serialized:"enable_compaction"`
25+ EnablePartitioning bool `human:"Enable Partitioning" serialized:"enable_partitioning"`
26+ Environment string `human:"Environment" serialized:"environment"`
27+ RecordFailureStrategy string `human:"Record Failure Strategy" serialized:"record_failure_strategy"`
28+ RetentionMs string `human:"Retention Ms" serialized:"retention_ms"`
29+ StorageType string `human:"Storage Type" serialized:"storage_type"`
30+ ProviderIntegrationId string `human:"Provider Integration ID,omitempty" serialized:"provider_integration_id,omitempty"`
31+ BucketName string `human:"Bucket Name,omitempty" serialized:"bucket_name,omitempty"`
32+ BucketRegion string `human:"Bucket Region,omitempty" serialized:"bucket_region,omitempty"`
33+ Suspended bool `human:"Suspended" serialized:"suspended"`
34+ TableFormats string `human:"Table Formats" serialized:"table_formats"`
35+ TablePath string `human:"Table Path" serialized:"table_path"`
36+ Phase string `human:"Phase" serialized:"phase"`
37+ CatalogSyncStatus map [string ]string `human:"Catalog Sync Status,omitempty" serialized:"catalog_sync_status,omitempty"`
38+ FailingTableFormat map [string ]string `human:"Failing Table Format,omitempty" serialized:"failing_table_format,omitempty"`
39+ ErrorMessage string `human:"Error Message,omitempty" serialized:"error_message,omitempty"`
40+ WriteMode string `human:"Write Mode,omitempty" serialized:"write_mode,omitempty"`
3941}
4042
4143func (c * command ) newTopicCommand () * cobra.Command {
@@ -106,6 +108,56 @@ func getStorageType(topic tableflowv1.TableflowV1TableflowTopic) (string, error)
106108 return "" , fmt .Errorf (errors .CorruptedNetworkResponseErrorMsg , "config" )
107109}
108110
111+ // include error message in output if Sync Status is FAILED
112+ func getDescribeCatalogSyncStatuses (statuses []tableflowv1.TableflowV1CatalogSyncStatus ) map [string ]string {
113+ result := make (map [string ]string )
114+ for _ , s := range statuses {
115+ catalogIntegrationId := "id-unknown"
116+ if s .CatalogIntegrationId != nil {
117+ catalogIntegrationId = * s .CatalogIntegrationId
118+ }
119+ syncStatus := "status-unknown"
120+ if s .SyncStatus != nil {
121+ syncStatus = * s .SyncStatus
122+ }
123+
124+ if syncStatus == "FAILED" && s .ErrorMessage .IsSet () {
125+ if v := s .ErrorMessage .Get (); v != nil && * v != "" {
126+ syncStatus = fmt .Sprintf ("%s-%s" , syncStatus , * v )
127+ }
128+ }
129+
130+ result [catalogIntegrationId ] = syncStatus
131+ }
132+ return result
133+ }
134+
135+ // does not include error message in output if Sync Status is FAILED, to maintain readability
136+ func getListCatalogSyncStatuses (statuses []tableflowv1.TableflowV1CatalogSyncStatus ) map [string ]string {
137+ result := make (map [string ]string )
138+ for _ , s := range statuses {
139+ catalogIntegrationId := "id-unknown"
140+ if s .CatalogIntegrationId != nil {
141+ catalogIntegrationId = * s .CatalogIntegrationId
142+ }
143+ syncStatus := "status-unknown"
144+ if s .SyncStatus != nil {
145+ syncStatus = * s .SyncStatus
146+ }
147+
148+ result [catalogIntegrationId ] = syncStatus
149+ }
150+ return result
151+ }
152+
153+ func getFailingTableFormats (formats []tableflowv1.TableflowV1TableflowTopicStatusFailingTableFormats ) map [string ]string {
154+ result := make (map [string ]string )
155+ for _ , f := range formats {
156+ result [f .Format ] = f .ErrorMessage
157+ }
158+ return result
159+ }
160+
109161func printTopicTable (cmd * cobra.Command , topic tableflowv1.TableflowV1TableflowTopic ) error {
110162 storageType , err := getStorageType (topic )
111163 if err != nil {
@@ -119,18 +171,23 @@ func printTopicTable(cmd *cobra.Command, topic tableflowv1.TableflowV1TableflowT
119171 return fmt .Errorf (errors .CorruptedNetworkResponseErrorMsg , "status not found" )
120172 }
121173
174+ strStatus := getDescribeCatalogSyncStatuses (topic .Status .GetCatalogSyncStatuses ())
175+ strFormats := getFailingTableFormats (topic .Status .GetFailingTableFormats ())
176+
122177 out := & topicOut {
123178 KafkaCluster : topic .GetSpec ().KafkaCluster .GetId (),
124179 TopicName : topic .Spec .GetDisplayName (),
125180 EnableCompaction : topic .GetSpec ().Config .GetEnableCompaction (), // should be read-only & true
126181 EnablePartitioning : topic .GetSpec ().Config .GetEnablePartitioning (), // should be read-only & true
127- TableFormats : strings .Join (topic .Spec .GetTableFormats (), "" ),
182+ TableFormats : strings .Join (topic .Spec .GetTableFormats (), ", " ),
128183 Environment : topic .GetSpec ().Environment .GetId (),
129184 RetentionMs : topic .GetSpec ().Config .GetRetentionMs (),
130185 RecordFailureStrategy : topic .GetSpec ().Config .GetRecordFailureStrategy (),
131186 StorageType : storageType ,
132187 Suspended : topic .Spec .GetSuspended (),
133188 Phase : topic .Status .GetPhase (),
189+ CatalogSyncStatus : strStatus ,
190+ FailingTableFormat : strFormats ,
134191 ErrorMessage : topic .Status .GetErrorMessage (),
135192 WriteMode : topic .Status .GetWriteMode (),
136193 }
@@ -146,5 +203,5 @@ func printTopicTable(cmd *cobra.Command, topic tableflowv1.TableflowV1TableflowT
146203
147204 table := output .NewTable (cmd )
148205 table .Add (out )
149- return table .Print ( )
206+ return table .PrintWithAutoWrap ( false )
150207}
0 commit comments