Documentation
¶
Overview ¶
Package lifecycle removes a profile or a key completely, as one guarded transaction.
Deleting used to mean editing the manifest and nothing else: key files stayed, the profile directory stayed, known_hosts kept pins for hosts that no longer existed, and ~/.ssh/config only caught up on the next reconcile - so the immediate result of "delete" was a tree doctor then reported as broken. This package finishes the job: manifest and inventory (via editor), then the rendered config, then reference-counted known_hosts pins, and finally the key files themselves - those last only under Purge, because a key file is the one thing here that cannot be reconstructed from the manifest.
The caller owns the lock, the snapshot and the encrypted backup (the CLI's mutation guard), the same way it does for keygen and rotate.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Purge removes the key files too, and the profile directory when nothing
// unmanaged is left in it.
Purge bool
// Revoke asks the provider adapters to remove the deployed public key from
// its targets first.
Revoke bool
}
Options are the destructive opt-ins. Both default off: a delete that only edits state is recoverable from the manifest plus the key files still on disk.
type Result ¶
type Result struct {
Removed string // "profile work" | "key work/work_gh-ed25519"
Revoked []string // targets the key was revoked from
PrunedRecords []string // inventory records dropped
RemovedFiles []string // key files deleted (Purge only)
RemovedDirs []string // directories deleted once empty (Purge only)
KeptFiles []string // key files deliberately left behind
UnmanagedLeft []string // directories left in place, holding files we did not create
ConfigWritten []string // config files re-rendered
PrunedPins int // known_hosts lines removed
// UnwiredKeys are keys the deletion left with no host, but which their
// profile still declares - so they remain sshmgr's, just unused.
UnwiredKeys []string
// VaultItems are 1Password items that held a deleted key. sshmgr never
// deletes a vault item; the user archives it.
VaultItems []string
// OrphanedKeys are keys the deletion removed from the manifest entirely,
// because nothing declared them and only the deleted host named them. Their
// files are still on disk and nothing tracks them any more.
OrphanedKeys []string
}
Result is what the transaction actually did.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs profile and key deletions against one home.
func New ¶
New builds a lifecycle service. emitUseKeychain matches the platform (macOS only), as everywhere else that renders config.
func (*Service) DeleteHost ¶
DeleteHost removes one host: its manifest entry, its Host block in the rendered config, and any known_hosts pin no remaining host needs.
Keys are not the host's to take - a key can outlive the host that used it - so what happens to the key it named depends on what the manifest says after the delete. Still used by another host: nothing to report. Still declared in the profile's keys list: UNWIRED, reported with the two ways out, files untouched even under Purge, because the profile still owns it. Neither: the key left the manifest along with the host, its files are now tracked by nothing, and Purge is what removes them.
func (*Service) DeleteKey ¶
DeleteKey removes one key: its declaration, its inventory record and, under Purge, its files. It refuses while a host still uses the key (see editor.DeleteKey) - the config would otherwise keep pointing at a file that no longer exists.
func (*Service) DeleteProfile ¶
DeleteProfile removes a profile and everything the manifest says belongs to it: its hosts, its keys' inventory records, its Host blocks in the rendered config, its hosts' known_hosts pins (only those no surviving host still needs) and, under Purge, its key files and directory.