Skip to content

[Go] kubens not resolving file paths relative to config file #229

Open
@nbusseneau

Description

@nbusseneau

Hi,

Just switched from bash version to Go version on a Windows environment (Git Bash).

It looks like kubens does not treat relative file paths in .kube/config as relative to the config file, but rather as relative to current working directory:

λ kubens
error: could not list namespaces (is the cluster accessible?): failed to initialize config: invalid configuration: [
unable to read client-cert REDACTED_PATH_CRT.crt for REDACTED_USER due to open REDACTED_PATH_CRT.crt: The system cannot find the file specified.,
unable to read client-key REDACTED_PATH_KEY.key for REDACTED_USER due to open REDACTED_PATH_KEY.key: The system cannot find the file specified.,
unable to read certificate-authority REDACTED_PATH_CRT_2.crt for REDACTED_CLUSTER due to open REDACTED_PATH_CRT_2.crt: The system cannot find the file specified.]

λ cd ~/.kube/
λ kubens
{works as expected}

λ cd ..
error: could not list namespaces (is the cluster accessible?): failed to initialize config: invalid configuration: [
unable to read client-cert REDACTED_PATH_CRT.crt for REDACTED_USER due to open REDACTED_PATH_CRT.crt: The system cannot find the file specified.,
unable to read client-key REDACTED_PATH_KEY.key for REDACTED_USER due to open REDACTED_PATH_KEY.key: The system cannot find the file specified.,
unable to read certificate-authority REDACTED_PATH_CRT_2.crt for REDACTED_CLUSTER due to open REDACTED_PATH_CRT_2.crt: The system cannot find the file specified.]

Current workaround is to use absolute file paths in config file by prefixing all paths with C:\Users\USERNAME\.kube\, but that kinda defeats the purpose of having a .kube directory :D

I did not have a chance to play with Go yet, but if nobody picks this up and I have some time this weekend, I'll have a try at it.

Thanks for the awesome work by the way! 👍

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions