Documentation
¶
Overview ¶
Package paths resolves where configuration, state and logs live.
The same XDG-style layout is used on macOS and Linux so that the config file is easy to find and edit by hand: ~/.config/<id>/ and ~/.local/state/<id>/. On Linux XDG_CONFIG_HOME and XDG_STATE_HOME move them. On macOS they do not: the menu bar app and launchd never see a shell's XDG variables, so honoring them there would give the CLI another config, state directory, token and lock than the app. Earlier versions did honor them on macOS; MoveLegacy moves what they left there.
Index ¶
- Constants
- func ConfigFile() string
- func ConfigLockName(config string) string
- func DaemonLog() string
- func Default(cfgPath, stateDir string) bool
- func DefaultConfigFile() string
- func ExpandHome(p string) string
- func LockHeld(path string) bool
- func LogDir(stateDir string) string
- func MoveLegacy() []string
- func MoveLegacyForService(cfgPath string) (string, []string)
- func Restrict(cfgPath, stateDir string)
- func SamePath(a, b string) bool
- func ShortenHome(p string) string
- func StateDir() string
- func StopMarker() string
- func WriteFile(path string, data []byte) error
Constants ¶
const ( // DirMode is the mode of directories created for config and state. DirMode os.FileMode = 0o700 // FileMode is the mode of files written into them. FileMode os.FileMode = 0o600 )
The config can hold secrets in server environments and the logs can hold whatever a server prints, so both stay readable by the owner only.
const ( TokenName = "auth-token" // the API token DashboardHostName = "dashboard-host" // the dashboard's host name PortName = "daemon.port" // the port a running daemon serves LockName = "daemon.lock" // held by the running daemon TUIPrefsName = "tui.json" // the terminal UI's preferences )
Files in the state directory that the daemon writes and its clients read.
Variables ¶
This section is empty.
Functions ¶
func ConfigFile ¶
func ConfigFile() string
ConfigFile returns the path of the main configuration file.
func ConfigLockName ¶
ConfigLockName is the file next to the config file named config that serialises edits to it; it stays after an edit.
func Default ¶
Default reports whether cfgPath and stateDir are the default config file and state directory, as for the account's main daemon rather than an isolated instance.
func DefaultConfigFile ¶
func DefaultConfigFile() string
DefaultConfigFile is the config file used unless the config path is overridden.
func ExpandHome ¶
ExpandHome replaces a leading ~ and expands $VARS.
func LockHeld ¶ added in v0.10.1
LockHeld reports whether a daemon holds the lock file at path. The test takes a shared lock for a moment; a daemon starting meanwhile retries its own.
func MoveLegacy ¶
func MoveLegacy() []string
MoveLegacy moves, on macOS, a config file and state directory that an earlier version put under XDG_CONFIG_HOME or XDG_STATE_HOME to the default locations, which macOS uses regardless of those variables (see the package comment). It acts only when the variable is set, points elsewhere than the default, the old location holds the product's files and nothing else (see legacyLocation), the default one does not exist, and the location is not overridden. While a daemon still runs from the old state directory, the login service names an old location, or a move fails, this process uses the old locations instead. It returns one note per change, for the user. Commands run it before they read any location.
func MoveLegacyForService ¶
MoveLegacyForService is MoveLegacy for `service install`, run once any daemon has stopped: it moves the old locations even when the login service names them, because the service is written anew with the default ones next. It returns the config file to use instead of cfgPath, and the notes.
func Restrict ¶
func Restrict(cfgPath, stateDir string)
Restrict removes group and other access from the product's config and state.
The default config and state directories belong to the product, so they are tightened with everything in them. A config file elsewhere is tightened on its own, and a state directory elsewhere is tightened itself together with the product's files and logs in it; other files in such directories keep their modes. Parent directories such as ~/.config are left alone, and symlinks are not followed.
func SamePath ¶
SamePath reports whether a and b name the same location once symlinks in them are resolved.
func ShortenHome ¶
ShortenHome renders a path with the home directory replaced by ~.
func StateDir ¶
func StateDir() string
StateDir returns the directory for runtime state, logs and the lock file.
func StopMarker ¶
func StopMarker() string
StopMarker returns the file a deliberate daemon stop leaves behind; while it exists, background clients such as the menu bar app do not start a daemon.
Types ¶
This section is empty.