Documentation
¶
Overview ¶
Package manifest is the authama manifest domain model. The manifest is the single source of truth; this package loads/validates it and exposes the per-host key resolution the renderer and reconciler depend on (per_service default, shared opt-in).
Index ¶
- Constants
- Variables
- func CategoryConfigFile(category string) string
- func CategoryConfigRel(category string) string
- func GlobProfileTree(sshDir string, tail ...string) []string
- func IsBuiltinHypervisor(name string) bool
- func IsDangerousOption(key string) bool
- func KeyComment(m *Manifest, ref KeyRef, alias, date string) string
- func KeyCommentTemplate(m *Manifest, profile string) string
- func KnownHypervisors() []string
- func ManagedHostOption(key string) (useInstead string, ok bool)
- func ProfileForOwner(m *Manifest, owner string) (string, error)
- func RawOptionOverlaps(m *Manifest) []string
- func SetCustomHypervisors(names []string)
- func UsesOnePassword(m *Manifest) bool
- func ValidateHost(profile string, h Host) error
- type Defaults
- type ExpiryCheck
- type GitDefaults
- type Host
- type KeyRef
- type KeySpec
- type Manifest
- func (m *Manifest) Categories() []string
- func (m *Manifest) DeleteProfile(name string)
- func (m *Manifest) HostsForKey(ref KeyRef) ([]Host, error)
- func (m *Manifest) IdentityFile(profileName, keyName string) string
- func (m *Manifest) IterResolved() ([]ResolvedKey, error)
- func (m *Manifest) KeyPath(sshDir string, ref KeyRef) string
- func (m *Manifest) KeyRefs() ([]KeyRef, error)
- func (m *Manifest) KeySpecFor(ref KeyRef) (KeySpec, bool)
- func (m *Manifest) KeyTypeFor(ref KeyRef) string
- func (m *Manifest) KnownHostsFile() string
- func (m Manifest) MarshalJSON() ([]byte, error)
- func (m *Manifest) NonEmptyProfiles() []string
- func (m *Manifest) ProfileDir(sshDir, profileName string) string
- func (m *Manifest) ProfileNames() []string
- func (m *Manifest) ProfileRel(profileName string) string
- func (m *Manifest) ResolveKeySelector(selector string) (KeyRef, error)
- func (m *Manifest) ResolvedKeyName(profileName string, host Host) (string, error)
- func (m *Manifest) RotateAfterDaysFor(ref KeyRef) int
- func (m *Manifest) Save(path string) error
- func (m *Manifest) SetProfile(name string, p Profile)
- func (m *Manifest) UnmarshalJSON(b []byte) error
- func (m *Manifest) Validate() error
- type OrderedOptions
- type Profile
- type ProxySpec
- type ResolvedKey
- type VMSpec
Constants ¶
const ( GitModeProfile = "profile" GitModeSSH = "ssh" GitModeHTTPS = "https" )
Git remote modes. A checkout's origin points at GitHub one of three ways: through a profile's own SSH alias (git@github-<profile>:owner/repo.git), through plain SSH to github.com (the key bound to the rendered `Host github.com`), or over HTTPS (the gh-app credential helper).
const ( HypervisorParallels = "parallels" HypervisorVMPal = "vmpal" HypervisorVMware = "vmware" HypervisorUTM = "utm" HypervisorLima = "lima" HypervisorOrbStack = "orbstack" HypervisorPodman = "podman" )
Hypervisors authama can resolve a devbox's address through.
const ( KeyStoreFile = "file" KeyStoreOnePassword = "1password" )
Key stores. The empty string is the file store, so it never has to be written; anything else must be named here, because a typo would otherwise silently fall back to looking for private keys on disk.
const DefaultKeyComment = "{profile}/{alias} {date}"
DefaultKeyComment is the comment authama writes when neither the profile nor the defaults set key_comment: the one every release before key_comment wrote.
const ProxyCloudflared = "cloudflared"
ProxyCloudflared reaches a host through Cloudflare Access: ssh runs `cloudflared access ssh --hostname %h`, which opens the tunnel after a browser sign-in, so no SSH port has to be open to the internet.
Variables ¶
var DefaultGlobalOptions = map[string]string{
"AddKeysToAgent": "yes", "IgnoreUnknown": "UseKeychain", "UseKeychain": "yes",
"IdentitiesOnly": "yes", "ServerAliveInterval": "60",
}
DefaultGlobalOptions are the canonical Host* defaults used by Starter.
var GitModes = []string{GitModeProfile, GitModeSSH, GitModeHTTPS}
GitModes lists the modes in the order they are documented.
var Hypervisors = []string{HypervisorParallels, HypervisorVMPal, HypervisorVMware, HypervisorUTM, HypervisorLima, HypervisorOrbStack, HypervisorPodman}
Hypervisors lists the built-in hypervisors.
var ProxyKinds = []string{ProxyCloudflared}
ProxyKinds are the proxies authama can render. raw_options may not set a ProxyCommand (it would run any command ssh is given), so each supported proxy is a field authama writes itself, as it does for VM hosts.
Functions ¶
func CategoryConfigFile ¶
CategoryConfigFile is the ~ form path the root config Includes for a category, matching how IdentityFile paths render.
func CategoryConfigRel ¶
CategoryConfigRel is the forward-slash path, relative to ~/.ssh, of the file holding a category's Host blocks.
func GlobProfileTree ¶
GlobProfileTree matches the pattern tail inside every profile directory on disk, in both layouts: profiles/<profile>/<tail> and profiles/<category>/<profile>/<tail>. It needs no manifest, because the scans that use it (doctor, snapshots, keyaudit) also look for what the manifest has forgotten.
A two-level match whose middle segment is "old" or dot-prefixed is dropped: that is a flat profile's rotation archive or staging directory, not a categorized profile, and a flat-only glob never saw inside them either. The result is sorted.
func IsBuiltinHypervisor ¶ added in v0.1.3
IsBuiltinHypervisor reports whether name is one of the built-in drivers.
func IsDangerousOption ¶
IsDangerousOption reports whether an SSH option key can execute commands / pull in config (dropped on import, rejected by validation). Case-insensitive.
func KeyComment ¶
KeyComment expands the profile's key_comment for one key. alias is the host the key serves (callers pass the key name for an unwired key) and date the mint day.
func KeyCommentTemplate ¶
KeyCommentTemplate resolves the key_comment template for a profile: the profile's own, else the defaults', else DefaultKeyComment. It and KeyComment are functions, not Manifest methods, to keep that type from regrowing into a facade (cmd/authama's layering test caps its method count).
func KnownHypervisors ¶ added in v0.1.3
func KnownHypervisors() []string
KnownHypervisors is the built-in hypervisors followed by the custom ones.
func ManagedHostOption ¶
ManagedHostOption reports whether a raw_options key duplicates a line the renderer writes for every host, and what to set instead. Case-insensitive, as ssh reads keywords.
func ProfileForOwner ¶
ProfileForOwner picks the profile a GitHub owner uses: Orgs, then Profile, then the only profile with a GitHub host. It fails rather than guess between several.
func RawOptionOverlaps ¶
RawOptionOverlaps lists, as "profile/alias: ..." lines in manifest order, each raw_options key that duplicates a managed line. The renderer emits only the managed value (bar a raw Port at the default port), so these keys read as if they applied when they do not.
func SetCustomHypervisors ¶ added in v0.1.3
func SetCustomHypervisors(names []string)
SetCustomHypervisors replaces the registered custom hypervisor names.
func UsesOnePassword ¶
UsesOnePassword reports whether any profile keeps its keys in 1Password. A function rather than a method: Manifest carries a method ceiling (see TestNoTypeHasBecomeTheFacadeAgain), and this needs nothing private.
func ValidateHost ¶
ValidateHost reports whether one host of the named profile would pass the manifest's validation, so a caller assembling hosts (import) can leave out the one that fails rather than the whole batch.
Types ¶
type Defaults ¶
type Defaults struct {
KeyType string `json:"key_type"`
KeyScope string `json:"key_scope"`
RotateAfterDays int `json:"rotate_after_days"`
WarnBeforeDays []int `json:"warn_before_days"`
ExpiryCheck ExpiryCheck `json:"expiry_check"`
GlobalOptions OrderedOptions `json:"global_options"`
// OnePasswordAgent overrides the 1Password SSH agent socket a profile with
// key_store "1password" renders as its IdentityAgent. Empty = the
// platform's standard path (see OnePasswordAgentSocket).
OnePasswordAgent string `json:"onepassword_agent,omitempty"`
// KeyComment is the ssh-keygen -C template every profile inherits; empty
// means DefaultKeyComment.
KeyComment string `json:"key_comment,omitempty"`
// Git configures `authama ssh git` and the rendered `Host github.com` block.
Git *GitDefaults `json:"git,omitempty"`
}
Defaults are manifest-wide defaults.
func (Defaults) MarshalJSON ¶
MarshalJSON emits warn_before_days as [] when empty (not null) and global_options as {} via OrderedOptions, in declaration order.
func (Defaults) OnePasswordAgentSocket ¶
OnePasswordAgentSocket is the IdentityAgent a 1Password profile renders: the defaults override when set, else the platform's standard socket (checked against 1password.dev/ssh/get-started, 2026-10-19). "" on Windows, where Microsoft OpenSSH talks to one fixed pipe and per-host agents do not apply.
func (*Defaults) UnmarshalJSON ¶
type ExpiryCheck ¶
type ExpiryCheck struct {
Enabled bool `json:"enabled"`
DebounceHours int `json:"debounce_hours"`
DesktopNotify bool `json:"desktop_notify"`
}
ExpiryCheck is the notifier policy.
func (*ExpiryCheck) UnmarshalJSON ¶
func (e *ExpiryCheck) UnmarshalJSON(b []byte) error
type GitDefaults ¶
type GitDefaults struct {
// Mode is the default remote mode; empty means profile.
Mode string `json:"mode,omitempty"`
// Profile is the default identity: its GitHub key is bound to `Host github.com`
// (ssh mode), and it is used for an owner Orgs does not list.
Profile string `json:"profile,omitempty"`
// Orgs maps a GitHub owner to the profile whose key it uses.
Orgs map[string]string `json:"orgs,omitempty"`
}
GitDefaults configures `authama ssh git`. Absent, the mode is profile and no `Host github.com` block is rendered, so a manifest without it renders as before.
func (*GitDefaults) EffectiveMode ¶
func (g *GitDefaults) EffectiveMode() string
EffectiveMode is Mode, or profile when unset.
type Host ¶
type Host struct {
Alias string `json:"alias"`
Hostname string `json:"hostname"`
User string `json:"user"`
Port int `json:"port"`
Provider *string `json:"provider,omitempty"`
TokenEnv *string `json:"token_env,omitempty"`
KeyName *string `json:"key_name,omitempty"`
Tags []string `json:"tags,omitempty"`
RequiresVPN bool `json:"requires_vpn"`
VPNName *string `json:"vpn_name,omitempty"`
VPNURL *string `json:"vpn_url,omitempty"`
RawOptions OrderedOptions `json:"raw_options,omitempty"`
// VM marks a local VM whose address the hypervisor supplies at connect time.
VM *VMSpec `json:"vm,omitempty"`
// Proxy routes connections through a proxy command, e.g. Cloudflare Access.
Proxy *ProxySpec `json:"proxy,omitempty"`
}
Host is a single SSH host entry.
func GitHubHostOf ¶
GitHubHostOf returns the profile's GitHub host: the first one whose hostname is github.com. A profile with none has no profile-mode alias.
func (Host) MarshalJSON ¶
MarshalJSON emits every field in declaration order (null for unset pointers, [] for no tags), matching the files v1 and v2 wrote. raw_options serializes {} when empty via OrderedOptions.
func (*Host) UnmarshalJSON ¶
type KeyRef ¶
KeyRef names one key: the profile that owns it plus the file name inside that profile's directory. Key names are unique per profile, not globally - a person working under two orgs uses the same file name in both profile directories.
type KeySpec ¶
type KeySpec struct {
Name string `json:"name"`
// Unset (rather than defaulted-on-load) so re-saving a manifest does not
// bake today's defaults into every key, freezing them against a later
// change to defaults.key_type / defaults.rotate_after_days.
Type *string `json:"type,omitempty"`
RotateAfterDays *int `json:"rotate_after_days,omitempty"`
}
KeySpec declares a key as a first-class member of its profile, independent of any host that uses it. Type and rotate_after_days are optional and inherit the manifest defaults when unset (see KeyTypeFor / RotateAfterDaysFor).
Declaring is optional in both directions: a host whose key_name names a key absent from the list still implicitly declares it, so every pre-`keys` manifest loads and renders unchanged. The list exists so a profile can own a key no host references yet - a second identity for the same org, or a key minted ahead of the host it will serve - which previously could not be expressed at all, since a key existed only as a property of a host.
func (*KeySpec) UnmarshalJSON ¶
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
Defaults Defaults `json:"defaults"`
Profiles map[string]Profile `json:"profiles"`
// contains filtered or unexported fields
}
Manifest is the whole manifest.
func Starter ¶
Starter returns a minimal valid manifest for `authama init` - defaults and no profiles. Off macOS, the UseKeychain option is dropped. Mirrors Manifest.starter.
func (*Manifest) Categories ¶
Categories returns the distinct categories in use, in first-seen manifest (file) order, so the root config Includes them in a stable order.
func (*Manifest) DeleteProfile ¶
DeleteProfile removes a profile and its order entry.
func (*Manifest) HostsForKey ¶
HostsForKey returns the hosts that use one key, scoped to its own profile.
func (*Manifest) IdentityFile ¶
IdentityFile is the rendered ~ form path for a key (always forward slashes). It names the private key. For a 1Password profile the private key is never on disk, so the renderer points ssh at its .pub instead; inventory records and every other caller keep this one, so a key has the same identity in both stores.
func (*Manifest) IterResolved ¶
func (m *Manifest) IterResolved() ([]ResolvedKey, error)
IterResolved returns every host with its resolved key, in manifest (file) order - the order v1 resolved them in. Order is observable in order-preserving consumers like doctor's unpinned-host list; the rendered config is order-independent (the root config uses Include).
func (*Manifest) KeyRefs ¶
KeyRefs lists every distinct key in the manifest - the union of the keys each profile declares and the keys its hosts resolve to - deduplicated per profile so that hosts sharing one key yield a single ref. Refs are grouped by profile in manifest (file) order; within a profile, host-derived keys come first in host order, then any declared key no host uses.
The union is what makes a declared key real: it has no Host block, so walking IterResolved alone (which iterates hosts) leaves it invisible to reconcile, validate, doctor, list and expiry - present in the manifest, never minted, never checked.
func (*Manifest) KeySpecFor ¶
KeySpecFor returns the profile's declaration for one key, if it has one. A key that only exists because a host names it has no spec and inherits every default.
func (*Manifest) KeyTypeFor ¶
KeyTypeFor resolves the algorithm to mint a key with: the declared type when the profile declares one, else the manifest default.
func (*Manifest) KnownHostsFile ¶
KnownHostsFile is the single, user-wide host-key trust store path. Every rendered host block points at this same file: splitting it per profile gave up cross-profile duplicate detection for no isolation ssh itself enforces (any profile's ssh invocation can read any other profile's known_hosts), so there is exactly one store, tagged and reference-counted per line instead of separated by directory.
func (Manifest) MarshalJSON ¶
MarshalJSON emits {version, defaults, profiles} with profiles in manifest (file) order - a Go map would otherwise marshal its keys sorted. Compact output; Save re-indents it to two spaces, the indentation those files used.
func (*Manifest) NonEmptyProfiles ¶
NonEmptyProfiles lists profiles that have at least one host, in manifest (file) order - the order v1 listed non-empty profiles in.
func (*Manifest) ProfileDir ¶
ProfileDir is ProfileRel as an absolute path under sshDir.
func (*Manifest) ProfileNames ¶
ProfileNames returns profile names in manifest (file) order. Falls back to name order for a programmatically built manifest with no captured order.
func (*Manifest) ProfileRel ¶
ProfileRel is a profile's key directory relative to ~/.ssh, in forward-slash form: profiles/<category>/<profile> when the profile has a category, else profiles/<profile>. An undeclared profile resolves to the flat form, which is where every key lived before categories existed.
This is the one place the layout is decided. Every path to a key, its .pub, or its old/ directory goes through ProfileRel or ProfileDir; a hand-built filepath.Join(sshDir, "profiles", profile) is the defect a categorized profile exposes, because it silently points one directory too high.
func (*Manifest) ResolveKeySelector ¶
ResolveKeySelector turns a user-supplied key selector into a single KeyRef. It accepts the composite "profile/key" form, or a bare key name when exactly one profile uses it. A bare name matched by several profiles is an error listing the candidates, because the caller would otherwise operate on one profile's files while touching another's hosts.
func (*Manifest) ResolvedKeyName ¶
ResolvedKeyName resolves a host's key name (per_service derives it; shared uses the profile key_name).
func (*Manifest) RotateAfterDaysFor ¶
RotateAfterDaysFor resolves a key's rotation interval the same way.
func (*Manifest) Save ¶
Save writes the manifest as indented JSON, atomically.
Via a temp file and a rename, not os.WriteFile: WriteFile truncates the target first, so a crash or a full disk mid-write leaves a truncated manifest - and the manifest is the only description of every profile, host and key, with nothing to rebuild it from. It also keeps whatever mode the file already had, while this re-asserts 0600 on every write.
func (*Manifest) SetProfile ¶
SetProfile adds or replaces a profile, preserving file order (a new profile is appended, as v1 did).
func (*Manifest) UnmarshalJSON ¶
type OrderedOptions ¶
type OrderedOptions struct {
// contains filtered or unexported fields
}
OrderedOptions is an SSH-option map that preserves JSON key order (the renderer emits options in that order) and stringifies values the way v1 did.
func NewOrderedOptions ¶
func NewOrderedOptions(pairs [][2]string) OrderedOptions
NewOrderedOptions builds an OrderedOptions from ordered key/value pairs (later duplicates overwrite the value but keep the first position).
func (OrderedOptions) Get ¶
func (o OrderedOptions) Get(k string) string
func (OrderedOptions) Keys ¶
func (o OrderedOptions) Keys() []string
func (OrderedOptions) Len ¶
func (o OrderedOptions) Len() int
Len, Keys, and Get expose the options in order.
func (OrderedOptions) MarshalJSON ¶
func (o OrderedOptions) MarshalJSON() ([]byte, error)
MarshalJSON emits the options in their preserved order.
func (*OrderedOptions) UnmarshalJSON ¶
func (o *OrderedOptions) UnmarshalJSON(b []byte) error
type Profile ¶
type Profile struct {
Category string `json:"category,omitempty"`
KeyStore string `json:"key_store,omitempty"`
OPVault string `json:"op_vault,omitempty"`
KeyScope string `json:"key_scope"`
KeyName *string `json:"key_name,omitempty"`
// KeyComment is the ssh-keygen -C template for keys minted in this
// profile; empty inherits defaults.key_comment (see KeyCommentTemplate).
KeyComment string `json:"key_comment,omitempty"`
Keys []KeySpec `json:"keys,omitempty"`
Hosts []Host `json:"hosts"`
}
Profile groups hosts that share an identity, plus the keys it owns.
Category optionally files the profile under a grouping directory - profiles/<category>/<profile>/ instead of profiles/<profile>/ - and moves its Host blocks out of the root config into profiles/<category>/config, which the root config Includes. Empty keeps the flat layout and inline rendering, so a manifest written before categories existed behaves exactly as it did.
KeyStore says where the profile's private keys live: "file" (the default, written as an omitted field) keeps them under ~/.ssh; "1password" keeps them as SSH Key items in OPVault, with only the public half on disk.
func (Profile) InOnePassword ¶
InOnePassword reports whether the profile keeps its private keys in 1Password.
func (Profile) MarshalJSON ¶
MarshalJSON emits key_scope, key_name (null when unset), and hosts ([] when none) in declaration order, matching those files. category and keys are emitted only when set: both are v2 additions with no counterpart there, and omitting them keeps a manifest that uses neither - i.e. every manifest written before these fields existed - byte-identical across a load/save cycle.
func (*Profile) UnmarshalJSON ¶
type ProxySpec ¶
type ProxySpec struct {
Kind string `json:"kind"`
}
ProxySpec routes a host's connections through a proxy command.
type ResolvedKey ¶
ResolvedKey pairs a host with its resolved key name + IdentityFile path.