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 WithDebug() 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 WithPackageManager(p string) ConfigOption
- func WithResultWriter(w io.Writer) ConfigOption
- func WithRetryTimeout(d time.Duration) ConfigOption
- func WithSleep(d time.Duration) 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 NewCommand ¶
func NewCommandContext ¶
NewCommandContext is NewCommand with a context attached, so that cancelling the context kills the child process.
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 the goss system, the cli.Command gets converted to this and it allows other packages to embed goss by creating this structure and using it when adding, validating etc.
NewConfig can be used to create this which will default to what the CLI assumes and allow manipulation via 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
func WithOutputFormat ¶
func WithOutputFormat(f string) ConfigOption
WithOutputFormat is the formatter to use for output
func WithPackageManager ¶
func WithPackageManager(p string) ConfigOption
WithPackageManager overrides the package manager to use
func WithResultWriter ¶
func WithResultWriter(w io.Writer) ConfigOption
WithResultWriter sets the writer to write output format to when validating
func WithRetryTimeout ¶
func WithRetryTimeout(d time.Duration) ConfigOption
WithRetryTimeout sets the maximum amount of time checks can be retried, it's runtime + WithSleep
func WithSleep ¶
func WithSleep(d time.Duration) ConfigOption
WithSleep sets the time to sleep between retries when WithRetryTimeout is set
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
}