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

Adhere to XDG's configuration specification #1320

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

torrca
Copy link
Contributor

@torrca torrca commented Jul 16, 2023

What

This patch set makes 3 changes:

  • Ensure the DefaultConfigDirName constant is used when creating the config directory;
  • Set the DefaultConfigDirName constant to the XDG default path for configuration;
  • Make the function GetConfigDirOrCreate check the environment variable XDG_CONFIG_HOME before using the default value;

Why

Standardization, organization and customization.

Implications

This change makes the program more predictable, as most Unix tooling already uses the paths from the specification. Furthermore, it makes it more customizable, since the configuration path can be changed through a mere env var.

K3d places default configuration values in the 'types' pkg, including
the configuration directory. However, that value wasn't being used.

This commit replaces the hardcoded ".k3d" string on the
'GetConfigDirOrCreate' function by the default value in the constant
'DefaultConfigDirName'.

Signed-off-by: Carlos Torres <torr.ca@mailgw.com>
So far K3d has been creating the '.k3d' directory on the user's 'HOME'
directory, which isn't the ideal place for configuration and violates
the XDG base directory specification.

This commit aligns the configuration persistency with the XDG spec,
making the 'GetConfigDirOrCreate' function obtain the config dir
from the 'XDG_CONFIG_HOME' environment variable, falling back to the
'~/.config/k3d' default path in case the former is not set.

Signed-off-by: Carlos Torres <torr.ca@mailgw.com>
@iwilltry42
Copy link
Member

I wonder if we should do an automatic migration of files on first run 🤔

@iwilltry42 iwilltry42 merged commit 14c5358 into k3d-io:main Aug 3, 2023
1 check passed
@iwilltry42
Copy link
Member

Thank you very much @torrca !

tesla59 pushed a commit to tesla59/k3d that referenced this pull request Aug 10, 2023
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