Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XDG base dir spec for config file #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

triarius
Copy link

The XDG base directory specification is a popular way to store config files that doesn't clutter a user's home directory with dotfiles.

This tool stores its configuration in ~/.kube/kubie.yaml, however, I think it should follow the spec and store it in a location that is not shared by other tools.

Fortunately, the dirs crate has native support for the XDG base directory spec, so we can use it to handle resolving the environment variables and falling back to the defaults in the spec.

What this means is that the new default location for this tool's settings from this PR onwards is ~/.config/kubie/config.yaml. If the old config file exists, it will prefer that. Otherwise, it will create the parent directories for the XDG based config file.

@sbstp
Copy link
Owner

sbstp commented Aug 6, 2023

I knew about the XDG spec when I made the decision to put the config file there. I put it there to match what kubectl does. If recent versions of kubectl have started supporting the XDG spec, then maybe this change makes sense. But has kubectl changed where it stores the config?

A lot of tools like gcloud and k3d write the clusters' config files in ~/.kube/config by default too.

@triarius
Copy link
Author

triarius commented Aug 6, 2023

I guess there are two opinions I have:

  1. Tools should follow the XDG Spec
  2. Tools should store their config in their own directories

Let's ignore 1. for the present.

A lot of tools like gcloud and k3d write the clusters' config files in ~/.kube/config by default too.

That's fine. These tools are generating config for kubectl to use. Kubie's job is to choose between these configs, but Kubie has its own config, the ~/.kube/kubie.yaml.

Apart from this file, the config files in ~/.kube are not config for Kubie, but data that Kubie operates on. So I think it makes sense to separate them. I don't think Kubie should mix its own config with the cluster config used by kubectl. I would store it in a different directory, as the file, ~/.kubie/config.yaml.

Now if you add 1. to this position, you get:

Kubie should store its config in the directory $XDG_CONFIG_HOME/kubie/, which is what this PR does.

I don't think it follows from the fact that other tools in the Kubernetes ecosystem don't follow the XDG spec for their config, can Kubie must not either. I currently use AWS EKS, and through the setting of some environment variables for aws and kubectl, I've manage to eliminate the .kube directory from my homedir entirely, except for when I use Kubie. With the patch in this PR, however, Kubie plays nice with this setup too.

LMK what you think, I would like to get Kubie to work with this setup, open to hearing other ideas on how to do so too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants