Skip to content

Commit

Permalink
fix kn trigger list command to show correct v1/service sink output
Browse files Browse the repository at this point in the history
  • Loading branch information
Abirdcfly committed Aug 14, 2021
1 parent 2e71451 commit 6c42449
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/kn/commands/flags/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func parseSink(sink string) (string, string, string) {
// SinkToString prepares a sink for list output
func SinkToString(sink duckv1.Destination) string {
if sink.Ref != nil {
if sink.Ref.Kind == "Service" {
if sink.Ref.Kind == "Service" && sink.Ref.APIVersion == "serving.knative.dev/v1" {
return fmt.Sprintf("ksvc:%s", sink.Ref.Name)
} else {
return fmt.Sprintf("%s:%s", strings.ToLower(sink.Ref.Kind), sink.Ref.Name)
Expand Down
7 changes: 7 additions & 0 deletions pkg/kn/commands/flags/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ func TestSinkToString(t *testing.T) {
Name: "default"}}
expected = "broker:default"
assert.Equal(t, expected, SinkToString(sink))
sink = duckv1.Destination{
Ref: &duckv1.KReference{Kind: "Service",
APIVersion: "v1",
Namespace: "my-namespace",
Name: "mysvc"}}
expected = "service:mysvc"
assert.Equal(t, expected, SinkToString(sink))

uri := "http://target.example.com"
targetExampleCom, err := apis.ParseURL(uri)
Expand Down

0 comments on commit 6c42449

Please sign in to comment.