databricks / click

The "Command Line Interactive Controller for Kubernetes"
Apache License 2.0
1.49k stars 84 forks source link

Make it easier to set the pod context #115

Open tleyden opened 5 years ago

tleyden commented 5 years ago

The ux is a bit confusing to select the pod context, and I didn't see anything in the help menu that described it.

Would you take a PR to change the ux to allow:

[context][namespace][] > pod mypod
[context][namespace][mypod] > pod mypod
nicklan commented 5 years ago

yeah, this makes it a bit more like kubectl i guess. i'd be okay with this, but there's a couple of things to think through:

  1. what if mypod doesn't exist? do we require that the name specified was part of the last list returned from a pods call? otherwise we have to validate the pod exists when you call this, or we have to fail more gracefully on subsequent commands that will try and manipulate a non-existent pod.

    I think the best experience would be to require it be part of the last list returned, which would also allow for tab-completion. The downside is, it removes the shortcut of being able to quickly switch to a pod you know exists without first having to call pods.

    Alternately we could allow any name to be specified, and if it's not in the last-list, validate it. tab-complete could follow similar rules, complete first from the last-list, then query the api-server.

  2. we'd probably want this for all resources, so I could also do service myservice and configmap myconfmap and so on. it's a bit awkward with the way commands are currently specified since each one would be similar but need a different command. this could probably be worked around with a macro.

Also, thanks for the point that there's nothing in help that discusses using numbers to select things, i'll certainly add that soon!

tleyden commented 5 years ago

what if mypod doesn't exist?

It could just give an error message:

No pod with that name exists and it wouldn't change any state.

be part of the last list returned, which would also allow for tab-completion

Agree it should be part of the associated list, but I think the user shouldn't need to call list just for this to work (if they already know the pod name). Tab-completion would be nice to have, but probably increases the scope enough that it would be better done in another PR.

we'd probably want this for all resources

Ah, good point.

this could probably be worked around with a macro.

Ewww.. I hope there's a better way. Good to know though.

bazhenov commented 1 year ago

Pods as well as a lot of different resources have dynamic postfixes (like bf5cc5c89-pkbq4). Those dynamic postfixes are hard to enter by hand. For productive navigation either UX should have some sort of dialog (like now) or autocomplete. Autocomplete I think is quite hard to implement in context of any k8s client because of latency of k8s API itself, which makes any autocomplete sluggish. In fact I have autocomplete plugin for kubectl in my zsh shell. And because of high latency it is basically unusable :(

I know I'm just bystander, but as for me, I like current method of selecting resources much more. 😇