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

inventorytest

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facts

type Facts struct {
	DirectoryURL, InventoryURL string
	Identity                   oidc.ValidatorConfig
}

func ServeFacts

func ServeFacts(t *testing.T, inv *Static, issuer string, key sshcert.RawPublicKey) *Facts

func ServeFactsWithConfig

func ServeFactsWithConfig(t *testing.T, inv *Static, cfg oidc.ValidatorConfig, key sshcert.RawPublicKey) *Facts

func ServeFactsWithSources

func ServeFactsWithSources(t *testing.T, users directory.Directory, hosts inventory.Hosts, cfg oidc.ValidatorConfig, key sshcert.RawPublicKey) *Facts

func (*Facts) CAOption

func (f *Facts) CAOption() ca.Option

type Static

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

Static is a combined YAML fact fixture for integration tests: directory users and hosts loaded once at startup. Reload is a process restart, like the policy itself.

inventory.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. Principal realms are separate issuance metadata and never replace host names. 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) LookupHost

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

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

func (*Static) LookupUser

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

LookupUser delegates directory semantics to the production static loader.

type StaticOption

type StaticOption func(*staticOptions) error

StaticOption configures static inventory loading.

func WithDefaultPrincipalMode

func WithDefaultPrincipalMode(mode inventory.PrincipalMode) StaticOption

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

func WithoutHosts

func WithoutHosts() StaticOption

WithoutHosts loads only directory facts, independently of host configuration.

func WithoutUsers

func WithoutUsers() StaticOption

WithoutUsers loads only host facts; user records cannot become a fallback.

Jump to

Keyboard shortcuts

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