syver

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func AddResources(fileName, resourceName string, keys []string, c *util.Config) error

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

func AutoAddResources(fileName string, keys []string, c *util.Config) error

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

func RenderJSON(c *util.Config) (string, error)

RenderJSON reads json file recursively returning string

func Serve

func Serve(ctx context.Context, c *util.Config) error

func Validate

func Validate(ctx context.Context, c *util.Config) (code int, err error)

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 ValidateConfig(ctx context.Context, c *util.Config, syverConfig *SyverConfig) (code int, err error)

func ValidateMaxConcurrent

func ValidateMaxConcurrent(n int) error

ValidateMaxConcurrent rejects a --max-concurrent below 1. It is the flag's Validator on both validate and serve.

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

func ValidateVarsInline(s string) error

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"`
	PkgBaselines resource.PkgBaselineMap `json:"pkg-baseline,omitempty" yaml:"pkg-baseline,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

type DiscoveryEntry struct {
	Register string
	Resource resource.Resource
}

DiscoveryEntry pairs a register name with a discovery resource.

type SyverConfig

type SyverConfig struct {
	// SyverVersion is the minimum Syver release this file was written for.
	// Declaring the key also makes unknown top-level keys in this file an
	// error. It is not a resource type and has no accessor: Merge leaves it
	// alone, and mergeJSONData carries the highest value across includes.
	// First in the struct so a marshalled spec writes it at the top.
	SyverVersion string `json:"syver-version,omitempty" yaml:"syver-version,omitempty"`

	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"`
	PkgBaselines   resource.PkgBaselineMap `json:"pkg-baseline,omitempty" yaml:"pkg-baseline,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 wiring'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 in the top-level key guard's warnings and errors below, so an included gossfile's message names that file rather than its parent -- 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 resource.Descriptor's InValidation field, which is what "eligible" means here -- gossfile is the one registered type excluded).

type TemplateFilter

type TemplateFilter func([]byte) ([]byte, error)

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.

type TmplVars

type TmplVars struct {
	Vars       map[string]any
	Discovered map[string]any
}

func (*TmplVars) Env

func (t *TmplVars) Env() map[string]string

Jump to

Keyboard shortcuts

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