so0k / powerline-kubernetes

A Powerline segment to show your current Kubernetes context
MIT License
41 stars 19 forks source link

Very long contexts when using with OpenShift #3

Open bliemli opened 7 years ago

bliemli commented 7 years ago

When using powerline-kubernetes with OpenShift, the context part usually gets very long, e.g.:

⎈ explore-00/master-asdf-openshift3roadshow-com:443/user00 - explore-00

A config parameter permitting to either only display the namespace or the context would be great.

so0k commented 7 years ago

Sorry I hadn't seen this issue until just now. I'll have a look into this - thanks for suggestion.

for me, I can manage my context and namespace names as I'm working with k8s directly (and just use kubectl config set-context with the desired name), but a feature toggle what you want to display or trim either field isn't a bad idea.

If trimming, should it chop off in the front or the end?

bliemli commented 7 years ago

Thanks for writing back. I just realized ... config set-context works for oc as well. But to answer your question: When working with OpenShift, the interesting part in the above example would simply be explore-00 in a lot of use cases. This corresponds to the NAMESPACE part of the get-context output. So maybe an idea would be to allow toggling the different fields of the get-context output, in my case:

$ oc config get-contexts 
CURRENT  NAME  CLUSTER  AUTHINFO  NAMESPACE
...

(where CURRENT doesn't contain any useful information and could probably be left out anyway). So if I wanted to only display the NAMESPACE part I'd toggle off all other parts and only allow NAMESPACE.

kungfuchicken commented 5 years ago

@bliemli I think @so0k took care of this with more recent updates that let you toggle whether the context and/or namespace get added.

rgordill commented 4 years ago

Hi.

Why does not adds "cluster" as a new parameter? It would be easier in most of the situation to have just that instead of the context, particularly with OpenShift.

Just adding

cluster = ctx['cluster']

And the corresponding references.