Documentation ¶
Overview ¶
nolint
nolint
nolint
Index ¶
- Constants
- Variables
- func DefaultSetOpts(opts map[string]cty.Value, pendingOptions []PendingInput) error
- func GenerateShim(variantBin, dir string) error
- func Getenv(name string)
- func IsExpressionEmpty(ex hcl2.Expression) bool
- func MakeQuestions(pendingOptions []PendingInput) ([]*survey.Question, map[string]survey.Transformer, error)
- func NewImportFunc(importBaseDir string, f func(string) (*App, error)) func(string) (*App, error)
- func Open(name string)
- func SetLogger(impl Interface)
- func SetOptsFromMap(transformers map[string]survey.Transformer, opts map[string]cty.Value, ...) error
- func Stat(name string)
- type App
- func (app *App) ExitWithError(err error)
- func (app *App) ExportBinary(srcDir, dstFile string) error
- func (app *App) ExportGo(srcDir, dstDir string) error
- func (app *App) ExportShim(srcDir, dstDir string) error
- func (app *App) Job(jobCtx *JobContext, l *EventLogger, cmd string, args map[string]interface{}, ...) (func() (*Result, error), error)
- func (app *App) PrintDiags(err error)
- func (app *App) PrintError(err error)
- func (app *App) Run(cmd string, args map[string]interface{}, opts map[string]interface{}, ...) (*Result, error)
- func (app *App) RunTests(pat string) (*Result, error)
- func (app *App) WriteDiags(diagnostics hcl2.Diagnostics)
- type Arg
- type Assert
- type Case
- type Collect
- type Command
- type Config
- type ConfigSource
- type DependsOn
- type DynamicRun
- type EnvSource
- type Event
- type EventLogger
- type Exec
- type ExecEvent
- type Expect
- type Forward
- type HCL2Config
- type Instance
- type Interface
- type JobContext
- type JobSpec
- type LazyDynamicRun
- type LazyStaticRun
- type Log
- type LogCollector
- type LogSpec
- type Option
- type OptionSpec
- type Options
- type Parameter
- type PendingInput
- type Result
- type RunEvent
- type SetOptsFunc
- type Setup
- type Source
- type SourceFile
- type SourceJob
- type StaticRun
- type Step
- type Test
- type TestDeps
- func (TestDeps) ImportPath() string
- func (TestDeps) MatchString(pat, str string) (result bool, err error)
- func (TestDeps) SetPanicOnExit0(bool)
- func (TestDeps) StartCPUProfile(w io.Writer) error
- func (TestDeps) StartTestLog(w io.Writer)
- func (TestDeps) StopCPUProfile()
- func (TestDeps) StopTestLog() error
- func (TestDeps) WriteProfileTo(name string, w io.Writer, debug int) error
- type Variable
Constants ¶
View Source
const ( NoRunMessage = "nothing to run" FormatYAML = "yaml" FormatText = "text" )
View Source
const (
DefaultCacheDir = ".variant2/cache"
)
Variables ¶
View Source
var ImportPath string
ImportPath is the import path of the testing binary, set by the generated main function.
Functions ¶
func DefaultSetOpts ¶ added in v0.13.0
func DefaultSetOpts(opts map[string]cty.Value, pendingOptions []PendingInput) error
func GenerateShim ¶
func IsExpressionEmpty ¶
func IsExpressionEmpty(ex hcl2.Expression) bool
func MakeQuestions ¶ added in v0.13.0
func MakeQuestions(pendingOptions []PendingInput) ([]*survey.Question, map[string]survey.Transformer, error)
func NewImportFunc ¶ added in v0.32.0
func SetLogger ¶
func SetLogger(impl Interface)
SetLogger sets the test logger implementation for the current process. It must be called only once, at process startup.
func SetOptsFromMap ¶ added in v0.13.0
Types ¶
type App ¶
type App struct { BinName string Files map[string]*hcl.File Config *HCL2Config JobByName map[string]JobSpec Stdout, Stderr io.Writer Trace string Funcs map[string]function.Function JobLocalFuncs map[string]map[string]function.Function // contains filtered or unexported fields }
func (*App) ExitWithError ¶
func (*App) ExportBinary ¶
func (*App) ExportShim ¶
func (*App) Job ¶
func (app *App) Job(jobCtx *JobContext, l *EventLogger, cmd string, args map[string]interface{}, opts map[string]interface{}, f SetOptsFunc, streamOutput bool) (func() (*Result, error), error)
func (*App) PrintDiags ¶ added in v0.21.0
func (*App) PrintError ¶
func (*App) WriteDiags ¶
func (app *App) WriteDiags(diagnostics hcl2.Diagnostics)
type Assert ¶
type Assert struct { Name string `hcl:"name,label"` Condition hcl.Expression `hcl:"condition,attr"` }
type Collect ¶
type Collect struct { Condition hcl.Expression `hcl:"condition,attr"` Format hcl.Expression `hcl:"format,attr"` }
type Config ¶
type Config struct { Name string `hcl:"name,label"` Sources []ConfigSource `hcl:"source,block"` }
type ConfigSource ¶ added in v0.36.0
type ConfigSource struct { Type string `hcl:"type,label"` Body hcl.Body `hcl:",remain"` }
type DependsOn ¶ added in v0.20.0
type DependsOn struct { Name string `hcl:"name,label"` Items hcl.Expression `hcl:"items,attr"` Args hcl.Expression `hcl:"args,attr"` }
type DynamicRun ¶ added in v0.22.0
type DynamicRun struct { Job string `hcl:"job,attr"` Args hcl.Expression `hcl:"with,attr"` Condition hcl.Expression `hcl:"condition,attr"` }
type EventLogger ¶
type EventLogger struct { Command string Args, Opts map[string]interface{} Stream string Stderr io.Writer Events []Event // contains filtered or unexported fields }
func NewEventLogger ¶
func NewEventLogger(cmd string, args map[string]interface{}, opts map[string]interface{}) *EventLogger
func (*EventLogger) LogRun ¶
func (l *EventLogger) LogRun(job string, args map[string]interface{}) error
func (*EventLogger) Register ¶
func (l *EventLogger) Register(logCollector LogCollector) func() error
type Exec ¶
type Exec struct { Command hcl.Expression `hcl:"command,attr"` Args hcl.Expression `hcl:"args,attr"` Env hcl.Expression `hcl:"env,attr"` Dir hcl.Expression `hcl:"dir,attr"` Interactive *bool `hcl:"interactive,attr"` }
type Expect ¶ added in v0.28.0
type Expect struct { // Type must be `exec` for now Type string `hcl:"type,label"` Command hcl.Expression `hcl:"command,attr"` Args hcl.Expression `hcl:"args,attr"` Dir hcl.Expression `hcl:"dir,attr"` }
type HCL2Config ¶
type Interface ¶
type Interface interface { Getenv(key string) Stat(file string) Open(file string) Chdir(dir string) }
Interface is the interface required of test loggers. The os package will invoke the interface's methods to indicate that it is inspecting the given environment variables or files. Multiple goroutines may call these methods simultaneously.
type JobContext ¶ added in v0.23.0
type JobContext struct {
// contains filtered or unexported fields
}
func (JobContext) Ptr ¶ added in v0.26.0
func (c JobContext) Ptr() *JobContext
func (*JobContext) WithEvalContext ¶ added in v0.26.0
func (c *JobContext) WithEvalContext(evalCtx *hcl2.EvalContext) JobContext
func (*JobContext) WithVariable ¶ added in v0.26.0
func (c *JobContext) WithVariable(name string, v cty.Value) JobContext
type JobSpec ¶
type JobSpec struct { // Type string `hcl:"type,label"` Name string `hcl:"name,label"` Version *string `hcl:"version,attr"` Module hcl.Expression `hcl:"module,attr"` Description *string `hcl:"description,attr"` Parameters []Parameter `hcl:"parameter,block"` Options []OptionSpec `hcl:"option,block"` Configs []Config `hcl:"config,block"` Secrets []Config `hcl:"secret,block"` Variables []Variable `hcl:"variable,block"` Concurrency hcl.Expression `hcl:"concurrency,attr"` SourceLocator hcl.Expression `hcl:"__source_locator,attr"` Deps []DependsOn `hcl:"depends_on,block"` Exec *Exec `hcl:"exec,block"` Assert []Assert `hcl:"assert,block"` Fail hcl.Expression `hcl:"fail,attr"` Import *string `hcl:"import,attr"` Imports *[]string `hcl:"imports,attr"` // Private hides the job from `variant run -h` when set to true Private *bool `hcl:"private,attr"` Log *LogSpec `hcl:"log,block"` Steps []Step `hcl:"step,block"` Body hcl.Body `hcl:",remain"` Sources []Source `hcl:"source,block"` }
type LazyDynamicRun ¶ added in v0.22.0
type LazyDynamicRun struct {
Run []DynamicRun `hcl:"run,block"`
}
type LazyStaticRun ¶ added in v0.22.0
type LazyStaticRun struct {
Run []StaticRun `hcl:"run,block"`
}
type LogCollector ¶
type Option ¶ added in v0.34.0
type Option func(options *Options)
func WithCacheDir ¶ added in v0.34.0
type OptionSpec ¶
type PendingInput ¶ added in v0.23.0
type Result ¶
type Result struct { Stdout string Stderr string Undefined bool Skipped bool // Cancelled is set to true when and only when the original command execution has been scheduled concurrently, // but was cancelled before it was actually executed. Cancelled bool // Validated is set to true when and only when the command execution was successfully validated against the mock Validated bool ExitStatus int }
type SetOptsFunc ¶ added in v0.13.0
type SetOptsFunc func(opts map[string]cty.Value, pendingOptions []PendingInput) error
type Setup ¶ added in v0.33.0
func FromSources ¶ added in v0.33.0
type Source ¶
type Source struct { ID string `hcl:"id,label"` // Kind is the kind of source-controller source kind like "GitRepository" and "Bucket" Kind string `hcl:"kind,attr"` // Namespace is the K8s namespace of the source-controller source Namepsace string `hcl:"namespace,attr"` // Name defaults to ID Name string `hcl:"name,attr"` }
type SourceFile ¶
type TestDeps ¶
type TestDeps struct{}
TestDeps is an implementation of the testing.testDeps interface, suitable for passing to testing.MainStart.
func (TestDeps) ImportPath ¶
func (TestDeps) SetPanicOnExit0 ¶ added in v0.38.0
func (TestDeps) StartTestLog ¶
func (TestDeps) StopCPUProfile ¶
func (TestDeps) StopCPUProfile()
func (TestDeps) StopTestLog ¶
Click to show internal directories.
Click to hide internal directories.