paths

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 or a legacy spelling) 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 legacy variables $SSH_MANAGER_HOME and $SSH_MANAGER_CONFIG_DIR are still honored (see envnames); the folders earlier releases used (~/.config/ ssh-manager, %APPDATA%\ssh-manager, ~/.config/sshmgr, ~/.sshmgr) are found by LegacyHomes for the one-time migration.

Index

Constants

View Source
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.

View Source
const DevRootEnv = envnames.DevRoot

DevRootEnv is the environment variable form of --dev-root. Its pre-0.1.1 spelling, SSHMGR_DEV_ROOT, is still read (envnames.Legacy).

View Source
const Folder = "authama"

Folder is the directory name under the config and state bases.

View Source
const LegacyFolder = "ssh-manager"

LegacyFolder is the config folder name releases before 0.1.1 used.

View Source
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

View Source
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

func ConfigDir(get Getenv, cwd string) string

ConfigDir resolves the per-user config home. cwd is used to absolutize a relative override (pass "" to use the process cwd).

func SeparateState added in v0.1.1

func SeparateState(p Paths) bool

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

func StateRoot(get Getenv, cwd string) string

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.

Types

type Getenv

type Getenv func(string) string

Getenv is an env lookup, injectable for tests. nil means os.Getenv.

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 Resolve

func Resolve(get Getenv, cwd, sshDir string) Paths

Resolve builds the Paths bundle. sshDir "" defaults to ~/.ssh.

func ResolveDev

func ResolveDev(get Getenv, cwd, devRoot string) (Paths, error)

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 ($SSH_MANAGER_HOME) 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 (p Paths) AgeIdentity() string

func (Paths) AuditLog

func (p Paths) AuditLog() string

func (Paths) Contains

func (p Paths) Contains(path string) bool

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) DistDir

func (p Paths) DistDir() string

func (Paths) EnvFile

func (p Paths) EnvFile() string

func (Paths) ExpiryCache

func (p Paths) ExpiryCache() string

func (Paths) FirstLegacyHome

func (p Paths) FirstLegacyHome() string

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) HistoryDB

func (p Paths) HistoryDB() string

func (Paths) Home

func (p Paths) Home() string

func (Paths) Inventory

func (p Paths) Inventory() string

func (Paths) IsDev

func (p Paths) IsDev() bool

IsDev reports whether this layout is a sandbox.

func (Paths) LegacyHomes

func (p Paths) LegacyHomes() []string

LegacyHomes are the homes earlier releases used, newest first: the "ssh-manager" sibling of the config home (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.

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) LockFile

func (p Paths) LockFile() string

func (Paths) LogDir

func (p Paths) LogDir() string

func (Paths) Manifest

func (p Paths) Manifest() string

func (Paths) NotifyCache

func (p Paths) NotifyCache() string

func (Paths) Providers

func (p Paths) Providers() string

func (Paths) RefuseOutsideSandbox

func (p Paths) RefuseOutsideSandbox(action string) error

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 TUI, a future one - can skip it.

func (Paths) SettingsFile added in v0.1.1

func (p Paths) SettingsFile() string

SettingsFile is authama.json, the user's settings file.

func (Paths) SnapshotsDir

func (p Paths) SnapshotsDir() string

func (Paths) State added in v0.1.1

func (p Paths) State() string

State is the effective state home.

func (Paths) StateDir

func (p Paths) StateDir() string

func (Paths) TokenHome

func (p Paths) TokenHome(get Getenv) string

TokenHome is the directory the token targets (~/.npmrc, ~/.docker, ...) resolve under: the real home, or in dev mode the sandbox's "home" subtree, so a sandboxed token write can never reach a real credential file.

func (Paths) Tokens

func (p Paths) Tokens() string

Tokens is the token config: which env vars build which registry credential. It holds variable names, never secrets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL