mirror of
https://github.com/ahmetb/kubectx.git
synced 2026-05-14 19:12:07 +00:00
When kubens needs to query the Kubernetes API (e.g. to check if a namespace exists), it builds a REST client from the in-memory kubeconfig bytes using clientcmd.RESTConfigFromKubeConfig(). This function has no knowledge of the kubeconfig file's location on disk, so it cannot resolve relative paths in exec credential plugin commands (e.g. `command: ../scripts/get-token.sh`). This causes a "no such file or directory" error for users whose kubeconfig uses relative paths in exec-based authentication. The fix threads the kubeconfig file path through a new PathHinter optional interface on ReadWriteResetCloser. When a file path is available, newKubernetesClientSet now uses clientcmd.NewNonInteractiveDeferredLoadingClientConfig with ExplicitPath, which resolves relative paths relative to the kubeconfig file's directory — matching kubectl's own behavior. The old bytes-based fallback is preserved for in-memory configs (e.g. tests). Fixes #488 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>