From c3455f9207c1b6222379099c08fd992abbc6fa2c Mon Sep 17 00:00:00 2001 From: Luyi Xiao Date: Tue, 8 Oct 2024 12:54:39 -0700 Subject: [PATCH 1/3] add --- internal/kafka/command_link_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/kafka/command_link_list.go b/internal/kafka/command_link_list.go index a363b32fc1..f2afab91ac 100644 --- a/internal/kafka/command_link_list.go +++ b/internal/kafka/command_link_list.go @@ -83,5 +83,5 @@ func getListFields(includeTopics bool) []string { x = append(x, "TopicName") } - return append(x, "SourceCluster", "DestinationCluster", "RemoteCluster", "State", "Error", "ErrorMessage") + return append(x, "RemoteCluster", "State", "Error", "ErrorMessage") } From 60568cfba93337284fe81b8db7af3f61969979a2 Mon Sep 17 00:00:00 2001 From: Luyi Xiao <166444028+luyixiao12@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:00:31 -0700 Subject: [PATCH 2/3] add test (#139) --- internal/kafka/command_link_describe.go | 2 +- internal/kafka/command_link_list.go | 11 ++++++++--- .../output/kafka/link/list-link-json.golden | 6 ------ .../output/kafka/link/list-link-plain.golden | 16 ++++++++-------- .../output/kafka/link/list-link-yaml.golden | 6 ------ 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/internal/kafka/command_link_describe.go b/internal/kafka/command_link_describe.go index 6b8d0eeac0..e17180d18d 100644 --- a/internal/kafka/command_link_describe.go +++ b/internal/kafka/command_link_describe.go @@ -52,7 +52,7 @@ func (c *linkCommand) describe(cmd *cobra.Command, args []string) error { table := output.NewTable(cmd) table.Add(newDescribeLink(link, "")) - table.Filter(getListFields(false)) + table.Filter(getListFields(false, false)) return table.Print() } diff --git a/internal/kafka/command_link_list.go b/internal/kafka/command_link_list.go index f2afab91ac..65312383bb 100644 --- a/internal/kafka/command_link_list.go +++ b/internal/kafka/command_link_list.go @@ -72,16 +72,21 @@ func (c *linkCommand) list(cmd *cobra.Command, _ []string) error { list.Add(newLink(link, "")) } } - list.Filter(getListFields(includeTopics)) + list.Filter(getListFields(includeTopics, true)) return list.Print() } -func getListFields(includeTopics bool) []string { +func getListFields(includeTopics bool, isListLink bool) []string { x := []string{"Name"} if includeTopics { x = append(x, "TopicName") } - return append(x, "RemoteCluster", "State", "Error", "ErrorMessage") + if isListLink { + return append(x, "RemoteCluster", "State", "Error", "ErrorMessage") + } else { + return append(x, "SourceCluster", "DestinationCluster", "RemoteCluster", "State", "Error", "ErrorMessage") + } + } diff --git a/test/fixtures/output/kafka/link/list-link-json.golden b/test/fixtures/output/kafka/link/list-link-json.golden index 29dd6a5e11..bdcf61efce 100644 --- a/test/fixtures/output/kafka/link/list-link-json.golden +++ b/test/fixtures/output/kafka/link/list-link-json.golden @@ -1,20 +1,14 @@ [ { "link_name": "link-1", - "source_cluster": "cluster-1", - "destination_cluster": "cluster-2", "state": "" }, { "link_name": "link-2", - "source_cluster": "cluster-1", - "destination_cluster": "cluster-2", "state": "AVAILABLE" }, { "link_name": "link-3", - "source_cluster": "cluster-1", - "destination_cluster": "cluster-2", "state": "UNAVAILABLE", "error": "AUTHENTICATION_ERROR", "error_message": "Please check your API key and secret." diff --git a/test/fixtures/output/kafka/link/list-link-plain.golden b/test/fixtures/output/kafka/link/list-link-plain.golden index 8dbc384ffb..e518a9c29b 100644 --- a/test/fixtures/output/kafka/link/list-link-plain.golden +++ b/test/fixtures/output/kafka/link/list-link-plain.golden @@ -1,8 +1,8 @@ - Name | Source Cluster | Destination Cluster | Remote Cluster | State | Error | Error Message ----------+----------------+---------------------+----------------+-------------+----------------------+--------------------------------- - link-1 | cluster-1 | cluster-2 | | | | - link-2 | cluster-1 | cluster-2 | | AVAILABLE | | - link-3 | cluster-1 | cluster-2 | | UNAVAILABLE | AUTHENTICATION_ERROR | Please check your API key and - | | | | | | secret. - link-4 | | | cluster-2 | | | - link-5 | | | cluster-2 | | | + Name | Remote Cluster | State | Error | Error Message +---------+----------------+-------------+----------------------+--------------------------------- + link-1 | | | | + link-2 | | AVAILABLE | | + link-3 | | UNAVAILABLE | AUTHENTICATION_ERROR | Please check your API key and + | | | | secret. + link-4 | cluster-2 | | | + link-5 | cluster-2 | | | diff --git a/test/fixtures/output/kafka/link/list-link-yaml.golden b/test/fixtures/output/kafka/link/list-link-yaml.golden index 583519cafa..16d5bf56c3 100644 --- a/test/fixtures/output/kafka/link/list-link-yaml.golden +++ b/test/fixtures/output/kafka/link/list-link-yaml.golden @@ -1,14 +1,8 @@ - link_name: link-1 - source_cluster: cluster-1 - destination_cluster: cluster-2 state: "" - link_name: link-2 - source_cluster: cluster-1 - destination_cluster: cluster-2 state: AVAILABLE - link_name: link-3 - source_cluster: cluster-1 - destination_cluster: cluster-2 state: UNAVAILABLE error: AUTHENTICATION_ERROR error_message: Please check your API key and secret. From e52ec7776c249a44aa14b09d037d0444f4469f24 Mon Sep 17 00:00:00 2001 From: Luyi Xiao <166444028+luyixiao12@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:12:41 -0700 Subject: [PATCH 3/3] KGLOBAL-5631: Minor style change --- internal/kafka/command_link_list.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/kafka/command_link_list.go b/internal/kafka/command_link_list.go index 65312383bb..00e7fdb6ba 100644 --- a/internal/kafka/command_link_list.go +++ b/internal/kafka/command_link_list.go @@ -88,5 +88,4 @@ func getListFields(includeTopics bool, isListLink bool) []string { } else { return append(x, "SourceCluster", "DestinationCluster", "RemoteCluster", "State", "Error", "ErrorMessage") } - }