mirror of https://github.com/knative/client.git
fix kn trigger list command to show correct v1/service sink output (#1428)
* fix kn trigger list command to show correct v1/service sink output * Update pkg/kn/commands/flags/sink.go Co-authored-by: Murugappan Chetty <itsmurugappan@gmail.com> Co-authored-by: Murugappan Chetty <itsmurugappan@gmail.com>
This commit is contained in:
parent
00269396cf
commit
4a0ac33dcc
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
"apiVersion": "serving.knative.dev/v1",
|
||||
"kind": "Service",
|
||||
"name": "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
"apiVersion": "serving.knative.dev/v1",
|
||||
"kind": "Service",
|
||||
"name": "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue