paths

package
v3.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 5 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 home and the on-disk layout, ported from the platform config_dir logic. Resolution: $SSH_MANAGER_HOME (alias $SSH_MANAGER_CONFIG_DIR), else the OS-standard config dir + the "ssh-manager" folder ($XDG_CONFIG_HOME or ~/.config on Unix/macOS, %APPDATA% on Windows).

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 = "SSHMGR_DEV_ROOT"

DevRootEnv is the environment variable form of --dev-root.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir(get Getenv, cwd string) string

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

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
	// 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 real legacy dir worth migrating (a directory, not a symlink, not the standard home), or "". Mirrors facade._first_legacy_home.

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 pre-rename / pre-XDG home locations in priority order: the "sshmgr" sibling of the standard home (pre-rename OS-standard dir) and the original dot-home ~/.sshmgr. Mirrors facade._legacy_homes.

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

func (p Paths) SnapshotsDir() string

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