Documentation
¶
Index ¶
- Constants
- func Descriptors() map[string]Descriptor
- func HumanOutcomes() map[int]string
- func Ref(res Resource) string
- func Register(d Descriptor)
- func Resources() map[string]Resource
- func UpsertLive(field any, res Resource) error
- func YAMLKey(res Resource) string
- type Addr
- func (a *Addr) GetAddress() string
- func (a *Addr) GetMeta() meta
- func (a *Addr) GetTitle() string
- func (a *Addr) ID() string
- func (a *Addr) SetID(id string)
- func (a *Addr) SetSkip()
- func (a *Addr) TypeKey() string
- func (a *Addr) TypeName() string
- func (a *Addr) Validate(ctx context.Context, sys *system.System) []TestResult
- type AddrMap
- type AppendFn
- type AutoAddSpec
- type Command
- func (c *Command) GetExec() string
- func (c *Command) GetMeta() meta
- func (c *Command) GetTitle() string
- func (c *Command) ID() string
- func (c *Command) SetID(id string)
- func (c *Command) SetSkip()
- func (c *Command) TypeKey() string
- func (c *Command) TypeName() string
- func (c *Command) Validate(ctx context.Context, sys *system.System) []TestResult
- type CommandMap
- type DNS
- func (d *DNS) GetMeta() meta
- func (d *DNS) GetResolve() string
- func (d *DNS) GetTitle() string
- func (d *DNS) ID() string
- func (d *DNS) SetID(id string)
- func (d *DNS) SetSkip()
- func (d *DNS) TypeKey() string
- func (d *DNS) TypeName() string
- func (d *DNS) Validate(ctx context.Context, sys *system.System) []TestResult
- type DNSMap
- type Dependent
- type Descriptor
- type Discoverable
- type DiscoveryMeta
- type File
- func (f *File) GetMeta() meta
- func (f *File) GetPath() string
- func (f *File) GetTitle() string
- func (f *File) ID() string
- func (f *File) SetID(id string)
- func (f *File) SetSkip()
- func (f *File) TypeKey() string
- func (f *File) TypeName() string
- func (f *File) Validate(ctx context.Context, sys *system.System) []TestResult
- type FileMap
- type Group
- func (g *Group) GetGroupname() string
- func (g *Group) GetMeta() meta
- func (g *Group) GetTitle() string
- func (g *Group) ID() string
- func (g *Group) SetID(id string)
- func (g *Group) SetSkip()
- func (g *Group) TypeKey() string
- func (g *Group) TypeName() string
- func (g *Group) Validate(ctx context.Context, sys *system.System) []TestResult
- type GroupMap
- type HTTP
- type HTTPMap
- type Interface
- func (i *Interface) GetMeta() meta
- func (i *Interface) GetName() string
- func (i *Interface) GetTitle() string
- func (i *Interface) ID() string
- func (i *Interface) SetID(id string)
- func (i *Interface) SetSkip()
- func (i *Interface) TypeKey() string
- func (i *Interface) TypeName() string
- func (i *Interface) Validate(ctx context.Context, sys *system.System) []TestResult
- type InterfaceMap
- type KernelParam
- func (k *KernelParam) GetMeta() meta
- func (k *KernelParam) GetName() string
- func (k *KernelParam) GetTitle() string
- func (k *KernelParam) ID() string
- func (a *KernelParam) SetID(id string)
- func (a *KernelParam) SetSkip()
- func (a *KernelParam) TypeKey() string
- func (a *KernelParam) TypeName() string
- func (k *KernelParam) Validate(ctx context.Context, sys *system.System) []TestResult
- type KernelParamMap
- type Matching
- func (r *Matching) GetMeta() meta
- func (r *Matching) GetTitle() string
- func (a *Matching) ID() string
- func (a *Matching) SetID(id string)
- func (a *Matching) SetSkip()
- func (a *Matching) TypeKey() string
- func (a *Matching) TypeName() string
- func (a *Matching) Validate(ctx context.Context, sys *system.System) []TestResult
- type MatchingMap
- type Mount
- func (m *Mount) GetMeta() meta
- func (m *Mount) GetMountPoint() string
- func (m *Mount) GetTitle() string
- func (m *Mount) ID() string
- func (m *Mount) SetID(id string)
- func (m *Mount) SetSkip()
- func (m *Mount) TypeKey() string
- func (m *Mount) TypeName() string
- func (m *Mount) Validate(ctx context.Context, sys *system.System) []TestResult
- type MountMap
- type Package
- func (p *Package) GetMeta() meta
- func (p *Package) GetName() string
- func (p *Package) GetTitle() string
- func (p *Package) ID() string
- func (p *Package) SetID(id string)
- func (p *Package) SetSkip()
- func (p *Package) TypeKey() string
- func (p *Package) TypeName() string
- func (p *Package) Validate(ctx context.Context, sys *system.System) []TestResult
- type PackageMap
- type Port
- func (p *Port) GetMeta() meta
- func (p *Port) GetPort() string
- func (p *Port) GetTitle() string
- func (p *Port) ID() string
- func (p *Port) SetID(id string)
- func (p *Port) SetSkip()
- func (p *Port) TypeKey() string
- func (p *Port) TypeName() string
- func (p *Port) Validate(ctx context.Context, sys *system.System) []TestResult
- type PortMap
- type Process
- func (p *Process) GetComm() string
- func (p *Process) GetMeta() meta
- func (p *Process) GetTitle() string
- func (p *Process) ID() string
- func (p *Process) SetID(id string)
- func (p *Process) SetSkip()
- func (p *Process) TypeKey() string
- func (p *Process) TypeName() string
- func (p *Process) Validate(ctx context.Context, sys *system.System) []TestResult
- type ProcessMap
- type Registry
- func (r *Registry) GetMeta() meta
- func (r *Registry) GetName() string
- func (r *Registry) GetTitle() string
- func (r *Registry) ID() string
- func (r *Registry) SetID(id string)
- func (r *Registry) SetSkip()
- func (r *Registry) TypeKey() string
- func (r *Registry) TypeName() string
- func (r *Registry) Validate(ctx context.Context, sys *system.System) []TestResult
- type RegistryMap
- type Resource
- type ResourceMap
- func (r ResourceMap[T, ST, PT]) AppendSysResource(sr string, sys *system.System, config util.Config) (PT, error)
- func (r ResourceMap[T, ST, PT]) AppendSysResourceIfExists(sr string, sys *system.System) (PT, ST, bool, error)
- func (ret *ResourceMap[T, ST, PT]) UnmarshalJSON(data []byte) error
- func (ret *ResourceMap[T, ST, PT]) UnmarshalYAML(unmarshal func(v interface{}) error) error
- type ResourceRead
- type Service
- func (s *Service) GetMeta() meta
- func (s *Service) GetName() string
- func (s *Service) GetTitle() string
- func (s *Service) ID() string
- func (s *Service) SetID(id string)
- func (s *Service) SetSkip()
- func (s *Service) TypeKey() string
- func (s *Service) TypeName() string
- func (s *Service) Validate(ctx context.Context, sys *system.System) []TestResult
- type ServiceMap
- type Source
- type Syverfile
- func (g *Syverfile) GetMeta() meta
- func (g *Syverfile) GetSkip() bool
- func (g *Syverfile) GetSyverfile() string
- func (g *Syverfile) GetTitle() string
- func (g *Syverfile) ID() string
- func (g *Syverfile) SetID(id string)
- func (g *Syverfile) SetSkip()
- func (g *Syverfile) TypeKey() string
- func (g *Syverfile) TypeName() string
- func (g *Syverfile) Validate(ctx context.Context, sys *system.System) []TestResult
- type SyverfileMap
- type TestResult
- func SkipResourceResults(res Resource, reason string) []TestResult
- func ValidateGomegaValue(res ResourceRead, property string, expectedValue any, actual any, skip bool) TestResult
- func ValidateSafe(ctx context.Context, res Resource, sys *system.System) (results []TestResult)
- func ValidateValue(res ResourceRead, property string, expectedValue any, actual any, skip bool) TestResult
- type TypedResourceRead
- type User
- func (u *User) GetMeta() meta
- func (u *User) GetTitle() string
- func (u *User) GetUsername() string
- func (u *User) ID() string
- func (u *User) SetID(id string)
- func (u *User) SetSkip()
- func (u *User) TypeKey() string
- func (u *User) TypeName() string
- func (u *User) Validate(ctx context.Context, sys *system.System) []TestResult
- type UserMap
- type ValidateError
Constants ¶
const ( AddrResourceKey = "addr" AddrResourceName = "Addr" )
const ( CommandResourceKey = "command" CommandResourceName = "Command" )
const ( DNSResourceKey = "dns" DNSResourceName = "DNS" )
const ( FileResourceKey = "file" FileResourceName = "File" )
const ( GroupResourceKey = "group" GroupResourceName = "Group" )
const ( HTTPResourceKey = "http" HTTPResourceName = "HTTP" )
const ( InterfaceResourceKey = "interface" InterfaceResourceName = "Interface" )
const ( KernelParamResourceKey = "kernel-param" KernelParamResourceName = "KernelParam" )
const ( MatchingResourceKey = "matching" MatchingResourceName = "Matching" )
const ( MountResourceKey = "mount" MountResourceName = "Mount" )
const ( PackageResourceKey = "package" PackageResourceName = "Package" )
const ( PortResourceKey = "port" PortResourceName = "Port" )
const ( ProcessResourceKey = "process" ProcessResourceName = "Process" )
const ( RegistryResourceKey = "registry" RegistryResourceName = "Registry" )
const ( ServiceResourceKey = "service" ServiceResourceName = "Service" )
const ( SyverFileResourceKey = "gossfile" SyverFileResourceName = "Gossfile" )
const ( UserResourceKey = "user" UserResourceName = "User" )
const ( Value = iota Values Contains )
const ( SUCCESS = iota FAIL SKIP UNKNOWN )
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 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 ¶
Resources returns the deprecated key->Resource map. Deprecated: use Descriptors() and Descriptor.New() instead.
func UpsertLive ¶ added in v0.8.0
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 ¶
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 (*Addr) GetAddress ¶
type AppendFn ¶ added in v0.8.0
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
}
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 (*DNS) GetResolve ¶
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 ¶
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
}
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 (*Group) GetGroupname ¶
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
}
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 ¶
type InterfaceMap ¶
type InterfaceMap = ResourceMap[Interface, system.Interface, *Interface]
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 KernelParamMap ¶
type KernelParamMap = ResourceMap[KernelParam, system.KernelParam, *KernelParam]
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) 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.
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 (*Mount) GetMountPoint ¶
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
}
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
}
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
}
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"`
// View selects the WOW64 registry view: "32", "64" or "native".
//
// omitempty is load-bearing twice over. It keeps the attribute out of every
// gossfile that does not use it, so no golden changes and no existing spec
// gains a field it never asked for; and empty parses as native, which is
// exactly the behaviour that existed before this attribute did.
View string `json:"view,omitempty" yaml:"view,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 ¶
type RegistryMap ¶
type RegistryMap = ResourceMap[Registry, system.Registry, *Registry]
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 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
}
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.
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 (*Syverfile) GetSyverfile ¶
type SyverfileMap ¶
type SyverfileMap = ResourceMap[Syverfile, system.Syverfile, *Syverfile]
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
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 (*User) GetUsername ¶
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