Skip to content

Commit

Permalink
KGLOBAL-2241: Dont print NO_ERROR for the link error in the CLI output (
Browse files Browse the repository at this point in the history
#1448)

* KGLOBAL-2241: Dont print NO_ERROR for the link error in the CLI output

* Use PtrString
  • Loading branch information
andymg3 authored Sep 29, 2022
1 parent b2dc992 commit ed3d832
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
6 changes: 5 additions & 1 deletion internal/cmd/kafka/command_link_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ type link struct {
}

func newLink(data kafkarestv3.ListLinksResponseData, topic string) *link {
var linkError string
if data.GetLinkError() != "NO_ERROR" {
linkError = data.GetLinkError()
}
return &link{
LinkName: data.LinkName,
TopicName: topic,
SourceClusterId: data.GetSourceClusterId(),
DestinationClusterId: data.GetDestinationClusterId(),
LinkState: data.GetLinkState(),
LinkError: data.GetLinkError(),
LinkError: linkError,
LinkErrorMessage: data.GetLinkErrorMessage(),
}
}
Expand Down
35 changes: 19 additions & 16 deletions test/test-server/kafka_rest_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,37 +473,40 @@ func (r KafkaRestProxyRouter) HandleKafkaRPLinks(t *testing.T) http.HandlerFunc
w.Header().Set("Content-Type", "application/json")
topics := make([]string, 2)
topics = append(topics, "link-1-topic-1", "link-1-topic-2")
cluster1 := "cluster-1"
cluster2 := "cluster-2"
linkStateAvailable := "AVAILABLE"
linkStateUnavailable := "UNAVAILABLE"
linkAuthErr := "AUTHENTICATION_ERROR"
linkAuthErrMsg := "Please check your API key and secret."
cluster1 := cckafkarestv3.PtrString("cluster-1")
cluster2 := cckafkarestv3.PtrString("cluster-2")
linkStateAvailable := cckafkarestv3.PtrString("AVAILABLE")
linkStateUnavailable := cckafkarestv3.PtrString("UNAVAILABLE")
linkAuthErr := cckafkarestv3.PtrString("AUTHENTICATION_ERROR")
noErrorErr := cckafkarestv3.PtrString("NO_ERROR")
linkAuthErrMsg := cckafkarestv3.PtrString("Please check your API key and secret.")
err := json.NewEncoder(w).Encode(cckafkarestv3.ListLinksResponseDataList{Data: []cckafkarestv3.ListLinksResponseData{
{
SourceClusterId: *cckafkarestv3.NewNullableString(&cluster1),
DestinationClusterId: *cckafkarestv3.NewNullableString(&cluster2),
SourceClusterId: *cckafkarestv3.NewNullableString(cluster1),
DestinationClusterId: *cckafkarestv3.NewNullableString(cluster2),
LinkName: "link-1",
LinkId: "LINKID1",
TopicsNames: &topics,
LinkError: noErrorErr,
},
{
SourceClusterId: *cckafkarestv3.NewNullableString(&cluster1),
DestinationClusterId: *cckafkarestv3.NewNullableString(&cluster2),
SourceClusterId: *cckafkarestv3.NewNullableString(cluster1),
DestinationClusterId: *cckafkarestv3.NewNullableString(cluster2),
LinkName: "link-2",
LinkId: "LINKID2",
TopicsNames: &topics,
LinkState: &linkStateAvailable,
LinkState: linkStateAvailable,
LinkError: noErrorErr,
},
{
SourceClusterId: *cckafkarestv3.NewNullableString(&cluster1),
DestinationClusterId: *cckafkarestv3.NewNullableString(&cluster2),
SourceClusterId: *cckafkarestv3.NewNullableString(cluster1),
DestinationClusterId: *cckafkarestv3.NewNullableString(cluster2),
LinkName: "link-3",
LinkId: "LINKID3",
TopicsNames: &topics,
LinkState: &linkStateUnavailable,
LinkError: &linkAuthErr,
LinkErrorMessage: *cckafkarestv3.NewNullableString(&linkAuthErrMsg),
LinkState: linkStateUnavailable,
LinkError: linkAuthErr,
LinkErrorMessage: *cckafkarestv3.NewNullableString(linkAuthErrMsg),
},
}})
require.NoError(t, err)
Expand Down

0 comments on commit ed3d832

Please sign in to comment.