Open needleshaped opened 6 hours ago
Update! I have installed same binary in Powershell, and noted, that
PS Write-Output $env:KUBECONFIG
/Users/user/.kube/.switch_tmp/config.3246108154.tmp
is without /c or C:\
Also, from original comment you can see, that Windows binary translates path to Windows format on it's own, always.
I see related issue https://github.com/danielfoehrKn/kubeswitch/issues/131
So let's try another workaround, removing disk C
# try with UNIX style path
$ unset KUBECONFIG
$ switch # switched to context dev-cluster
$ export KUBECONFIG=$(cygpath -u "$KUBECONFIG" | sed 's|/c||')
$ echo $KUBECONFIG
/Users/user/.kube/.switch_tmp/config.2390096444.tmp
$ switch --debug
time="2024-10-17T14:41:24+03:00" level=debug msg="Adding kubeconfig path from KUBECONFIG env C:/scoop/apps/git/2.46.0/Users/user/.kube/.switch_tmp/config.2390096444.tmp"
time="2024-10-17T14:41:24+03:00" level=debug msg="Starting search for store: filesystem" store=filesystem
Error: the configured kubeconfig directory "C" does not exist
time="2024-10-17T14:41:24+03:00" level=debug msg="Starting search for store: filesystem" store=filesystem
the configured kubeconfig directory "C" does not exist
Wow, Switcher binary constructs KUBECONFIG path from path to bash.exe
+ KUBECONFIG
without disk
# try with Windows style path
$ unset KUBECONFIG
$ switch # switched to context dev-cluster
$ export KUBECONFIG=$(cygpath -w "$KUBECONFIG" | sed 's|C:||')
$ echo $KUBECONFIG
\Users\user\.kube\.switch_tmp\config.2719742217.tmp
$ switch --debug
And that finally works!
s() {
switch "$@" && export KUBECONFIG=$(cygpath -w "$KUBECONFIG" | sed 's|C:||')
# cygpath used by MINGW https://www.msys2.org/docs/filesystem-paths/
}
The code line is: https://github.com/danielfoehrKn/kubeswitch/blame/master/cmd/switcher/init.go#L219
$KUBECONFIG_PATH = $KUBECONFIG_PATH -replace "C:", ""
I wonder, WHY disk is removed from path? this is so awkward, confusing. 😢 Is it attempt to make it portable?
TLDR: Using Windows with Bash (e.g. git-bash from Git For Windows) + Windows version of kubeswitch results in
! Notice mixed Windows and Linux style paths:
This stems from the fact, that binary and shell do work together: https://github.com/danielfoehrKn/kubeswitch/blob/master/docs/how_it_works.md
HOWEVER, convertion of KUBECONFIG to NEITHER Unix or Bash format works:
Workaround:
unset KUBECONFIG before running switcher (we loose current context, bad)
Environment:
file
shows: switcher.exe: PE32+ executable (console) x86-64, for MS Windows, 8 sectionsHow to repeat
P.S.:
Configuration uses
~
and it works fine, shows up in selection