Documentation
¶
Index ¶
- Constants
- Variables
- func IsValueInList(value string, list []string) bool
- func ValidateSections(unmarshal func(any) error, i any, whitelist map[string]bool) error
- func WhitelistAttrs(i any, format format) (map[string]bool, error)
- type Command
- type Config
- type ConfigOption
- func WithCache(d time.Duration) ConfigOption
- func WithColor() ConfigOption
- func WithDisabledResourceTypes(t ...string) ConfigOption
- func WithDiscoverFile(f string) ConfigOption
- func WithFormatOptions(opts ...string) ConfigOption
- func WithMaxConcurrency(mc int) ConfigOption
- func WithNoColor() ConfigOption
- func WithOutputFormat(f string) ConfigOption
- func WithResultWriter(w io.Writer) ConfigOption
- func WithSpecFile(f string) ConfigOption
- func WithVarsBytes(v []byte) ConfigOption
- func WithVarsData(v any) ConfigOption
- func WithVarsFile(file string) ConfigOption
- func WithVarsFiles(files []string) ConfigOption
- func WithVarsString(v string) ConfigOption
- type OutputConfig
Constants ¶
const ( JSON format = "json" YAML format = "yaml" )
Variables ¶
var Version string
Functions ¶
func IsValueInList ¶
func ValidateSections ¶
Types ¶
type Command ¶
type Command struct {
Cmd *exec.Cmd
Stdout, Stderr bytes.Buffer
Err error
Status int
// contains filtered or unexported fields
}
func NewCommandContext ¶
NewCommandContext builds a command bound to ctx, so that cancelling the context kills the child process. There is deliberately no context-free constructor: a child with no cancellation and no bound wedges `serve`'s health endpoint for the life of the process, see system/helper_command.go.
Only the `command:` resource needs this, because it is the only caller that imposes a timeout. runCommand (system/command.go) used to return on timeout while leaving the child running and its goroutine parked in Wait: the process was never signalled, so a command that hangs leaked one process and one goroutine every time it ran. Under `serve` that is once per cache refresh for the life of the daemon.
Killing via the context rather than calling Process.Kill from the timeout goroutine avoids racing on Cmd.Process, which Start writes and Wait consumes.
type Config ¶
type Config struct {
AllowInsecure bool
AnnounceToCLI bool
Cache time.Duration
Debug bool
Endpoint string
FormatOptions []string
IgnoreList []string
ListenAddress string
LocalAddress string
LogLevel string
MaxConcurrent int
Method string
NoColor *bool
NoFollowRedirects bool
OutputFormat string
OutputWriter io.Writer
PackageManager string
Password string
RequestBody string
Proxy string
RequestHeader []string
RequestQueryParams map[string][]string
RetryTimeout time.Duration
RunLevel string
Server string
Sleep time.Duration
Spec string
Timeout time.Duration
Username string
CAFile string
CertFile string
KeyFile string
VarsFiles []string
VarsInline string
DiscoverSpec string
DisabledResourceTypes []string
}
Config is the runtime configuration for syver. The CLI converts its cli.Command into a Config, which the add, validate, serve and render paths then read.
NewConfig creates one with defaults modeled on the CLI's, adjusted by ConfigOption functions.
func NewConfig ¶
func NewConfig(opts ...ConfigOption) (rc *Config, err error)
NewConfig creates a default configuration modeled on the defaults the CLI sets, modified using opts
func (*Config) TimeOutMilliSeconds ¶
TimeOutMilliSeconds is the timeout as milliseconds
type ConfigOption ¶
ConfigOption manipulates Config
func WithCache ¶
func WithCache(d time.Duration) ConfigOption
WithCache sets how long results may be cached for
func WithDisabledResourceTypes ¶
func WithDisabledResourceTypes(t ...string) ConfigOption
WithDisabledResourceTypes ensures that any resource matching types listed will be skipped when validating
func WithDiscoverFile ¶
func WithDiscoverFile(f string) ConfigOption
WithDiscoverFile sets a gossfile whose discovery: section runs before the main -g spec
func WithFormatOptions ¶
func WithFormatOptions(opts ...string) ConfigOption
WithFormatOptions sets options used by the output format plugins, valid options are output.WithFormatOptions
func WithMaxConcurrency ¶
func WithMaxConcurrency(mc int) ConfigOption
WithMaxConcurrency is the maximum concurrent test that can be run. It must be at least 1: with no worker a run checks nothing and reports success.
func WithOutputFormat ¶
func WithOutputFormat(f string) ConfigOption
WithOutputFormat is the formatter to use for output
func WithResultWriter ¶
func WithResultWriter(w io.Writer) ConfigOption
WithResultWriter sets the writer to write output format to when validating
func WithSpecFile ¶
func WithSpecFile(f string) ConfigOption
WithSpecFile sets the path to the file holding spec contents
func WithVarsBytes ¶
func WithVarsBytes(v []byte) ConfigOption
WithVarsBytes is a yaml or json byte stream to use as variables passed to the Validator
func WithVarsData ¶
func WithVarsData(v any) ConfigOption
WithVarsData uses v as variables to pass to the Validator
func WithVarsFile ¶
func WithVarsFile(file string) ConfigOption
WithVarsFile is a json or yaml file containing variables to pass to the validator
func WithVarsFiles ¶
func WithVarsFiles(files []string) ConfigOption
WithVarsFiles are json or yaml files containing variables to pass to the validator
func WithVarsString ¶
func WithVarsString(v string) ConfigOption
WithVarsString is a yaml or json string to use as variables passed to the Validator
type OutputConfig ¶
type OutputConfig struct {
FormatOptions []string
}