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
3 changes: 3 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
| Fix kn export to always honor mode irrespective of revisions flag and have Export as the default mode
| https://github.com/knative/client/pull/1212[#1212]

| 🎁
| Add S column to specify built-in sources in kn source list-types
| https://github.com/knative/client/pull/1246[#1246]
|===

## v0.21.0 (2021-02-23)
Expand Down
11 changes: 10 additions & 1 deletion pkg/kn/commands/source/human_readable_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ var sourceTypeDescription = map[string]string{
"KafkaSource": "Route events from Apache Kafka Server to addressable",
}

var sourceTypeSupported = map[string]string{
"ApiServerSource": "X",
"SinkBinding": "X",
"PingSource": "X",
"ContainerSource": "X",
"KafkaSource": "",
}

// ListTypesHandlers handles printing human readable table for `kn source list-types`
func ListTypesHandlers(h printers.PrintHandler) {
sourceTypesColumnDefinitions := []metav1beta1.TableColumnDefinition{
{Name: "Type", Type: "string", Description: "Kind / Type of the source type", Priority: 1},
{Name: "S", Type: "string", Description: "Supported source", Priority: 1},
{Name: "Name", Type: "string", Description: "Name of the source type", Priority: 1},
{Name: "Description", Type: "string", Description: "Description of the source type", Priority: 1},
}
Expand Down Expand Up @@ -78,7 +87,7 @@ func printSourceTypes(sourceType unstructured.Unstructured, options printers.Pri
row := metav1beta1.TableRow{
Object: runtime.RawExtension{Object: &sourceType},
}
row.Cells = append(row.Cells, kind, name, sourceTypeDescription[kind])
row.Cells = append(row.Cells, kind, sourceTypeSupported[kind], name, sourceTypeDescription[kind])
return []metav1beta1.TableRow{row}, nil
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/kn/commands/source/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func TestSourceListTypes(t *testing.T) {
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"),
)
assert.NilError(t, err)
assert.Check(t, util.ContainsAll(output[0], "TYPE", "NAME", "DESCRIPTION"))
assert.Check(t, util.ContainsAll(output[1], "ApiServerSource", "apiserversources"))
assert.Check(t, util.ContainsAll(output[2], "PingSource", "pingsources"))
assert.Check(t, util.ContainsAll(output[0], "TYPE", "S", "NAME", "DESCRIPTION"))
assert.Check(t, util.ContainsAll(output[1], "ApiServerSource", "X", "apiserversources"))
assert.Check(t, util.ContainsAll(output[2], "PingSource", "X", "pingsources"))
}

func TestSourceListTypesNoHeaders(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/source_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestSourceListTypes(t *testing.T) {

t.Log("List available source types")
output := sourceListTypes(r)
assert.Check(t, util.ContainsAll(output, "TYPE", "NAME", "DESCRIPTION", "Ping", "ApiServer"))
assert.Check(t, util.ContainsAll(output, "TYPE", "S", "NAME", "DESCRIPTION", "Ping", "ApiServer"))

t.Log("List available source types in YAML format")

Expand Down