lifecycle

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 12 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 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 authama's, just unused.
	UnwiredKeys []string
	// VaultItems are 1Password items that held a deleted key. authama 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.

func (Result) Format

func (r Result) Format() string

Format renders the human-readable summary.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service performs profile and key deletions against one home.

func New

func New(p paths.Paths, emitUseKeychain bool) *Service

New builds a lifecycle service. emitUseKeychain matches the platform (macOS only), as everywhere else that renders config.

func (*Service) DeleteHost

func (s *Service) DeleteHost(profile, alias string, opt Options) (Result, error)

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

func (s *Service) DeleteKey(ref manifest.KeyRef, opt Options) (Result, error)

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

func (s *Service) DeleteProfile(name string, opt Options) (Result, error)

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.

Jump to

Keyboard shortcuts

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