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

cache: respect UserCacheDir convention #172

Merged
merged 1 commit into from
Dec 1, 2021
Merged

cache: respect UserCacheDir convention #172

merged 1 commit into from
Dec 1, 2021

Conversation

tgross
Copy link
Member

@tgross tgross commented Nov 22, 2021

The registry cache pollutes the user's home directory with a
~/.nomad directory. Desktop operating systems have platform-specific
conventions for placing cache directories (XDG standard on Unix,
~/Library/Caches on Darwin, %AppData% on Windows, etc.). Go
provides a os.UserCacheDir function that does the right thing for
the platform it's being called on.


We can't exactly unit test this change without messing up the test runner's home directory, but here's what it looks like after building locally on macOS:

$ nomad-pack registry list
...
$ ls ~/Library/Caches/nomad/packs/default
csi_openstack_cinder@latest     jenkins@latest                  prometheus_snmp_exporter@latest
drone@latest                    loki@latest                     promtail@latest
faasd@latest                    nginx@latest                    simple_service@latest
fabio@latest                    nomad_autoscaler@latest         tempo@latest
grafana@latest                  nomad_ingress_nginx@latest      tfc_agent@latest
haproxy@latest                  outline@latest                  traefik@latest
hello_world@latest              prometheus@latest               wordpress@latest
influxdb@latest                 prometheus_node_exporter@latest

The registry cache pollutes the user's home directory with a
`~/.nomad` directory. Desktop operating systems have platform-specific
conventions for placing cache directories (XDG standard on Unix,
`~/Library/Caches` on Darwin, `%AppData%` on Windows, etc.). Go
provides a `os.UserCacheDir` function that does the right thing for
the platform its being called on.
Copy link
Contributor

@DerekStrickland DerekStrickland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this suggested change a lot. We struggled with the "right" location, and opted ultimately for a .folder approach based on some other tool's convention, but even that confused some users. This seems very standard to me. I like it.

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.

2 participants