Documentation
¶
Overview ¶
Package paths provides centralized path resolution for scafctl using the XDG Base Directory Specification (https://specifications.freedesktop.org/basedir/latest/).
This package uses the github.com/adrg/xdg library to provide cross-platform XDG-compliant paths for configuration, data, cache, and state files.
Directory Types ¶
The XDG specification defines several directory types:
- Config: User-specific configuration files (XDG_CONFIG_HOME)
- Data: User-specific data files (XDG_DATA_HOME)
- Cache: User-specific non-essential cached data (XDG_CACHE_HOME)
- State: User-specific state data like logs and history (XDG_STATE_HOME)
Platform Defaults ¶
When XDG environment variables are not set, platform-specific defaults are used:
Linux:
- Config: ~/.config/scafctl/
- Data: ~/.local/share/scafctl/
- Cache: ~/.cache/scafctl/
- State: ~/.local/state/scafctl/
macOS:
- Config: ~/Library/Application Support/scafctl/
- Data: ~/Library/Application Support/scafctl/
- Cache: ~/Library/Caches/scafctl/
- State: ~/Library/Application Support/scafctl/
Windows:
- Config: %LOCALAPPDATA%\scafctl\
- Data: %LOCALAPPDATA%\scafctl\
- Cache: %LOCALAPPDATA%\cache\scafctl\
- State: %LOCALAPPDATA%\scafctl\
Environment Variable Overrides ¶
All XDG environment variables are respected:
- XDG_CONFIG_HOME
- XDG_DATA_HOME
- XDG_CACHE_HOME
- XDG_STATE_HOME
Additionally, SCAFCTL_SECRETS_DIR can override the secrets directory location.
Index ¶
- Constants
- func CacheDir() string
- func CatalogDir() string
- func ConfigDir() string
- func ConfigFile() (string, error)
- func DataDir() string
- func HTTPCacheDir() string
- func RuntimeDir() string
- func SearchConfigFile() (string, error)
- func SecretsDir() (string, error)
- func SecretsDirPath() string
- func StateDir() string
Constants ¶
const ( // AppName is the application name used in XDG paths. AppName = "scafctl" // ConfigFileName is the default config file name. ConfigFileName = "config.yaml" // SecretsDirName is the name of the secrets subdirectory. SecretsDirName = "secrets" // HTTPCacheDirName is the name of the HTTP cache subdirectory. HTTPCacheDirName = "http-cache" // CatalogDirName is the name of the catalog subdirectory. CatalogDirName = "catalog" )
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
func CacheDir() string
CacheDir returns the path to the cache directory.
Returns: $XDG_CACHE_HOME/scafctl/
func CatalogDir ¶
func CatalogDir() string
CatalogDir returns the default path to the local catalog directory.
Returns: $XDG_DATA_HOME/scafctl/catalog/
Platform defaults:
- Linux: ~/.local/share/scafctl/catalog/
- macOS: ~/Library/Application Support/scafctl/catalog/
- Windows: %LOCALAPPDATA%\scafctl\catalog\
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the path to the config directory.
Returns: $XDG_CONFIG_HOME/scafctl/
func ConfigFile ¶
ConfigFile returns the path to the config file. Creates parent directories if they don't exist.
Returns: $XDG_CONFIG_HOME/scafctl/config.yaml
Platform defaults:
- Linux: ~/.config/scafctl/config.yaml
- macOS: ~/Library/Application Support/scafctl/config.yaml
- Windows: %LOCALAPPDATA%\scafctl\config.yaml
func DataDir ¶
func DataDir() string
DataDir returns the path to the data directory.
Returns: $XDG_DATA_HOME/scafctl/
func HTTPCacheDir ¶
func HTTPCacheDir() string
HTTPCacheDir returns the path to the HTTP cache directory.
Returns: $XDG_CACHE_HOME/scafctl/http-cache/
Platform defaults:
- Linux: ~/.cache/scafctl/http-cache/
- macOS: ~/Library/Caches/scafctl/http-cache/
- Windows: %LOCALAPPDATA%\cache\scafctl\http-cache\
func RuntimeDir ¶
func RuntimeDir() string
RuntimeDir returns the path to the runtime directory. Used for sockets, pipes, and other runtime files.
Returns: $XDG_RUNTIME_DIR/scafctl/
func SearchConfigFile ¶
SearchConfigFile searches for the config file in XDG config paths. Does not create any directories.
Search order:
- $XDG_CONFIG_HOME/scafctl/config.yaml
- $XDG_CONFIG_DIRS/scafctl/config.yaml (each directory in order)
func SecretsDir ¶
SecretsDir returns the path to the secrets directory. Creates parent directories if they don't exist.
Returns: $XDG_DATA_HOME/scafctl/secrets/
Platform defaults:
- Linux: ~/.local/share/scafctl/secrets/
- macOS: ~/Library/Application Support/scafctl/secrets/
- Windows: %LOCALAPPDATA%\scafctl\secrets\
Note: Secrets are stored in DATA_HOME (not CONFIG_HOME) because they are user-specific data that should persist, not configuration settings.
func SecretsDirPath ¶
func SecretsDirPath() string
SecretsDirPath returns the secrets directory path without creating it.
Returns: $XDG_DATA_HOME/scafctl/secrets/
Types ¶
This section is empty.