Ramilito / kubesess

Kubectl plugin managing sessions
MIT License
205 stars 5 forks source link

Changing namespace takes two attempts #40

Closed morozov closed 1 year ago

morozov commented 1 year ago

Describe the bug When I change the namespace via kn (Fish), it takes two attempts to succeed instead of one.

Steps to reproduce

# Check if $KUBECONFIG is set
→ set -q KUBECONFIG && echo Set || echo Not set
Not set

# Try to change the namespace
→ kn strimzi && echo OK || echo Fail
Fail

# Again, check if $KUBECONFIG is set
→ set -q KUBECONFIG && echo Set || echo Not set
Set

# Print $KUBECONFIG value
→ echo $KUBECONFIG

# Again, try to change the namespace
→ kn strimzi && echo OK || echo Fail
OK

Expected behavior It should take a single attempt to change the namespace.

Desktop (please complete the following information):

Additional context It looks like kubesess expects $KUBECONFIG to be always set. The first failing attempt sets it to an empty string, and the second one succeeds.

Here's what it looks like with additional details:

RUST_BACKTRACE=1 kubesess namespace -c
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/config.rs:110:60
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::Option<T>::unwrap
             at /private/tmp/rust-20220923-6877-yszh4a/rustc-1.64.0-src/library/core/src/option.rs:775:21
   4: kubesess::config::get_current_session
             at /Users/smorozov/Projects/kubesess/src/config.rs:110:34
   5: kubesess::modes::namespace
             at /Users/smorozov/Projects/kubesess/src/modes.rs:67:18
   6: kubesess::Mode::invoke
             at /Users/smorozov/Projects/kubesess/src/main.rs:43:32
   7: kubesess::main
             at /Users/smorozov/Projects/kubesess/src/main.rs:57:5
   8: core::ops::function::FnOnce::call_once
             at /private/tmp/rust-20220923-6877-yszh4a/rustc-1.64.0-src/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.