Get revision and service listing skeletons in.#2
Conversation
This adds the kn program, with basic commands for service and revision listing in. kn service list kn revision list They use the genericclioptions library from kubernetes to support jsonpath, yaml, and json output. The default is to just list the names of the objects, for now, until we add in some of the kubectl-based libraries for creating tables in another commit. This is deliberately bare-bones; I am looking to get the basic skeletons of how this repository is laid out down. No tests yet. Soon.
|
@sixolet what do you think about pattern a lot of go CLIs go with: have a cmd/kn/ directory with main.go and pkg/kn/commands/ that contains implementation of commands (similar to https://github.com/kubernetes/kubernetes/blob/master/cmd/kubectl/kubectl.go) |
|
i think we should also figure out how to move some of this stuff into objects instead of global variables. i've heard for example from riff folks that they want to use CLI commands as a library as well to add more of their own commands. might be a bit cleaner. we should also figure out how to only have one exit point (one |
|
That structure of files sounds fine and I'll make this PR so; this is just the structure generated for me by the cobra commandline, rather than something I decided was best. I'll look at the exiting and non-global suggestions and see if they fit in this PR or a separate follow-on PR or two. |
|
K, I think making stuff less global is going to wait; the examples I can find of Cobra best practices all have their commands global and things initialized using module init functions. Let's have conversation about how to unglobalize stuff after this is in? |
| // use the current context in kubeconfig | ||
| config, err := clientcmd.BuildConfigFromFlags("", kubeCfgFile) | ||
| if err != nil { | ||
| panic(err.Error()) |
| // use the current context in kubeconfig | ||
| config, err := clientcmd.BuildConfigFromFlags("", kubeCfgFile) | ||
| if err != nil { | ||
| panic(err.Error()) |
ok. will wait for that.
knctl does it the same way as kubectl
ultimately all commands are combined into root cmd: https://github.com/cppforlife/knctl/blob/master/pkg/knctl/cmd/knctl.go |
|
Agreeing with @cppforlife on the non global variable thing. In That said, we can iterate in follow-ups if needed 👼 |
…r triggered by main.go init
|
/lgtm as a starting point.
i think this should be next. writing some unit tests may actually change some of the structure. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cppforlife, sixolet, vdemeester The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
# This is the 1st commit message: adding BUILT-IN SOURCE column for kn source list-types # The commit message knative#2 will be skipped: # changing list test to check for BUILT-IN SOURCE column # The commit message knative#3 will be skipped: # changing e2e source list test to check for BUILT-IN SOURCE column # The commit message knative#4 will be skipped: # adding CHANGELOG entry # The commit message knative#5 will be skipped: # kn source list-types: changing BUILT-IN SOURCE to BUILT-IN and moving DESCRIPTION column to the end # The commit message knative#6 will be skipped: # changing BUILT-IN SOURCE to BUILT-IN in changelog # The commit message knative#7 will be skipped: # Update CHANGELOG.adoc # # Co-authored-by: David Simansky <dsimansk@redhat.com> # The commit message knative#8 will be skipped: # kn source list-types: changing column header to S, values to X, and moving to second column # The commit message knative#9 will be skipped: # fixing CHANGELOG merge conflict
* # This is a combination of 9 commits. # This is the 1st commit message: adding BUILT-IN SOURCE column for kn source list-types # The commit message #2 will be skipped: # changing list test to check for BUILT-IN SOURCE column # The commit message #3 will be skipped: # changing e2e source list test to check for BUILT-IN SOURCE column # The commit message #4 will be skipped: # adding CHANGELOG entry # The commit message #5 will be skipped: # kn source list-types: changing BUILT-IN SOURCE to BUILT-IN and moving DESCRIPTION column to the end # The commit message #6 will be skipped: # changing BUILT-IN SOURCE to BUILT-IN in changelog # The commit message #7 will be skipped: # Update CHANGELOG.adoc # # Co-authored-by: David Simansky <dsimansk@redhat.com> # The commit message #8 will be skipped: # kn source list-types: changing column header to S, values to X, and moving to second column # The commit message #9 will be skipped: # fixing CHANGELOG merge conflict * adding BUILT-IN SOURCE column for kn source list-types
This adds the kn program, with basic commands for service and revision listing
in.
kn service list
kn revision list
They use the genericclioptions library from kubernetes to support jsonpath,
yaml, and json output. The default is to just list the names of the objects, for
now, until we add in some of the kubectl-based libraries for creating tables in
another commit.
This is deliberately bare-bones; I am looking to get the basic skeletons of how
this repository is laid out down.
No tests yet. Soon.