keysvc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 7 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 keysvc is the key-centric read layer: for every key the manifest owns, what is on disk for it, which hosts wire it, and where it is deployed. The query package answers the same questions host-first (list/view); this one is key-first, because a key can now outlive - or precede - any host that uses it.

It reports facts, not judgements: whether a file is there, whether a record covers it, which hosts name it. Deciding that some combination of those facts means a key is "dangling" belongs to one package so every command agrees, and that package is keyaudit, which reads these rows.

Read-only, and deliberately shallow on disk: it uses os.Lstat, so a symlink planted where a key should be reports as what it is rather than being followed, and it never reads private key material.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detail

type Detail struct {
	Row
	// DiskFingerprint is fingerprinted from the .pub actually on disk, which can
	// disagree with the recorded one after a key was regenerated outside sshmgr.
	// Empty when there is no .pub to read.
	DiskFingerprint string
	// FingerprintErr explains an unreadable or malformed .pub, rather than
	// letting it show as a blank fingerprint.
	FingerprintErr string
}

Detail is a Row plus what only reading the public key can answer.

func (Detail) Mismatched

func (d Detail) Mismatched() bool

Mismatched reports whether the key on disk is a different key from the one the inventory recorded - the state where deployments and expiry describe a key that no longer exists.

type Row

type Row struct {
	Ref             manifest.KeyRef
	Type            string // resolved: the declared override, else the default
	RotateAfterDays int
	Declared        bool // has an explicit keys[] entry (vs. implied by a host)
	IdentityFile    string
	PrivatePath     string
	PublicPath      string
	PrivateOnDisk   bool
	PublicOnDisk    bool
	PrivateMode     os.FileMode // zero when the file is absent
	PublicMode      os.FileMode
	Recorded        bool // an inventory record covers this key
	Fingerprint     string
	Created         string
	ExpiresOn       string
	Hosts           []string // aliases wiring this key, in manifest order
	// Vault is the 1Password vault holding the private key, "" for a key on
	// disk. When set, PrivatePath is never expected to exist.
	Vault       string
	Deployments []inventory.Deployment
	Status      string // query.NoKey | query.NeedsRedeploy | query.Deployed
}

Row is one key: what the manifest declares, what the inventory recorded, and what is actually on disk.

func (Row) InOnePassword

func (r Row) InOnePassword() bool

InOnePassword reports whether the private key lives in 1Password.

func (Row) Present

func (r Row) Present() bool

Present reports whether everything the key's store keeps on disk is there: both halves for a key on disk, the public half for a key in 1Password.

func (Row) Wired

func (r Row) Wired() bool

Wired reports whether any host references this key.

type Selection

type Selection struct {
	Selectors []string
	Category  string
	All       bool
}

Selection names the keys a bulk command acts on: some selectors (each a profile, host alias, key name or profile/key), every key in a category, or every key. All excludes the others, so "--all work" cannot quietly mean all.

type Service

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

Service answers key-centric questions about one ~/.ssh tree.

func New

func New(m *manifest.Manifest, inv *inventory.Inventory, sshDir string) *Service

New builds a key service over a manifest, its inventory, and ~/.ssh.

func (*Service) Detail

func (s *Service) Detail(ref manifest.KeyRef) (Detail, error)

Detail returns one key's row plus the fingerprint of its public key on disk. Only the public half is ever read.

func (*Service) Row

func (s *Service) Row(ref manifest.KeyRef) (Row, error)

Row returns the single row for one resolved key reference.

func (*Service) Rows

func (s *Service) Rows(selector string) ([]Row, error)

Rows returns one row per key the manifest owns, in KeyRefs order (profile in manifest order, host-derived keys before declared-only ones). selector filters by profile, host alias, key name, or the composite "profile/key" form; empty means every key. An unmatched selector is an error, so a typo never looks like an empty result.

func (*Service) Select

func (s *Service) Select(sel Selection) ([]Row, error)

Select resolves a Selection to rows, de-duplicated, in manifest order. A selector or category that matches nothing is an error, so a typo never reads as an empty batch, and an empty Selection is an error rather than "nothing".

Jump to

Keyboard shortcuts

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