Skip to content

Split the config directory into config, state and cache per the XDG spec #98

Open

Description

@henryde

Today the CLI writes everything to $XDG_CONFIG_HOME/meshstack (or MESHSTACK_CONFIG_DIR), including tokens and cached API documents. These files get in the way if you want to back up or sync the config dir. You also have to be careful when clearing the cache so you don't destroy your profiles.

Proposed layout

File Directory Why
profiles.json, profiles.json.lock XDG_CONFIG_HOME/meshstack Actual configuration
credentials/<profile>.json XDG_CONFIG_HOME/meshstack Actual configuration
credentials-cache/<profile>/<credential>.json XDG_STATE_HOME/meshstack State because cache should be deletable without the user noticing
versionCheck.json XDG_STATE_HOME/meshstack Automatic timestamp
api-docs*.json, *.lastcheck.json XDG_CACHE_HOME/meshstack Cached, downloaded again when missing

Open questions

  • Overrides: add MESHSTACK_STATE_DIR and MESHSTACK_CACHE_DIR, each defaulting to its own XDG location rather than to a folder of the config dir.
  • Defaults: honor XDG_* on every OS, as the config dir does. When unset, cache uses os.UserCacheDir (~/.cache on Linux). Go has no state-dir function, so state falls back to ~/.local/state on Linux, as the XDG spec defines, and to a folder under the platform config dir on macOS (some tools use XDG locations as well here) and Windows.
  • Migration: deleting the old files would require users to login again, which happens anyway after token expiration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions