Skip to content

feat: add XDG_CACHE_HOME support to Go implementations#478

Merged
ahmetb merged 1 commit intomasterfrom
abalkan/xdg-cache-home
Mar 9, 2026
Merged

feat: add XDG_CACHE_HOME support to Go implementations#478
ahmetb merged 1 commit intomasterfrom
abalkan/xdg-cache-home

Conversation

@ahmetb
Copy link
Copy Markdown
Owner

@ahmetb ahmetb commented Mar 9, 2026

Summary

Adds a new CacheDir() function that respects the XDG_CACHE_HOME environment variable, matching the bash scripts' behavior. kubectx and kubens now prefer XDG_CACHE_HOME when set, falling back to $HOME/.kube otherwise.

Testing Done

Added comprehensive tests covering XDG_CACHE_HOME set, unset, and missing home directory scenarios. All existing tests pass.

Adds a new CacheDir() function that respects the XDG_CACHE_HOME environment variable,
matching the bash scripts' behavior. kubectx and kubens now prefer XDG_CACHE_HOME when
set, falling back to $HOME/.kube otherwise. This aligns the Go implementations with
the bash scripts' cache directory logic.

Includes comprehensive tests covering all scenarios:
- XDG_CACHE_HOME set (returns the XDG value)
- XDG_CACHE_HOME unset (falls back to $HOME/.kube)
- Neither set (returns empty string)
@ahmetb ahmetb marked this pull request as ready for review March 9, 2026 03:17
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 9, 2026
@ahmetb ahmetb merged commit d357673 into master Mar 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant