Documentation
¶
Overview ¶
Package paths resolves the per-user directories and the on-disk layout.
Two roots, on every OS (Windows included - %USERPROFILE% is its ~):
config home $AUTHAMA_CONFIG_DIR, else $XDG_CONFIG_HOME/authama, else
~/.config/authama. What the user owns and edits: the
manifest, inventory, providers, tokens config, .env,
authama.json, the age identity.
state home $AUTHAMA_STATE_DIR, else $XDG_STATE_HOME/authama, else
~/.local/state/authama. What the tool writes for itself: the
history database and audit log (log/), snapshots, bundles
(dist/), the lock and caches (.state/).
When the config home is set explicitly ($AUTHAMA_CONFIG_DIR) and the state home is not, the state lives inside the config home, as it did before 0.1.1, so a pinned home stays self-contained. A --dev-root sandbox is likewise one tree.
The folders releases before 0.1.1 used, under the tool's earlier names, are found by LegacyHomes, so `authama migrate` can copy one into the authama home. Only migration looks there; nothing else reads or writes them.
Index ¶
- Constants
- Variables
- func ConfigDir(get Getenv, cwd string) string
- func ExportSelectionsDir(p Paths) string
- func SeparateState(p Paths) bool
- func StateRoot(get Getenv, cwd string) string
- func XDGConfigHome(get Getenv) string
- type Getenv
- type Paths
- func (p Paths) AgeIdentity() string
- func (p Paths) AuditLog() string
- func (p Paths) Contains(path string) bool
- func (p Paths) DistDir() string
- func (p Paths) EnvFile() string
- func (p Paths) ExpiryCache() string
- func (p Paths) FirstLegacyHome() string
- func (p Paths) HistoryDB() string
- func (p Paths) Home() string
- func (p Paths) Inventory() string
- func (p Paths) IsDev() bool
- func (p Paths) LegacyHomes() []string
- func (p Paths) LockFile() string
- func (p Paths) LogDir() string
- func (p Paths) Manifest() string
- func (p Paths) NotifyCache() string
- func (p Paths) Providers() string
- func (p Paths) RefuseOutsideSandbox(action string) error
- func (p Paths) SettingsFile() string
- func (p Paths) SnapshotsDir() string
- func (p Paths) State() string
- func (p Paths) StateDir() string
- func (p Paths) TokenHome(get Getenv) string
- func (p Paths) Tokens() string
Constants ¶
const ( DevSSHDir = "ssh" DevConfigDir = "config" // DevHomeDir stands in for $HOME for the token targets. DevHomeDir = "home" )
DevSSHDir and DevConfigDir are the fixed subdirectories a dev root is split into.
const DevRootEnv = envnames.DevRoot
DevRootEnv is the environment variable form of --dev-root.
const Folder = "authama"
Folder is the directory name under the config and state bases.
const LegacyFolder = "ssh-manager"
LegacyFolder is the config folder name releases before authama 0.1.1 used, as ssh-manager. Only LegacyHomes uses it, for migration.
const MigratedMarker = "MIGRATED-TO-AUTHAMA.txt"
MigratedMarker is written into a legacy home once its contents have been copied to the current one. The legacy folder is kept, but a marked folder is never offered for migration again and doctor does not call it stranded.
Variables ¶
var StateSubdirs = []string{"log", "snapshots", "dist", ".state"}
StateSubdirs are the state home's entries, by name. A config home from before 0.1.1 held them, and the migration moves them to a separate state home.
Functions ¶
func ConfigDir ¶
ConfigDir resolves the per-user config home. cwd is used to absolutize a relative override (pass "" to use the process cwd).
func ExportSelectionsDir ¶ added in v0.1.6
ExportSelectionsDir holds p's saved export selections, one <name>.json each. A folder of their own: exports/ also holds the file `config export --flat` writes. A function, not a method: Paths stays a list of locations under its method ceiling.
func SeparateState ¶ added in v0.1.1
SeparateState reports whether p's state home is not its config home. A function, not a method: Paths stays a list of locations.
func StateRoot ¶ added in v0.1.1
StateRoot resolves the state home for a config home: $AUTHAMA_STATE_DIR, else the config home itself when that was set explicitly, else $XDG_STATE_HOME/authama or ~/.local/state/authama.
func XDGConfigHome ¶ added in v0.1.6
XDGConfigHome is the user's base config directory, not authama's own folder in it: $XDG_CONFIG_HOME when it is absolute, else ~/.config, on every OS. It is where `ssh import ~/.config` looks for ssh/config.
Types ¶
type Paths ¶
type Paths struct {
SSHDir string
ConfigDir string
// StateRoot holds what the tool writes for itself (log/, snapshots/,
// dist/, .state/). Empty means ConfigDir: a Paths built by hand, as the
// preview copy and the tests do, keeps the single-tree layout.
StateRoot string
// DevRoot is the sandbox root when this layout came from --dev-root, and
// empty otherwise. Its presence is what every "am I sandboxed" check reads,
// so there is one answer rather than a comparison rebuilt per call site.
DevRoot string
}
Paths is the resolved on-disk layout for one invocation.
func ResolveDev ¶
ResolveDev builds the layout for a sandboxed run: one root, holding both the sandbox's ~/.ssh and its config home.
It is deliberately ONE root rather than two independent overrides. The config home already had an override ($AUTHAMA_CONFIG_DIR) and ~/.ssh had none, so the only way to test against a scratch tree was to move $HOME - which also moves the ssh-agent socket, the launchd session and everything else that reads it. Two knobs would allow the worse failure: a run with its config redirected and its keys still going to the real ~/.ssh, which looks sandboxed right up until it overwrites a key you use.
The root is created on demand by the caller; this only computes and checks it.
func (Paths) AgeIdentity ¶
func (Paths) Contains ¶
Contains reports whether path is at or below the sandbox root, after resolving symlinks in the part of path that exists. Outside dev mode every path qualifies.
func (Paths) ExpiryCache ¶
func (Paths) FirstLegacyHome ¶
FirstLegacyHome returns the first legacy home still worth migrating (a real directory, not a symlink, not the current home, not already marked as migrated), or "".
func (Paths) LegacyHomes ¶
LegacyHomes are the config homes releases before authama 0.1.1 used, newest first: the "ssh-manager" sibling of the config home (authama 0.1.0 and the ssh-manager releases), then on Windows %APPDATA%\ssh-manager (their Windows default), then the "sshmgr" sibling and %APPDATA%\sshmgr (before that rename), and the original dot-home ~/.sshmgr. authama never writes to them; migration reads the first one that exists and copies it into the authama home.
A sandbox has none outside its root: ~/.sshmgr is the real user's, and dev-mode `migrate` used to move it into the sandbox.
func (Paths) NotifyCache ¶
func (Paths) RefuseOutsideSandbox ¶
RefuseOutsideSandbox refuses, in dev mode, an action that takes effect on a server or account. Dev mode sandboxes files; it cannot sandbox a key installed on a real host or removed from one. It lives on Paths, and the services that reach targets (deploy, rotate, rollback, revoke) call it themselves, so no caller - a verb, the web UI, a future one - can skip it.
func (Paths) SettingsFile ¶ added in v0.1.1
SettingsFile is authama.json, the user's settings file.