Documentation
¶
Index ¶
- Constants
- func AddResource(fileName string, syverConfig SyverConfig, resourceName, key string, ...) error
- func AddResources(fileName, resourceName string, keys []string, c *util.Config) error
- func AutoAddResource(fileName string, syverConfig SyverConfig, key string, c *util.Config, ...) error
- func AutoAddResources(fileName string, keys []string, c *util.Config) error
- func NewTemplateFilter(varsFiles []string, varsInline string, discovered map[string]bool) (func([]byte) ([]byte, error), error)
- func RenderJSON(c *util.Config) (string, error)
- func Serve(ctx context.Context, c *util.Config) error
- func Validate(ctx context.Context, c *util.Config) (code int, err error)
- func ValidateConfig(ctx context.Context, c *util.Config, syverConfig *SyverConfig) (code int, err error)
- func ValidateResults(ctx context.Context, c *util.Config) (results <-chan []resource.TestResult, err error)
- func ValidateVarsInline(s string) error
- func WriteJSON(filePath string, syverConfig SyverConfig) error
- type DiscoveryConfig
- type DiscoveryEntry
- type SyverConfig
- type TemplateFilter
- type TmplVars
Constants ¶
const ( UNSET = iota JSON YAML )
Variables ¶
This section is empty.
Functions ¶
func AddResource ¶
func AddResource(fileName string, syverConfig SyverConfig, resourceName, key string, config util.Config, sys *system.System) error
AddResource adds a single resource to fileName.
FEAT-007 G1: this used to be a 16-case switch on resourceName, each case hand-calling syverConfig.<Field>.AppendSysResource(...) directly. That's replaced with a descriptor lookup by Name (desc.AppendSys, which closes over the type-specific system+resource construction -- see resource/descriptor.go) plus resource.UpsertLive, which needs to know *which* SyverConfig field to insert into without resource-package code ever importing SyverConfig (the two packages can't import each other). configAccessors[desc.Key].Field supplies that: a pointer to the live struct field, e.g. &syverConfig.Ports -- not a copy, so the new resource actually lands in the file WriteJSON writes below. Using the Get member here instead (a snapshot copy) was the exact trap this spec calls out: `syver add` would silently stop writing new resources.
func AddResources ¶
AddResources is a simple wrapper to add multiple resources
func AutoAddResource ¶
func AutoAddResource(fileName string, syverConfig SyverConfig, key string, c *util.Config, sys *system.System) error
AutoAddResource adds a single resource to fileName with automatic detection of the type of resource
func AutoAddResources ¶
AutoAddResources is a simple wrapper to add multiple resources
func NewTemplateFilter ¶
func NewTemplateFilter(varsFiles []string, varsInline string, discovered map[string]bool) (func([]byte) ([]byte, error), error)
NewTemplateFilter creates a new Template Filter based in the file and inline variables.
func RenderJSON ¶
RenderJSON reads json file recursively returning string
func Validate ¶
Validate performs validation, writes formatted output to stdout by default and supports retries and more, this is the full featured Validate used by the CLI invocation and will produce output to StdOut. Use ValidateResults for programmatic access
func ValidateConfig ¶
func ValidateResults ¶
func ValidateResults(ctx context.Context, c *util.Config) (results <-chan []resource.TestResult, err error)
ValidateResults performs validation and provides programmatic access to validation results no retries or outputs are supported
func ValidateVarsInline ¶ added in v0.11.0
ValidateVarsInline reports whether s is usable as the value of --vars-inline, without keeping the parsed result.
It exists so the CLI can reject a bad value AT FLAG-PARSE TIME rather than several steps later while loading vars. The difference is not cosmetic. A shell that mangles the argument -- cmd.exe does, because it does not treat `'` as a quote character -- leaves syver holding a fragment plus a stray argument, and the stray one is then read as a subcommand, so the user gets a "No help topic" error naming that fragment, pointing nowhere near the flag. Validating here makes the message name --vars-inline and quote the value it actually received, which is what tells someone their shell split the command line.
func WriteJSON ¶
func WriteJSON(filePath string, syverConfig SyverConfig) error
Types ¶
type DiscoveryConfig ¶
type DiscoveryConfig struct {
Files resource.FileMap `json:"file,omitempty" yaml:"file,omitempty"`
Packages resource.PackageMap `json:"package,omitempty" yaml:"package,omitempty"`
Addrs resource.AddrMap `json:"addr,omitempty" yaml:"addr,omitempty"`
Ports resource.PortMap `json:"port,omitempty" yaml:"port,omitempty"`
Services resource.ServiceMap `json:"service,omitempty" yaml:"service,omitempty"`
Users resource.UserMap `json:"user,omitempty" yaml:"user,omitempty"`
Groups resource.GroupMap `json:"group,omitempty" yaml:"group,omitempty"`
Commands resource.CommandMap `json:"command,omitempty" yaml:"command,omitempty"`
DNS resource.DNSMap `json:"dns,omitempty" yaml:"dns,omitempty"`
Processes resource.ProcessMap `json:"process,omitempty" yaml:"process,omitempty"`
KernelParams resource.KernelParamMap `json:"kernel-param,omitempty" yaml:"kernel-param,omitempty"`
Mounts resource.MountMap `json:"mount,omitempty" yaml:"mount,omitempty"`
Interfaces resource.InterfaceMap `json:"interface,omitempty" yaml:"interface,omitempty"`
HTTPs resource.HTTPMap `json:"http,omitempty" yaml:"http,omitempty"`
Matchings resource.MatchingMap `json:"matching,omitempty" yaml:"matching,omitempty"`
Registries resource.RegistryMap `json:"registry,omitempty" yaml:"registry,omitempty"`
}
DiscoveryConfig holds discovery-phase tests keyed by resource type.
func (*DiscoveryConfig) Entries ¶
func (c *DiscoveryConfig) Entries() ([]DiscoveryEntry, error)
func (*DiscoveryConfig) IsEmpty ¶
func (c *DiscoveryConfig) IsEmpty() bool
func (*DiscoveryConfig) Merge ¶
func (c *DiscoveryConfig) Merge(g2 DiscoveryConfig)
type DiscoveryEntry ¶
DiscoveryEntry pairs a register name with a discovery resource.
type SyverConfig ¶
type SyverConfig struct {
Discovery DiscoveryConfig `json:"discovery,omitempty" yaml:"discovery,omitempty"`
Files resource.FileMap `json:"file,omitempty" yaml:"file,omitempty"`
Packages resource.PackageMap `json:"package,omitempty" yaml:"package,omitempty"`
Addrs resource.AddrMap `json:"addr,omitempty" yaml:"addr,omitempty"`
Ports resource.PortMap `json:"port,omitempty" yaml:"port,omitempty"`
Services resource.ServiceMap `json:"service,omitempty" yaml:"service,omitempty"`
Users resource.UserMap `json:"user,omitempty" yaml:"user,omitempty"`
Groups resource.GroupMap `json:"group,omitempty" yaml:"group,omitempty"`
Commands resource.CommandMap `json:"command,omitempty" yaml:"command,omitempty"`
DNS resource.DNSMap `json:"dns,omitempty" yaml:"dns,omitempty"`
Processes resource.ProcessMap `json:"process,omitempty" yaml:"process,omitempty"`
Syverfiles resource.SyverfileMap `json:"gossfile,omitempty" yaml:"gossfile,omitempty"`
// SyverfileAlias is an input-only alias for Syverfiles: a gossfile
// written with `syverfile:` entries decodes here, gets folded into
// Syverfiles (see ReadJSONData in store.go), and is then nil'd out --
// it is never itself written back out (omitempty drops it once nil).
//
// NOTE (FEAT-007): this field intentionally has no dispatch.go
// accessor entry and is never touched by the configAccessors loops
// below -- it isn't a registered resource type, it's pure store.go
// decode plumbing (see store.go:255-268). Handled explicitly here,
// same as before the refactor.
SyverfileAlias resource.SyverfileMap `json:"syverfile,omitempty" yaml:"syverfile,omitempty"`
KernelParams resource.KernelParamMap `json:"kernel-param,omitempty" yaml:"kernel-param,omitempty"`
Mounts resource.MountMap `json:"mount,omitempty" yaml:"mount,omitempty"`
Interfaces resource.InterfaceMap `json:"interface,omitempty" yaml:"interface,omitempty"`
HTTPs resource.HTTPMap `json:"http,omitempty" yaml:"http,omitempty"`
Matchings resource.MatchingMap `json:"matching,omitempty" yaml:"matching,omitempty"`
Registries resource.RegistryMap `json:"registry,omitempty" yaml:"registry,omitempty"`
}
func NewSyverConfig ¶
func NewSyverConfig() *SyverConfig
NewSyverConfig builds an empty SyverConfig with every map field initialised (FEAT-007: replaces two 16-entry make() blocks with a loop over configAccessors/discoveryAccessors). gossfile has no accessor Make (see the accessor table's comment in dispatch.go) so Syverfiles and SyverfileAlias are still made explicitly, exactly as before.
func ReadJSON ¶
func ReadJSON(filePath string) (SyverConfig, error)
ReadJSON Reads json file returning SyverConfig
func ReadJSONData ¶
func ReadJSONData(data []byte, detectFormat bool, path string) (SyverConfig, error)
ReadJSONData Reads json byte array returning SyverConfig. path names the spec this data came from and is used only for the top-level key guard's warnings below (D7 in PLAN_toplevel_key_guard.md) -- pass "" if there is none (e.g. content assembled in memory rather than read from a file).
func (*SyverConfig) Merge ¶
func (c *SyverConfig) Merge(g2 SyverConfig)
Merge consumes all the resources in g2 into c, duplicate resources will be overwritten with the ones in g2
func (*SyverConfig) Resources ¶
func (c *SyverConfig) Resources() []resource.Resource
Resources returns every validation-eligible resource (FEAT-007: replaces the 16-argument genericConcatMaps call with a loop over resourceOrder; see the accessor table's InValidation field, which is what "eligible" means here -- gossfile is the one registered type excluded).
type TemplateFilter ¶
TemplateFilter is the type of the Goss Template Filter which include custom variables and functions.
func NewPeekTemplateFilter ¶
func NewPeekTemplateFilter(varsFiles []string, varsInline string) (TemplateFilter, error)
NewPeekTemplateFilter renders templates before discovery results exist. Missing .Discovered keys evaluate as false instead of failing template execution.