Skip to content
Merged
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: 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" && strings.HasPrefix(sink.Ref.APIVersion, sinkMappings["ksvc"].Group) {
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
5 changes: 3 additions & 2 deletions pkg/kn/commands/source/duck/multisourcelist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ func newSourceUnstructuredObjWithSink(name, apiVersion, kind string) *unstructur
"spec": map[string]interface{}{
"sink": map[string]interface{}{
"ref": map[string]interface{}{
"kind": "Service",
"name": "foo",
Comment on lines -86 to -87
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only kind and name are not enough here. An error will appear: "Unable to get the Subscriber's URI"

"apiVersion": "serving.knative.dev/v1",
"kind": "Service",
"name": "foo",
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/kn/commands/source/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ func newSourceUnstructuredObj(name, apiVersion, kind string) *unstructured.Unstr
"spec": map[string]interface{}{
"sink": map[string]interface{}{
"ref": map[string]interface{}{
"kind": "Service",
"name": "foo",
Comment on lines -191 to -192
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only kind and name are not enough here. An error will appear: "Unable to get the Subscriber's URI"

"apiVersion": "serving.knative.dev/v1",
"kind": "Service",
"name": "foo",
},
},
},
Expand Down