Help us shape the future of Go! Take the 2026 Go Developer Survey

inventory

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package inventory owns host facts and static loading. The static loader also implements the independent directory.Directory user lookup interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

type Host struct {
	Names    []string
	Labels   map[string]string
	Accounts []string
}

Host contains authorization attributes, separate from principal metadata.

type Hosts

type Hosts interface {
	LookupHost(context.Context, string) (*ResolvedHost, error)
}

Hosts resolves machines independently of the user directory.

type PrincipalMode

type PrincipalMode string

PrincipalMode selects how an allowed account@host tuple is represented in an issued SSH certificate.

const (
	// AccountNamePrincipals places the literal requested account name in the
	// certificate. It is compatible with ordinary OpenSSH CA configuration but
	// is not destination-bound.
	AccountNamePrincipals PrincipalMode = "account-name"

	// EpithetPrincipalV1 derives a destination-bound v1 principal from the
	// principal domain and requested account name.
	EpithetPrincipalV1 PrincipalMode = principal.SchemeV1
)

func (PrincipalMode) Effective

func (m PrincipalMode) Effective() PrincipalMode

Effective returns the concrete mode represented by m.

func (PrincipalMode) Validate

func (m PrincipalMode) Validate() error

Validate rejects unknown non-empty principal modes. Empty is the zero-value spelling of AccountNamePrincipals for compatibility with custom inventory implementations constructed in Go.

type ResolvedHost

type ResolvedHost struct {
	Policy        Host
	PrincipalMode PrincipalMode
	Domain        principal.Domain
}

ResolvedHost carries both the authorization resource consumed by Writ and issuance metadata that must remain outside the pure policy model. For a shared named domain, Policy.Names contains only the domain rather than individual DNS names because the resulting credential is portable across every member.

type Static

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

Static is a file-backed inventory: directory users and hosts loaded once at startup. Reload is a process restart, like the policy itself.

Host entries come in two forms. An exact entry (`names:`) is one registered host. A pattern entry (`pattern:`) uses the same DNS-label-aware hostname patterns as Writ host selectors. Exact entries expose all their names; pattern entries adopt the requested name. Destination-bound named domains expose that domain as the Writ resource so policy cannot claim per-member isolation. Patterns are the escape hatch for fleets of short-lived hosts (VM pools, CI runners) that follow a naming pattern but cannot be enumerated in a file.

func NewStatic

func NewStatic(paths []string, options ...StaticOption) (*Static, error)

NewStatic loads an inventory from one or more YAML files. Files concatenate; a missing id, duplicate id/userName, or duplicate exact host name across the set is a load error. All IDs belong to the inventory service's single configured provider/tenant. Decoding is strict — an unknown field is an error, not a silently ignored typo.

func (*Static) DirectoryRevision

func (s *Static) DirectoryRevision() string

func (*Static) InventoryRevision

func (s *Static) InventoryRevision() string

func (*Static) LookupHost

func (s *Static) LookupHost(_ context.Context, name string) (*ResolvedHost, error)

LookupHost implements Inventory: exact entries first, then pattern entries in file order, first match wins.

func (*Static) LookupUser

func (s *Static) LookupUser(_ context.Context, id string) (*directory.User, error)

LookupUser implements directory.Directory.

type StaticOption

type StaticOption func(*staticOptions) error

StaticOption configures static inventory loading.

func WithDefaultPrincipalMode

func WithDefaultPrincipalMode(mode PrincipalMode) StaticOption

WithDefaultPrincipalMode sets the mode inherited by host entries that omit principal-mode. The default is AccountNamePrincipals.

Jump to

Keyboard shortcuts

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