c-bata / kube-prompt

An interactive kubernetes client featuring auto-complete.
MIT License
1.79k stars 134 forks source link

Setting default namespace #19

Closed akhy closed 5 years ago

akhy commented 6 years ago

I think this feature would be very useful when we're working in certain namespace. For example, we would execute kube-prompt --namespace staging to set default namespace to staging if not set explicitly in the prompt. So we don't need to type --namespace option for each commands.

Bonus: Taking more generic approach, it would be better if kube-prompt CLI accept options from original kubectl command as defaults. For example, executing kube-prompt --namespace dev -o wide sets default namespace to dev and output format to wide for any compatible commands. (i.e. it behaves like currying/partial application in functional programming)

c-bata commented 5 years ago

Fix this behavior at https://github.com/c-bata/kube-prompt/pull/42

Determine the namespace to use after merged this PR:

  1. Use a command-line flag if it exists --namespace (or -n).
  2. Use the namespace of current context.
c-bata commented 5 years ago

Hi @akhy. This terrible behavior around namespace is fixed at v1.0.6. Please update your kube-prompt.

https://github.com/c-bata/kube-prompt/releases/tag/v1.0.6

sheerun commented 4 years ago

@c-bata Is it possible to change defualt namespace inside session?

c-bata commented 4 years ago

Currently you can't. But if everyone want this feature, it might be worth to consider it. The most concerned thing is that need to design magic command syntax like:

>>> !namespace <yournamespace>  # magic command starts with "!"
Changed namespace: <yournamespace>
>>>
mitchellmaler commented 4 years ago

@c-bata I am in favor of switching the namespace and even the context in session. Could even do slash instead of !. /namespace

!context "context autocomplete" !namespace "namespace autocomplete"

I tend to switch between multiple clusters and namespaces a lot so being able to switch these easily would be awesome.