Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kn source list - list all source instances (built-in, plugin, untyped) #480

Closed
sixolet opened this issue Nov 5, 2019 · 2 comments · Fixed by #666
Closed

kn source list - list all source instances (built-in, plugin, untyped) #480

sixolet opened this issue Nov 5, 2019 · 2 comments · Fixed by #666
Assignees
Labels
comp/source kind/feature New feature or request
Milestone

Comments

@sixolet
Copy link
Contributor

sixolet commented Nov 5, 2019

kn source list should list sources of all source CRDs, unlike the normal list which only lists one type. It should have an option to list only one type, too.

See the spec for details:

For listing all sources, kn queries all instances of source CRDs. So it first picks up all CRDs that are describing Sources and then queries each CRD type in turn to look up its COs and also checks whether this CO is supported by a typed source handler (built-in/plugin).

# List all created sources
$ kn source list

NAME            TYPE     RESOURCE                                 SINK    
twitter-knative twitter  twittersource.sources.k8spatterns.io     myservice 
mystorage       storage  storages.storages.events.cloud.run       broker:default

This list can be filtered by type (--type) or on the resource name (--source-name).

The general algorithm described above in pseudo-code:

var pluginTypes map[string]string
// sourcePlugins: All kn plugins prefixed with "kn-source-"
for _, plugin := range sourcePlugins {
    // Actually execute a command on the plugin ("manifest") 
    // and parse the output. See Source Plugins for details.
    for _, crd := range plugin.CRDs() {
        pluginTypes[crd] = plugin.Name
    }
}
var crds map[string]string
// Reach out to the cluster and query for all CRDs with a certain label
for _, crd := range listK8sCRDsWithSourceLabel() {
    crds[crd.Name] = "generic"
    if plugin, ok := pluginTypes[crd.Name]; ok {
        crds[crd.Name] = plugin
    }
}
for crd, plugin := range crds {
    printCustomObjectsUsingPluginIfNotGeneric(plugin, crd, namespace)
}
@sixolet sixolet added kind/feature New feature or request topic/eventing-mvp labels Nov 5, 2019
@sixolet sixolet added this to the v0.11.0 milestone Nov 5, 2019
@rhuss rhuss changed the title kn source list kn source list - List all typed and untyped source instances Nov 27, 2019
@rhuss
Copy link
Contributor

rhuss commented Nov 27, 2019

Updated description with the content of the spec (which remains the authorative document)

@rhuss rhuss changed the title kn source list - List all typed and untyped source instances kn source list - List all source instances (built-in, plugin, untyped) Nov 27, 2019
@rhuss rhuss changed the title kn source list - List all source instances (built-in, plugin, untyped) kn source list - list all source instances (built-in, plugin, untyped) Nov 27, 2019
@rhuss rhuss modified the milestones: v0.11.0, v0.12.0 Dec 16, 2019
@navidshaikh
Copy link
Collaborator

We have leaf list verb for supported sources to cover for now, would be good if we can bring kn source list.

@maximilien are you on it?

@navidshaikh navidshaikh modified the milestones: v0.12.0, v0.13.0 Feb 4, 2020
@rhuss rhuss assigned navidshaikh and unassigned maximilien Feb 5, 2020
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 14, 2020
 Fixes knative#480

 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 14, 2020
 Fixes knative#480

 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 18, 2020
 Fixes knative#480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 18, 2020
 Fixes knative#480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 18, 2020
 Fixes knative#480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 18, 2020
 Fixes knative#480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 18, 2020
 Fixes knative#480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry
navidshaikh added a commit to navidshaikh/client that referenced this issue Feb 26, 2020
 Fixes knative#480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry
knative-prow-robot pushed a commit that referenced this issue Mar 10, 2020
* feat(source): Add 'kn source list'

 Fixes #480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry

* Update group for ApiServerSource in tests

* Add kn duck source type for holding common eventing source fileds

 - Common infromation from sources are extracted into a struct
   for source list command output
 - Printer function picks the information from this struct object
   and doesn't know the details about extracting this info from multiple
   types of sources received
 - Group and Version for list is set to empty string and Kind to 'List',
   if printed a source list with multiple types of sources in machine readable
   format
 - Group, Version and Kind for list are kept intact if printed a source list
   with same type of source objects in machine readable format

* Update go.sum

* Add WithType builder for listing source

 - Separate the flags definition
 - WithType builder can be re-used to filter the source types
 - Add unit tests

* Update ApiServer source group to apiserversources.sources.knative.dev

* Fix typos and align

Co-authored-by: Roland Huß <[email protected]>
coryrc pushed a commit to coryrc/client that referenced this issue May 14, 2020
APICoverage-Recorder in the commit
knative/test-infra#463 was writting an
instance of v1beta1.AdmissionResponse to the http.ResponseWriter
when it should be writting v1beta1.AdmissionReview this changeset
fixes the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp/source kind/feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants