resource

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AddrResourceKey  = "addr"
	AddrResourceName = "Addr"
)
View Source
const (
	CommandResourceKey  = "command"
	CommandResourceName = "Command"
)
View Source
const (
	DNSResourceKey  = "dns"
	DNSResourceName = "DNS"
)
View Source
const (
	FileResourceKey  = "file"
	FileResourceName = "File"
)
View Source
const (
	GroupResourceKey  = "group"
	GroupResourceName = "Group"
)
View Source
const (
	HTTPResourceKey  = "http"
	HTTPResourceName = "HTTP"
)
View Source
const (
	InterfaceResourceKey  = "interface"
	InterfaceResourceName = "Interface"
)
View Source
const (
	KernelParamResourceKey  = "kernel-param"
	KernelParamResourceName = "KernelParam"
)
View Source
const (
	MatchingResourceKey  = "matching"
	MatchingResourceName = "Matching"
)
View Source
const (
	MountResourceKey  = "mount"
	MountResourceName = "Mount"
)
View Source
const (
	PackageResourceKey  = "package"
	PackageResourceName = "Package"
)
View Source
const (
	PortResourceKey  = "port"
	PortResourceName = "Port"
)
View Source
const (
	ProcessResourceKey  = "process"
	ProcessResourceName = "Process"
)
View Source
const (
	RegistryResourceKey  = "registry"
	RegistryResourceName = "Registry"
)
View Source
const (
	ServiceResourceKey  = "service"
	ServiceResourceName = "Service"
)
View Source
const (
	SyverFileResourceKey  = "gossfile"
	SyverFileResourceName = "Gossfile"
)
View Source
const (
	UserResourceKey  = "user"
	UserResourceName = "User"
)
View Source
const (
	Value = iota
	Values
	Contains
)
View Source
const (
	SUCCESS = iota
	FAIL
	SKIP
	UNKNOWN
)
View Source
const (
	OutcomePass    = "pass"
	OutcomeFail    = "fail"
	OutcomeSkip    = "skip"
	OutcomeUnknown = "unknown"
)

Variables

This section is empty.

Functions

func Descriptors added in v0.8.0

func Descriptors() map[string]Descriptor

Descriptors returns every registered descriptor, keyed by its primary Key (aliases are omitted from this view -- use DescriptorByName/lookup by Key on the map returned by descriptorsSnapshot for alias-inclusive access).

func HumanOutcomes

func HumanOutcomes() map[int]string

func Ref

func Ref(res Resource) string

Ref returns the canonical dependency reference for a resource.

func Register added in v0.8.0

func Register(d Descriptor)

Register adds a Descriptor to the registry. Mirrors the one working registry already in this tree, outputs.RegisterOutputer (outputs/outputs.go): mutex-guarded, panics on a nil New or on a duplicate key (including alias keys).

func Resources

func Resources() map[string]Resource

Resources returns the deprecated key->Resource map. Deprecated: use Descriptors() and Descriptor.New() instead.

func UpsertLive added in v0.8.0

func UpsertLive(field any, res Resource) error

UpsertLive inserts res into the live map pointed to by field -- field must be a pointer to one of the type aliases below (e.g. *PortMap), such as what an accessor.Field(c) call in the root package's dispatch.go returns. It preserves Title/Meta from any existing entry with the same ID, exactly like AppendSysResource does for its own map.

This exists because add.go, in the root package, cannot call AppendSysResource directly (it doesn't know which SyverConfig field a dispatched-by-name resource belongs to, and resource cannot import the root package to find out -- see FEAT-007 G1). It gets a freshly-built Resource from Descriptor.AppendSys instead, and needs a generic way to store it in whichever live field the accessor table points at.

func YAMLKey

func YAMLKey(res Resource) string

YAMLKey returns the gossfile map key for a resource.

Contract (FEAT-007 §4.5, documented now because it becomes load-bearing once Phase 2's external plugin types exist): this reads the unexported "id" struct field by reflection first, falling back to ResourceRead.ID() only if that field doesn't exist or isn't a string. Every builtin type in this package has that field (id string), so the fallback is never exercised today. A foreign package's unexported fields are unreadable via reflection from outside that package -- an external Resource implementation (Source: SourceExternal) will always hit the ID() fallback instead, never the "id" field. That's fine as long as its ID() is accurate, but it means `depends-on:` references into an external type depend entirely on that type's ID() being correct; there's no second, reflection-based check backing it up the way builtin types get.

Types

type Addr

type Addr struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Address      string  `json:"address,omitempty" yaml:"address,omitempty"`
	LocalAddress string  `json:"local-address,omitempty" yaml:"local-address,omitempty"`
	Reachable    matcher `json:"reachable" yaml:"reachable"`
	Timeout      int     `json:"timeout" yaml:"timeout"`
	Skip         bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewAddr

func NewAddr(sysAddr system.Addr, config util.Config) (*Addr, error)

func (*Addr) GetAddress

func (a *Addr) GetAddress() string

func (*Addr) GetMeta

func (a *Addr) GetMeta() meta

func (*Addr) GetTitle

func (a *Addr) GetTitle() string

FIXME: Can this be refactored?

func (*Addr) ID

func (a *Addr) ID() string

func (*Addr) SetID

func (a *Addr) SetID(id string)

func (*Addr) SetSkip

func (a *Addr) SetSkip()

func (*Addr) TypeKey

func (a *Addr) TypeKey() string

func (*Addr) TypeName

func (a *Addr) TypeName() string

func (*Addr) Validate

func (a *Addr) Validate(ctx context.Context, sys *system.System) []TestResult

type AddrMap

type AddrMap = ResourceMap[Addr, system.Addr, *Addr]

type AppendFn added in v0.8.0

type AppendFn func(sys *system.System, key string, config util.Config) (Resource, error)

AppendFn constructs a fresh resource from live system state for `syver add`/`autoadd`. It closes over both the system-side constructor (sys.NewPort, ...) and the resource-side constructor (resource.NewPort, ...), which is what lets add.go dispatch without knowing which SyverConfig field a type lives in -- that part is handled separately, by the caller, via the live-field accessor (see dispatch.go, FEAT-007 G1). A nil AppendFn means the type has no `syver add` support (only `matching` today).

type AutoAddSpec added in v0.8.0

type AutoAddSpec struct {
	Order int
}

AutoAddSpec marks a type as eligible for `syver autoadd` and fixes its position in the (order-sensitive -- it drives resourcePrint's stdout sequence, which is golden-tested) autoadd scan. Order values are sparse on purpose: File=1, Group=2, Package=3, Port=4, Process=5, Service=6, User=7, matching every other type out of the loop entirely (AutoAdd == nil).

type Command

type Command struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Exec       string  `json:"exec,omitempty" yaml:"exec,omitempty"`
	ExitStatus matcher `json:"exit-status" yaml:"exit-status"`
	Stdout     matcher `json:"stdout" yaml:"stdout"`
	Stderr     matcher `json:"stderr" yaml:"stderr"`
	Timeout    int     `json:"timeout" yaml:"timeout"`
	Skip       bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(sysCommand system.Command, config util.Config) (*Command, error)

func (*Command) GetExec

func (c *Command) GetExec() string

func (*Command) GetMeta

func (c *Command) GetMeta() meta

func (*Command) GetTitle

func (c *Command) GetTitle() string

func (*Command) ID

func (c *Command) ID() string

func (*Command) SetID

func (c *Command) SetID(id string)

func (*Command) SetSkip

func (c *Command) SetSkip()

func (*Command) TypeKey

func (c *Command) TypeKey() string

func (*Command) TypeName

func (c *Command) TypeName() string

func (*Command) Validate

func (c *Command) Validate(ctx context.Context, sys *system.System) []TestResult

type CommandMap

type CommandMap = ResourceMap[Command, system.Command, *Command]

type DNS

type DNS struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Resolve     string  `json:"resolve,omitempty" yaml:"resolve,omitempty"`
	Resolveable matcher `json:"resolveable,omitempty" yaml:"resolveable,omitempty"`
	Resolvable  matcher `json:"resolvable" yaml:"resolvable"`
	Addrs       matcher `json:"addrs,omitempty" yaml:"addrs,omitempty"`
	Timeout     int     `json:"timeout" yaml:"timeout"`
	Server      string  `json:"server,omitempty" yaml:"server,omitempty"`
	Skip        bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewDNS

func NewDNS(sysDNS system.DNS, config util.Config) (*DNS, error)

func (*DNS) GetMeta

func (d *DNS) GetMeta() meta

func (*DNS) GetResolve

func (d *DNS) GetResolve() string

func (*DNS) GetTitle

func (d *DNS) GetTitle() string

func (*DNS) ID

func (d *DNS) ID() string

func (*DNS) SetID

func (d *DNS) SetID(id string)

func (*DNS) SetSkip

func (d *DNS) SetSkip()

func (*DNS) TypeKey

func (d *DNS) TypeKey() string

func (*DNS) TypeName

func (d *DNS) TypeName() string

func (*DNS) Validate

func (d *DNS) Validate(ctx context.Context, sys *system.System) []TestResult

type DNSMap

type DNSMap = ResourceMap[DNS, system.DNS, *DNS]

type Dependent

type Dependent interface {
	Resource
	GetDependsOn() []string
}

Dependent resources declare prerequisite tests that must pass first.

type Descriptor added in v0.8.0

type Descriptor struct {
	Key  string          // gossfile key: "port", "kernel-param", "gossfile"
	Name string          // dispatch name: "Port", "Gossfile" -- NOT always the Go type name
	New  func() Resource // zero-value factory

	// Set membership. Today these two diverge implicitly (see the FEAT-007
	// spec's "canonical inventory" table); made explicit here.
	InValidation bool // in SyverConfig.Resources(): matching=true, gossfile=false
	InDiscovery  bool // has a DiscoveryConfig field: gossfile=false, others=true

	Alias     []string          // e.g. "syverfile" -> gossfile
	AppendSys AppendFn          // nil = no `syver add` (matching)
	AutoAdd   *AutoAddSpec      // nil = not auto-addable
	CLIFlags  func() []cli.Flag // per-type `add` flags (http, dns, addr, ...); nil = none

	// CLIName/CLIAliases drive the generated `cmd/syver add` subcommand.
	// Default to Key/nil when unset. Needed because at least one type
	// (gossfile) is named neither by its Key nor its Name on the CLI --
	// see FEAT-007 G4.
	CLIName    string
	CLIAliases []string

	Source Source
}

Descriptor is the single per-type registration record that replaces the old registerResource(key, &Type{}) call plus the ~19 scattered touch points a new resource type used to require (see FEAT-007 spec S1).

Do not confuse this file with resource/registry.go -- that is the Windows Registry *resource*, an unrelated pre-existing file.

func AutoAddDescriptors added in v0.8.0

func AutoAddDescriptors() []Descriptor

AutoAddDescriptors returns every AutoAdd-eligible descriptor, sorted by AutoAddSpec.Order. The order is load-bearing: `syver autoadd` prints one line per discovered resource, in this sequence, and that sequence is golden-tested.

func DescriptorByKey added in v0.8.0

func DescriptorByKey(key string) (Descriptor, bool)

DescriptorByKey looks up a descriptor by its gossfile key, including alias keys (e.g. "syverfile" resolves to the same Descriptor as "gossfile").

func DescriptorByName added in v0.8.0

func DescriptorByName(name string) (Descriptor, bool)

DescriptorByName looks up a descriptor by its dispatch Name (e.g. "Port", "Gossfile") -- the value add.go's switch used to key on.

type Discoverable

type Discoverable interface {
	Resource
	GetRegister() string
}

Discoverable resources expose a register name for discovery output.

type DiscoveryMeta

type DiscoveryMeta struct {
	Register  string   `json:"register,omitempty" yaml:"register,omitempty"`
	DependsOn []string `json:"depends-on,omitempty" yaml:"depends-on,omitempty"`
}

DiscoveryMeta holds optional discovery and dependency metadata shared by resources.

func (DiscoveryMeta) GetDependsOn

func (d DiscoveryMeta) GetDependsOn() []string

func (DiscoveryMeta) GetRegister

func (d DiscoveryMeta) GetRegister() string

type File

type File struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Path     string  `json:"path,omitempty" yaml:"path,omitempty"`
	Exists   matcher `json:"exists" yaml:"exists"`
	Mode     matcher `json:"mode,omitempty" yaml:"mode,omitempty"`
	Size     matcher `json:"size,omitempty" yaml:"size,omitempty"`
	Owner    matcher `json:"owner,omitempty" yaml:"owner,omitempty"`
	Uid      matcher `json:"uid,omitempty" yaml:"uid,omitempty"`
	Group    matcher `json:"group,omitempty" yaml:"group,omitempty"`
	Gid      matcher `json:"gid,omitempty" yaml:"gid,omitempty"`
	LinkedTo matcher `json:"linked-to,omitempty" yaml:"linked-to,omitempty"`
	Filetype matcher `json:"filetype,omitempty" yaml:"filetype,omitempty"`
	Contains matcher `json:"contains,omitempty" yaml:"contains,omitempty"`
	Contents matcher `json:"contents,omitempty" yaml:"contents,omitempty"`
	Md5      matcher `json:"md5,omitempty" yaml:"md5,omitempty"`
	Sha256   matcher `json:"sha256,omitempty" yaml:"sha256,omitempty"`
	Sha512   matcher `json:"sha512,omitempty" yaml:"sha512,omitempty"`
	Skip     bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewFile

func NewFile(sysFile system.File, config util.Config) (*File, error)

func (*File) GetMeta

func (f *File) GetMeta() meta

func (*File) GetPath

func (f *File) GetPath() string

func (*File) GetTitle

func (f *File) GetTitle() string

func (*File) ID

func (f *File) ID() string

func (*File) SetID

func (f *File) SetID(id string)

func (*File) SetSkip

func (f *File) SetSkip()

func (*File) TypeKey

func (f *File) TypeKey() string

func (*File) TypeName

func (f *File) TypeName() string

func (*File) Validate

func (f *File) Validate(ctx context.Context, sys *system.System) []TestResult

type FileMap

type FileMap = ResourceMap[File, system.File, *File]

type Group

type Group struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Groupname string  `json:"groupname,omitempty" yaml:"groupname,omitempty"`
	Exists    matcher `json:"exists" yaml:"exists"`
	GID       matcher `json:"gid,omitempty" yaml:"gid,omitempty"`
	Skip      bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup(sysGroup system.Group, config util.Config) (*Group, error)

func (*Group) GetGroupname

func (g *Group) GetGroupname() string

func (*Group) GetMeta

func (g *Group) GetMeta() meta

func (*Group) GetTitle

func (g *Group) GetTitle() string

func (*Group) ID

func (g *Group) ID() string

func (*Group) SetID

func (g *Group) SetID(id string)

func (*Group) SetSkip

func (g *Group) SetSkip()

func (*Group) TypeKey

func (g *Group) TypeKey() string

func (*Group) TypeName

func (g *Group) TypeName() string

func (*Group) Validate

func (g *Group) Validate(ctx context.Context, sys *system.System) []TestResult

type GroupMap

type GroupMap = ResourceMap[Group, system.Group, *Group]

type HTTP

type HTTP struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	URL                string              `json:"url,omitempty" yaml:"url,omitempty"`
	Method             string              `json:"method,omitempty" yaml:"method,omitempty"`
	Status             matcher             `json:"status" yaml:"status"`
	AllowInsecure      bool                `json:"allow-insecure" yaml:"allow-insecure"`
	NoFollowRedirects  bool                `json:"no-follow-redirects" yaml:"no-follow-redirects"`
	Timeout            int                 `json:"timeout,omitempty" yaml:"timeout,omitempty"`
	RequestHeader      []string            `json:"request-headers,omitempty" yaml:"request-headers,omitempty"`
	RequestQueryParams map[string][]string `json:"request-query-params,omitempty" yaml:"request-query-params,omitempty"`
	RequestBody        string              `json:"request-body,omitempty" yaml:"request-body,omitempty"`
	Headers            matcher             `json:"headers,omitempty" yaml:"headers,omitempty"`
	Body               matcher             `json:"body,omitempty" yaml:"body,omitempty"`
	Username           string              `json:"username,omitempty" yaml:"username,omitempty"`
	Password           string              `json:"password,omitempty" yaml:"password,omitempty"`
	CAFile             string              `json:"ca-file,omitempty" yaml:"ca-file,omitempty"`
	CertFile           string              `json:"cert-file,omitempty" yaml:"cert-file,omitempty"`
	KeyFile            string              `json:"key-file,omitempty" yaml:"key-file,omitempty"`
	Skip               bool                `json:"skip,omitempty" yaml:"skip,omitempty"`
	Proxy              string              `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	// contains filtered or unexported fields
}

func NewHTTP

func NewHTTP(sysHTTP system.HTTP, config util.Config) (*HTTP, error)

func (*HTTP) GetMeta

func (r *HTTP) GetMeta() meta

func (*HTTP) GetTitle

func (r *HTTP) GetTitle() string

FIXME: Can this be refactored?

func (*HTTP) ID

func (h *HTTP) ID() string

func (*HTTP) SetID

func (h *HTTP) SetID(id string)

func (*HTTP) SetSkip

func (u *HTTP) SetSkip()

func (*HTTP) TypeKey

func (u *HTTP) TypeKey() string

func (*HTTP) TypeName

func (u *HTTP) TypeName() string

func (*HTTP) Validate

func (u *HTTP) Validate(ctx context.Context, sys *system.System) []TestResult

type HTTPMap

type HTTPMap = ResourceMap[HTTP, system.HTTP, *HTTP]

type Interface

type Interface struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Name   string  `json:"name,omitempty" yaml:"name,omitempty"`
	Exists matcher `json:"exists" yaml:"exists"`
	Addrs  matcher `json:"addrs,omitempty" yaml:"addrs,omitempty"`
	MTU    matcher `json:"mtu,omitempty" yaml:"mtu,omitempty"`
	Skip   bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewInterface

func NewInterface(sysInterface system.Interface, config util.Config) (*Interface, error)

func (*Interface) GetMeta

func (i *Interface) GetMeta() meta

func (*Interface) GetName

func (i *Interface) GetName() string

func (*Interface) GetTitle

func (i *Interface) GetTitle() string

FIXME: Can this be refactored?

func (*Interface) ID

func (i *Interface) ID() string

func (*Interface) SetID

func (i *Interface) SetID(id string)

func (*Interface) SetSkip

func (i *Interface) SetSkip()

func (*Interface) TypeKey

func (i *Interface) TypeKey() string

func (*Interface) TypeName

func (i *Interface) TypeName() string

func (*Interface) Validate

func (i *Interface) Validate(ctx context.Context, sys *system.System) []TestResult

type KernelParam

type KernelParam struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Name  string  `json:"name,omitempty" yaml:"name,omitempty"`
	Key   string  `json:"-" yaml:"-"`
	Value matcher `json:"value" yaml:"value"`
	Skip  bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewKernelParam

func NewKernelParam(sysKernelParam system.KernelParam, config util.Config) (*KernelParam, error)

func (*KernelParam) GetMeta

func (k *KernelParam) GetMeta() meta

func (*KernelParam) GetName

func (k *KernelParam) GetName() string

func (*KernelParam) GetTitle

func (k *KernelParam) GetTitle() string

FIXME: Can this be refactored?

func (*KernelParam) ID

func (k *KernelParam) ID() string

func (*KernelParam) SetID

func (a *KernelParam) SetID(id string)

func (*KernelParam) SetSkip

func (a *KernelParam) SetSkip()

func (*KernelParam) TypeKey

func (a *KernelParam) TypeKey() string

func (*KernelParam) TypeName

func (a *KernelParam) TypeName() string

func (*KernelParam) Validate

func (k *KernelParam) Validate(ctx context.Context, sys *system.System) []TestResult

type Matching

type Matching struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`
	Content       any    `json:"content,omitempty" yaml:"content,omitempty"`
	AsReader      bool   `json:"as-reader,omitempty" yaml:"as-reader,omitempty"`

	Matches matcher `json:"matches" yaml:"matches"`
	Skip    bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func (*Matching) GetMeta

func (r *Matching) GetMeta() meta

func (*Matching) GetTitle

func (r *Matching) GetTitle() string

FIXME: Can this be refactored?

func (*Matching) ID

func (a *Matching) ID() string

func (*Matching) SetID

func (a *Matching) SetID(id string)

func (*Matching) SetSkip

func (a *Matching) SetSkip()

SetSkip is the one deliberate behaviour change in FEAT-007 (G2, AC-7): this used to be a no-op, which is a live bug, not a latent one -- `matching` IS in SyverConfig.Resources() (unlike `gossfile`), so it does reach applyDisabledTypes (dependency_scheduler.go), whose only action is calling SetSkip(). Before this fix, util.WithDisabledResourceTypes("matching") produced total=1 skipped=0 failed=1 instead of the expected total=1 skipped=1 failed=0 -- disabling the type didn't disable it. No golden exercises DisabledResourceTypes (it has no CLI flag, only util.WithDisabledResourceTypes, a library-only option), so this changes no golden and AC-1 stays valid. See TestMatchingSetSkipDisablesValidation in matching_test.go for the regression test.

func (*Matching) TypeKey

func (a *Matching) TypeKey() string

func (*Matching) TypeName

func (a *Matching) TypeName() string

func (*Matching) Validate

func (a *Matching) Validate(ctx context.Context, sys *system.System) []TestResult

type MatchingMap

type MatchingMap = ResourceMap[Matching, any, *Matching]

MatchingMap has no system backing (matching validates a literal `content:` value, not anything read off the host), so its ST is `any` and its fromSystem stub (matching.go) always errors -- matching has no `syver add` support (Descriptor.AppendSys is nil for it), so that stub is never actually reached.

type Mount

type Mount struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	MountPoint string  `json:"mountpoint,omitempty" yaml:"mountpoint,omitempty"`
	Exists     matcher `json:"exists" yaml:"exists"`
	Opts       matcher `json:"opts,omitempty" yaml:"opts,omitempty"`
	VfsOpts    matcher `json:"vfs-opts,omitempty" yaml:"vfs-opts,omitempty"`
	Source     matcher `json:"source,omitempty" yaml:"source,omitempty"`
	Filesystem matcher `json:"filesystem,omitempty" yaml:"filesystem,omitempty"`
	Timeout    int     `json:"timeout" yaml:"timeout"`
	Skip       bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	Usage      matcher `json:"usage,omitempty" yaml:"usage,omitempty"`
	// contains filtered or unexported fields
}

func NewMount

func NewMount(sysMount system.Mount, config util.Config) (*Mount, error)

func (*Mount) GetMeta

func (m *Mount) GetMeta() meta

func (*Mount) GetMountPoint

func (m *Mount) GetMountPoint() string

func (*Mount) GetTitle

func (m *Mount) GetTitle() string

FIXME: Can this be refactored?

func (*Mount) ID

func (m *Mount) ID() string

func (*Mount) SetID

func (m *Mount) SetID(id string)

func (*Mount) SetSkip

func (m *Mount) SetSkip()

func (*Mount) TypeKey

func (m *Mount) TypeKey() string

func (*Mount) TypeName

func (m *Mount) TypeName() string

func (*Mount) Validate

func (m *Mount) Validate(ctx context.Context, sys *system.System) []TestResult

type MountMap

type MountMap = ResourceMap[Mount, system.Mount, *Mount]

type Package

type Package struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Name      string  `json:"name,omitempty" yaml:"name,omitempty"`
	Installed matcher `json:"installed" yaml:"installed"`
	Versions  matcher `json:"versions,omitempty" yaml:"versions,omitempty"`
	Skip      bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewPackage

func NewPackage(sysPackage system.Package, config util.Config) (*Package, error)

func (*Package) GetMeta

func (p *Package) GetMeta() meta

func (*Package) GetName

func (p *Package) GetName() string

func (*Package) GetTitle

func (p *Package) GetTitle() string

func (*Package) ID

func (p *Package) ID() string

func (*Package) SetID

func (p *Package) SetID(id string)

func (*Package) SetSkip

func (p *Package) SetSkip()

func (*Package) TypeKey

func (p *Package) TypeKey() string

func (*Package) TypeName

func (p *Package) TypeName() string

func (*Package) Validate

func (p *Package) Validate(ctx context.Context, sys *system.System) []TestResult

type PackageMap

type PackageMap = ResourceMap[Package, system.Package, *Package]

type Port

type Port struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Port      string  `json:"port,omitempty" yaml:"port,omitempty"`
	Listening matcher `json:"listening" yaml:"listening"`
	IP        matcher `json:"ip,omitempty" yaml:"ip,omitempty"`
	PID       matcher `json:"pid,omitempty" yaml:"pid,omitempty"`
	Skip      bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewPort

func NewPort(sysPort system.Port, config util.Config) (*Port, error)

func (*Port) GetMeta

func (p *Port) GetMeta() meta

func (*Port) GetPort

func (p *Port) GetPort() string

func (*Port) GetTitle

func (p *Port) GetTitle() string

func (*Port) ID

func (p *Port) ID() string

func (*Port) SetID

func (p *Port) SetID(id string)

func (*Port) SetSkip

func (p *Port) SetSkip()

func (*Port) TypeKey

func (p *Port) TypeKey() string

func (*Port) TypeName

func (p *Port) TypeName() string

func (*Port) Validate

func (p *Port) Validate(ctx context.Context, sys *system.System) []TestResult

type PortMap

type PortMap = ResourceMap[Port, system.Port, *Port]

type Process

type Process struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Comm    string  `json:"comm,omitempty" yaml:"comm,omitempty"`
	Running matcher `json:"running" yaml:"running"`
	Status  matcher `json:"status,omitempty" yaml:"status,omitempty"`
	User    matcher `json:"user,omitempty" yaml:"user,omitempty"`
	Skip    bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewProcess

func NewProcess(sysProcess system.Process, config util.Config) (*Process, error)

func (*Process) GetComm

func (p *Process) GetComm() string

func (*Process) GetMeta

func (p *Process) GetMeta() meta

func (*Process) GetTitle

func (p *Process) GetTitle() string

func (*Process) ID

func (p *Process) ID() string

func (*Process) SetID

func (p *Process) SetID(id string)

func (*Process) SetSkip

func (p *Process) SetSkip()

func (*Process) TypeKey

func (p *Process) TypeKey() string

func (*Process) TypeName

func (p *Process) TypeName() string

func (*Process) Validate

func (p *Process) Validate(ctx context.Context, sys *system.System) []TestResult

type ProcessMap

type ProcessMap = ResourceMap[Process, system.Process, *Process]

type Registry

type Registry struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Name   string  `json:"name,omitempty" yaml:"name,omitempty"`
	Exists matcher `json:"exists" yaml:"exists"`
	Value  matcher `json:"value,omitempty" yaml:"value,omitempty"`
	Type   matcher `json:"type,omitempty" yaml:"type,omitempty"`
	Skip   bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(sysRegistry system.Registry, config util.Config) (*Registry, error)

func (*Registry) GetMeta

func (r *Registry) GetMeta() meta

func (*Registry) GetName

func (r *Registry) GetName() string

func (*Registry) GetTitle

func (r *Registry) GetTitle() string

func (*Registry) ID

func (r *Registry) ID() string

func (*Registry) SetID

func (r *Registry) SetID(id string)

func (*Registry) SetSkip

func (r *Registry) SetSkip()

func (*Registry) TypeKey

func (r *Registry) TypeKey() string

func (*Registry) TypeName

func (r *Registry) TypeName() string

func (*Registry) Validate

func (r *Registry) Validate(ctx context.Context, sys *system.System) []TestResult

type RegistryMap

type RegistryMap = ResourceMap[Registry, system.Registry, *Registry]

type Resource

type Resource interface {
	Validate(ctx context.Context, sys *system.System) []TestResult
	SetID(string)
	SetSkip()
	TypeKey() string
	TypeName() string
	GetRegister() string
	GetDependsOn() []string
}

type ResourceMap added in v0.8.0

type ResourceMap[T any, ST any, PT interface {
	*T
	Resource
	ResourceRead
	SetID(string)
	fromSystem(sys *system.System, key string, config util.Config) (ST, error)
}] map[string]*T

ResourceMap is the generic replacement for the 16 near-identical genny-generated per-type maps (AddrMap, FileMap, PortMap, ...) that used to live in resource_list.go.

T is the concrete resource struct (e.g. Port). ST is the concrete system-side value produced while building one (e.g. system.Port) -- carried as its own type parameter, not collapsed to `any`, specifically so AppendSysResourceIfExists can keep its original per-type return signature (some callers, e.g. add.go's process auto-add fan-out, use it). PT is *T, constrained to satisfy Resource, ResourceRead, SetID and fromSystem, which is what lets AppendSysResource/AppendSysResourceIfExists be written once instead of once per type.

fromSystem is unexported and type-specific (one ~8-line method per type, in that type's own file) -- it is the one piece genny used to text-substitute (sys.NewPort / resource.NewPort) that Go generics cannot derive generically, since it has no way to pick "NewPort" off *system.System from the type parameter T alone.

func (ResourceMap[T, ST, PT]) AppendSysResource added in v0.8.0

func (r ResourceMap[T, ST, PT]) AppendSysResource(sr string, sys *system.System, config util.Config) (PT, error)

AppendSysResource builds a fresh T from live system state and stores it, preserving Title/Meta from any existing entry under the same ID -- same contract as the old generated method.

func (ResourceMap[T, ST, PT]) AppendSysResourceIfExists added in v0.8.0

func (r ResourceMap[T, ST, PT]) AppendSysResourceIfExists(sr string, sys *system.System) (PT, ST, bool, error)

AppendSysResourceIfExists is AppendSysResource, but only stores the result if the underlying system resource actually exists -- used by `syver autoadd`. The bool return reports whether it existed (and was therefore stored).

func (*ResourceMap[T, ST, PT]) UnmarshalJSON added in v0.8.0

func (ret *ResourceMap[T, ST, PT]) UnmarshalJSON(data []byte) error

func (*ResourceMap[T, ST, PT]) UnmarshalYAML added in v0.8.0

func (ret *ResourceMap[T, ST, PT]) UnmarshalYAML(unmarshal func(v interface{}) error) error

type ResourceRead

type ResourceRead interface {
	ID() string
	GetTitle() string
	GetMeta() meta
}

type Service

type Service struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Name      string  `json:"name,omitempty" yaml:"name,omitempty"`
	Enabled   matcher `json:"enabled" yaml:"enabled"`
	Running   matcher `json:"running" yaml:"running"`
	Skip      bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	RunLevels matcher `json:"runlevels,omitempty" yaml:"runlevels,omitempty"`
	// contains filtered or unexported fields
}

func NewService

func NewService(sysService system.Service, config util.Config) (*Service, error)

func (*Service) GetMeta

func (s *Service) GetMeta() meta

func (*Service) GetName

func (s *Service) GetName() string

func (*Service) GetTitle

func (s *Service) GetTitle() string

func (*Service) ID

func (s *Service) ID() string

func (*Service) SetID

func (s *Service) SetID(id string)

func (*Service) SetSkip

func (s *Service) SetSkip()

func (*Service) TypeKey

func (s *Service) TypeKey() string

func (*Service) TypeName

func (s *Service) TypeName() string

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, sys *system.System) []TestResult

type ServiceMap

type ServiceMap = ResourceMap[Service, system.Service, *Service]

type Source added in v0.8.0

type Source int

Source distinguishes where a resource type's implementation lives. SourceExternal is reserved for Phase 2 (out-of-process plugin modules); nothing in Phase 1 sets it.

const (
	SourceBuiltin Source = iota
	SourceExternal
)

type Syverfile

type Syverfile struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`
	Path          string `json:"-" yaml:"-"`
	Skip          bool   `json:"skip,omitempty" yaml:"skip,omitempty"`
	File          string `json:"file,omitempty" yaml:"file,omitempty"`
}

func NewSyverfile

func NewSyverfile(sysSyverfile system.Syverfile, config util.Config) (*Syverfile, error)

func (*Syverfile) GetMeta

func (g *Syverfile) GetMeta() meta

func (*Syverfile) GetSkip

func (g *Syverfile) GetSkip() bool

func (*Syverfile) GetSyverfile

func (g *Syverfile) GetSyverfile() string

func (*Syverfile) GetTitle

func (g *Syverfile) GetTitle() string

func (*Syverfile) ID

func (g *Syverfile) ID() string

func (*Syverfile) SetID

func (g *Syverfile) SetID(id string)

func (*Syverfile) SetSkip

func (g *Syverfile) SetSkip()

func (*Syverfile) TypeKey

func (g *Syverfile) TypeKey() string

func (*Syverfile) TypeName

func (g *Syverfile) TypeName() string

func (*Syverfile) Validate

func (g *Syverfile) Validate(ctx context.Context, sys *system.System) []TestResult

type TestResult

type TestResult struct {
	Successful bool `json:"successful" yaml:"successful"`
	Skipped    bool `json:"skipped" yaml:"skipped"`
	// Resource data
	ResourceId   string `json:"resource-id" yaml:"resource-id"`
	ResourceType string `json:"resource-type" yaml:"resource-type"`
	Property     string `json:"property" yaml:"property"`

	// User added info
	Title string `json:"title" yaml:"title"`
	Meta  meta   `json:"meta" yaml:"meta"`

	// Result
	Result        int                    `json:"result" yaml:"result"`
	Err           *ValidateError         `json:"err" yaml:"err"`
	MatcherResult matchers.MatcherResult `json:"matcher-result" yaml:"matcher-result"`
	StartTime     time.Time              `json:"start-time" yaml:"start-time"`
	EndTime       time.Time              `json:"end-time" yaml:"end-time"`
	Duration      time.Duration          `json:"duration" yaml:"duration"`
}

func SkipResourceResults

func SkipResourceResults(res Resource, reason string) []TestResult

SkipResourceResults emits skip results for every validated property on a resource.

func ValidateGomegaValue

func ValidateGomegaValue(res ResourceRead, property string, expectedValue any, actual any, skip bool) TestResult

func ValidateSafe added in v0.9.0

func ValidateSafe(ctx context.Context, res Resource, sys *system.System) (results []TestResult)

ValidateSafe is res.Validate with a panic barrier.

Both schedulers (validateParallel and validateWithDependencies) run resources on bare goroutines. Nothing above them recovers -- net/http's per-connection recover does not extend to goroutines a handler started, and there is no recover() anywhere else in non-test code -- so a panic inside any one resource's Validate takes the whole process down. Under `validate` that is a confusing crash instead of a failing check; under `serve` it is the daemon dying on a request, from a spec it was handed at startup and has been serving happily until the panic's trigger appears.

That is not hypothetical. An empty map matcher (`stdout: {}`) panicked with index-out-of-range, and a served spec containing one killed the daemon on the first probe. That specific trigger is fixed; this closes the class, so the next one costs a FAIL on one resource rather than the process.

Deliberately per-resource, not per-worker: a worker-level recover would end the worker and silently drop every resource still queued behind it, which turns a crash into an under-reported pass. Here the panicking resource fails, its neighbours are unaffected, and the exit code and /healthz status follow from the FAIL like any other failure.

This does not, and cannot, catch a runtime *throw* -- concurrent map writes, out-of-memory, a nil-interface method call. Those are not panics and recover() never sees them; see the stateMu comment in dependency_scheduler.go.

func ValidateValue

func ValidateValue(res ResourceRead, property string, expectedValue any, actual any, skip bool) TestResult

func (TestResult) SortKey

func (t TestResult) SortKey() string

func (TestResult) ToOutcome

func (tr TestResult) ToOutcome() string

ToOutcome converts the enum to a human-friendly string.

type TypedResourceRead added in v0.8.0

type TypedResourceRead interface {
	ResourceRead
	TypeName() string
}

TypedResourceRead is ResourceRead plus TypeName(). It is *not* required by ValidateValue/ValidateGomegaValue's exported signatures below -- deliberately, see the comment on typeNameFor -- but every builtin resource type satisfies it, and any embedder's custom ResourceRead implementation should too, for the same reason: it's what lets those functions print an accurate ResourceType without reflection.

type User

type User struct {
	DiscoveryMeta `yaml:",inline" json:",inline"`
	Title         string `json:"title,omitempty" yaml:"title,omitempty"`
	Meta          meta   `json:"meta,omitempty" yaml:"meta,omitempty"`

	Username string  `json:"username,omitempty" yaml:"username,omitempty"`
	Exists   matcher `json:"exists" yaml:"exists"`
	UID      matcher `json:"uid,omitempty" yaml:"uid,omitempty"`
	GID      matcher `json:"gid,omitempty" yaml:"gid,omitempty"`
	Groups   matcher `json:"groups,omitempty" yaml:"groups,omitempty"`
	Home     matcher `json:"home,omitempty" yaml:"home,omitempty"`
	Shell    matcher `json:"shell,omitempty" yaml:"shell,omitempty"`
	Skip     bool    `json:"skip,omitempty" yaml:"skip,omitempty"`
	// contains filtered or unexported fields
}

func NewUser

func NewUser(sysUser system.User, config util.Config) (*User, error)

func (*User) GetMeta

func (u *User) GetMeta() meta

func (*User) GetTitle

func (u *User) GetTitle() string

func (*User) GetUsername

func (u *User) GetUsername() string

func (*User) ID

func (u *User) ID() string

func (*User) SetID

func (u *User) SetID(id string)

func (*User) SetSkip

func (u *User) SetSkip()

func (*User) TypeKey

func (u *User) TypeKey() string

func (*User) TypeName

func (u *User) TypeName() string

func (*User) Validate

func (u *User) Validate(ctx context.Context, sys *system.System) []TestResult

type UserMap

type UserMap = ResourceMap[User, system.User, *User]

type ValidateError

type ValidateError string

func NewValidateError added in v0.9.0

func NewValidateError(err error) *ValidateError

NewValidateError wraps an error as a *ValidateError so callers outside this package can build a TestResult. serve.go needs it to turn a validation that could not run at all into a visible failing result rather than an empty set.

func (ValidateError) Error

func (g ValidateError) Error() string

Jump to

Keyboard shortcuts

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