variant

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgsFromEnvVars added in v0.35.0

func ArgsFromEnvVars() ([]string, error)

func Int added in v0.26.0

func Int(v int) *int

func Register

func Register(stepLoader StepLoader)

Types

type AnyMap

type AnyMap map[string]interface{}

type Application

type Application struct {
	Name                string
	CommandRelativePath string
	CachedTaskOutputs   map[string]interface{}
	ConfigFile          string
	Verbose             bool
	Output              string
	Colorize            bool
	NoColorize          bool
	Env                 string
	TaskRegistry        *TaskRegistry
	InputResolver       InputResolver
	TaskNamer           *TaskNamer
	LogToStderr         bool

	LogLevel      string
	LogColorPanic string
	LogColorFatal string
	LogColorError string
	LogColorWarn  string
	LogColorInfo  string
	LogColorDebug string
	LogColorTrace string

	LastRun string

	LastOutputs map[string]string

	Viper *viper.Viper

	Log *logrus.Logger

	ConfigContexts []string
	ConfigDirs     []string
	CommandName    string
}

func (*Application) Color added in v0.34.0

func (p *Application) Color() bool

func (Application) DirectInputValuesForTaskKey

func (p Application) DirectInputValuesForTaskKey(taskName TaskName, args []string, arguments task.Arguments, scope map[string]interface{}, caller ...*Task) (map[string]interface{}, error)

func (Application) GetTmplOrTypedValueForConfigKey

func (p Application) GetTmplOrTypedValueForConfigKey(k string, tpe string, bindEnvVars bool) interface{}

func (Application) InheritedInputValuesForTaskKey

func (p Application) InheritedInputValuesForTaskKey(taskName TaskName, args []string, arguments task.Arguments, scope map[string]interface{}, caller ...*Task) (map[string]interface{}, error)

func (*Application) Run added in v0.25.2

func (p *Application) Run(taskName TaskName, args []string) error

func (*Application) RunTask

func (p *Application) RunTask(taskName TaskName, args []string, arguments task.Arguments, scope map[string]interface{}, asInput bool, caller ...*Task) (string, error)

func (*Application) RunTaskForKeyString

func (p *Application) RunTaskForKeyString(keyStr string, args []string, arguments task.Arguments, scope map[string]interface{}, asInput bool, caller ...*Task) (string, error)

func (*Application) Tasks

func (p *Application) Tasks() map[string]*Task

func (*Application) UpdateLoggingConfiguration

func (p *Application) UpdateLoggingConfiguration() error

type Artifact

type Artifact struct {
	Name string
	Path string
	Via  string
}

type Caller

type Caller interface {
	GetKey() Key
}

type CobraAdapter

type CobraAdapter struct {
	// contains filtered or unexported fields
}

func NewCobraAdapter

func NewCobraAdapter(app *Application) *CobraAdapter

func (*CobraAdapter) GenerateAllFlags

func (p *CobraAdapter) GenerateAllFlags()

func (*CobraAdapter) GenerateCommand

func (p *CobraAdapter) GenerateCommand(task *Task, rootCommand *cobra.Command) (*cobra.Command, error)

func (*CobraAdapter) Tasks

func (p *CobraAdapter) Tasks() map[string]*Task

type CobraApp added in v0.26.0

type CobraApp struct {
	VariantApp *Application
	// contains filtered or unexported fields
}

func Init added in v0.26.0

func Init(commandPath string, rootTaskConfig *TaskDef, opts ...Opts) (*CobraApp, error)

func (*CobraApp) Run added in v0.26.0

func (a *CobraApp) Run(args []string) (map[string]string, error)

type CommandError added in v0.25.2

type CommandError struct {
	TaskName TaskName
	Cause    string
	// contains filtered or unexported fields
}

type ExecutionContext

type ExecutionContext struct {
	// contains filtered or unexported fields
}

func NewStepExecutionContext

func NewStepExecutionContext(app Application, taskRunner TaskRunner, taskTemplate *TaskTemplate, asInput bool, trace []*Task) ExecutionContext

func (ExecutionContext) Autodir

func (c ExecutionContext) Autodir() bool

func (ExecutionContext) Autoenv

func (c ExecutionContext) Autoenv() bool

func (ExecutionContext) Caller

func (c ExecutionContext) Caller() []Caller

func (ExecutionContext) GenerateAutoenv

func (c ExecutionContext) GenerateAutoenv() (map[string]string, error)

func (ExecutionContext) Interactive

func (c ExecutionContext) Interactive() bool

func (ExecutionContext) Key

func (c ExecutionContext) Key() Key

func (ExecutionContext) Render

func (c ExecutionContext) Render(expr string, name string) (string, error)

func (ExecutionContext) RunAnotherTask

func (c ExecutionContext) RunAnotherTask(key string, arguments task.Arguments, scope map[string]interface{}) (string, error)

func (ExecutionContext) Values added in v0.29.0

func (c ExecutionContext) Values() map[string]interface{}

func (ExecutionContext) Vars

func (c ExecutionContext) Vars() map[string]interface{}

func (ExecutionContext) WithAdditionalValues added in v0.28.0

func (c ExecutionContext) WithAdditionalValues(vs map[string]interface{}) ExecutionContext

type IfStep

type IfStep struct {
	Name   string
	If     []Step
	Then   []Step
	Else   []Step
	Silent bool
}

func (IfStep) GetName

func (s IfStep) GetName() string

func (IfStep) Run

func (s IfStep) Run(context ExecutionContext) (StepStringOutput, error)

func (IfStep) Silenced added in v0.26.0

func (s IfStep) Silenced() bool

type IfStepLoader

type IfStepLoader struct{}

func NewIfStepLoader

func NewIfStepLoader() IfStepLoader

func (IfStepLoader) LoadStep

func (l IfStepLoader) LoadStep(config StepDef, context LoadingContext) (Step, error)

type InitError added in v0.29.0

type InitError struct {
	// contains filtered or unexported fields
}

func NewInitError added in v0.36.0

func NewInitError(err error) InitError

type Input

type Input struct {
	InputConfig
	TaskKey  TaskName
	FullName string
}

func (*Input) ShortName

func (v *Input) ShortName() string

type InputConfig

type InputConfig struct {
	Name          string                            `yaml:"name,omitempty"`
	Description   string                            `yaml:"description,omitempty"`
	ArgumentIndex *int                              `yaml:"argument-index,omitempty"`
	Type          string                            `yaml:"type,omitempty"`
	Default       interface{}                       `yaml:"default,omitempty"`
	Properties    map[string]map[string]interface{} `yaml:"properties,omitempty"`
	Remainings    map[string]interface{}            `yaml:",inline"`
}

func (*InputConfig) DefaultAsArray

func (c *InputConfig) DefaultAsArray() ([]interface{}, error)

func (*InputConfig) DefaultAsBool

func (c *InputConfig) DefaultAsBool() bool

func (*InputConfig) DefaultAsInt

func (c *InputConfig) DefaultAsInt() int

func (*InputConfig) DefaultAsObject

func (c *InputConfig) DefaultAsObject() (map[string]interface{}, error)

func (*InputConfig) DefaultAsString

func (c *InputConfig) DefaultAsString() string

func (*InputConfig) GoString added in v0.26.0

func (c *InputConfig) GoString() string

func (*InputConfig) JSONSchema

func (c *InputConfig) JSONSchema() map[string]interface{}

func (*InputConfig) Required

func (c *InputConfig) Required() bool

func (*InputConfig) TypeName

func (c *InputConfig) TypeName() string

type InputConfigs added in v0.26.0

type InputConfigs []*InputConfig

func (InputConfigs) GoString added in v0.26.0

func (c InputConfigs) GoString() string

type InputResolver

type InputResolver interface {
	ResolveInputs()
	ResolveInputsForTask(flowDef *Task) []*Input
	ResolveInputsForTaskKey(currentTaskKey TaskName, path string) []*Input
}

func NewRegistryBasedInputResolver

func NewRegistryBasedInputResolver(registry *TaskRegistry, flowKeyCreator *TaskNamer) InputResolver

type InternalError added in v0.36.4

type InternalError struct {
	// contains filtered or unexported fields
}

func NewInternalError added in v0.36.4

func NewInternalError(err error) InternalError

type Key

type Key interface {
	ShortString() string
	Parent() (Key, error)
}

type LoadingContext

type LoadingContext interface {
	LoadStep(config StepDef) (Step, error)
}

type MessageOnlyFormatter

type MessageOnlyFormatter struct {
}

func (*MessageOnlyFormatter) Format

func (f *MessageOnlyFormatter) Format(entry *log.Entry) ([]byte, error)

type OptionConfig

type OptionConfig struct {
	Name        string                            `yaml:"name,omitempty"`
	Description string                            `yaml:"description,omitempty"`
	Type        string                            `yaml:"type,omitempty"`
	Default     interface{}                       `yaml:"default,omitempty"`
	Required    bool                              `yaml:"required,omitempty"`
	Properties  map[string]map[string]interface{} `yaml:"properties,omitempty"`
	Remainings  map[string]interface{}            `yaml:",inline"`
}

type Opts added in v0.26.0

type Opts struct {
	CommandPath string
	Args        []string
	Log         *logrus.Logger

	ExtraCmds []*cobra.Command
}

type OrStep

type OrStep struct {
	Name   string
	Steps  []Step
	Silent bool
}

func (OrStep) GetName

func (s OrStep) GetName() string

func (OrStep) Run

func (s OrStep) Run(context ExecutionContext) (StepStringOutput, error)

func (OrStep) Silenced added in v0.26.0

func (s OrStep) Silenced() bool

type OrStepLoader

type OrStepLoader struct{}

func NewOrStepLoader

func NewOrStepLoader() OrStepLoader

func (OrStepLoader) LoadStep

func (l OrStepLoader) LoadStep(config StepDef, context LoadingContext) (Step, error)

type ParameterConfig

type ParameterConfig struct {
	Name        string                            `yaml:"name,omitempty"`
	Description string                            `yaml:"description,omitempty"`
	Type        string                            `yaml:"type,omitempty"`
	Default     interface{}                       `yaml:"default,omitempty"`
	Required    bool                              `yaml:"required,omitempty"`
	Properties  map[string]map[string]interface{} `yaml:"properties,omitempty"`
	Remainings  map[string]interface{}            `yaml:",inline"`
}

type RegistryBasedInputResolver

type RegistryBasedInputResolver struct {
	InputResolver
	// contains filtered or unexported fields
}

func (*RegistryBasedInputResolver) ResolveInputs

func (r *RegistryBasedInputResolver) ResolveInputs()

func (*RegistryBasedInputResolver) ResolveInputsForTask

func (r *RegistryBasedInputResolver) ResolveInputsForTask(flowDef *Task) []*Input

func (*RegistryBasedInputResolver) ResolveInputsForTaskKey

func (r *RegistryBasedInputResolver) ResolveInputsForTaskKey(currentTaskKey TaskName, path string) []*Input

type RunnerConfig added in v0.26.0

type RunnerConfig struct {
	Image      string
	Command    string
	Entrypoint *string
	Artifacts  []Artifact
	Args       []string
	Envfile    string
	Env        map[string]string
	Volumes    []string
	Net        string
	Workdir    string
}

type ScriptStep

type ScriptStep struct {
	Name         string
	Code         string
	Silent       bool
	RunnerConfig RunnerConfig
}

func (ScriptStep) GetName

func (s ScriptStep) GetName() string

func (ScriptStep) Run

func (ScriptStep) Silenced added in v0.26.0

func (s ScriptStep) Silenced() bool

type ScriptStepLoader

type ScriptStepLoader struct{}

func NewScriptStepLoader

func NewScriptStepLoader() ScriptStepLoader

func (ScriptStepLoader) LoadStep

func (l ScriptStepLoader) LoadStep(def StepDef, context LoadingContext) (Step, error)

type Step

type Step interface {
	GetName() string
	Run(context ExecutionContext) (StepStringOutput, error)
	Silenced() bool
}

func LoadStep

func LoadStep(config StepDef) (Step, error)

type StepDef

type StepDef struct {
	// contains filtered or unexported fields
}

func NewStepDef

func NewStepDef(raw map[string]interface{}) StepDef

func (StepDef) Get

func (c StepDef) Get(key string) interface{}

func (StepDef) GetName

func (c StepDef) GetName() string

func (StepDef) GetStringMapOrEmpty

func (c StepDef) GetStringMapOrEmpty(key string) map[string]interface{}

func (StepDef) Raw

func (c StepDef) Raw() map[string]interface{}

func (StepDef) Script

func (c StepDef) Script() (string, bool)

func (StepDef) Silent

func (c StepDef) Silent() bool

type StepLoader

type StepLoader interface {
	LoadStep(config StepDef, context LoadingContext) (Step, error)
}

type StepStringOutput

type StepStringOutput struct {
	String string
}

type Task

type Task struct {
	TaskDef
	Name           TaskName
	ProjectName    string
	ResolvedInputs []*Input
	Tasks          []*Task
	Command        *cobra.Command
}

func (Task) GetKey

func (f Task) GetKey() TaskName

type TaskCreator

type TaskCreator struct {
	// contains filtered or unexported fields
}

func NewTaskCreator

func NewTaskCreator(c *TaskNamer) *TaskCreator

func (*TaskCreator) Create

func (g *TaskCreator) Create(taskDef *TaskDef, parentTaskNameComponents []string, appName string) (*Task, error)

type TaskDef

type TaskDef struct {
	Name              string       `yaml:"name,omitempty"`
	Description       string       `yaml:"description,omitempty"`
	Inputs            InputConfigs `yaml:"inputs,omitempty"`
	TaskDefs          TaskDefs     `yaml:"tasks,omitempty"`
	Script            string       `yaml:"script,omitempty"`
	Steps             []Step       `yaml:"steps,omitempty"`
	Autoenv           bool         `yaml:"autoenv,omitempty"`
	Autodir           bool         `yaml:"autodir,omitempty"`
	BindParamsFromEnv bool         `yaml:"bindParamsFromEnv,omitempty"`
	Interactive       bool         `yaml:"interactive,omitempty"`
	Private           bool         `yaml:"private,omitempty"`
	// contains filtered or unexported fields
}

func NewDefaultTaskConfig

func NewDefaultTaskConfig() *TaskDef

func ReadTaskDefFromBytes added in v0.24.0

func ReadTaskDefFromBytes(data []byte) (*TaskDef, error)

func ReadTaskDefFromFile added in v0.24.0

func ReadTaskDefFromFile(path string) (*TaskDef, error)

func ReadTaskDefFromString added in v0.24.0

func ReadTaskDefFromString(data string) (*TaskDef, error)

func TransformV2FlowConfigMapToArray

func TransformV2FlowConfigMapToArray(v2 map[string]*TaskDef) []*TaskDef

func (*TaskDef) Add added in v0.29.0

func (t *TaskDef) Add(args []string, taskDef *TaskDef, f func(ctx ExecutionContext) (string, error)) error

func (*TaskDef) CopyTo

func (t *TaskDef) CopyTo(other *TaskDef)

func (*TaskDef) UnmarshalYAML

func (t *TaskDef) UnmarshalYAML(unmarshal func(interface{}) error) error

type TaskDefV1

type TaskDefV1 struct {
	Name        string                        `yaml:"name,omitempty"`
	Description string                        `yaml:"description,omitempty"`
	Inputs      []*InputConfig                `yaml:"inputs,omitempty"`
	Parameters  []*ParameterConfig            `yaml:"parameters,omitempty"`
	Options     []*OptionConfig               `yaml:"options,omitempty"`
	TaskDefs    []*TaskDef                    `yaml:"tasks,omitempty"`
	Runner      map[string]interface{}        `yaml:"runner,omitempty"`
	Script      string                        `yaml:"script,omitempty"`
	StepDefs    []map[interface{}]interface{} `yaml:"steps,omitempty"`
	Autoenv     bool                          `yaml:"autoenv,omitempty"`
	Autodir     bool                          `yaml:"autodir,omitempty"`
	BindEnvVar  bool                          `yaml:"bindParamsFromEnv,omitempty"`
	Interactive bool                          `yaml:"interactive,omitempty"`
	Private     bool                          `yaml:"private,omitempty"`
}

type TaskDefV2

type TaskDefV2 struct {
	Description string                        `yaml:"description,omitempty"`
	Inputs      []*InputConfig                `yaml:"inputs,omitempty"`
	Parameters  []*ParameterConfig            `yaml:"parameters,omitempty"`
	Options     []*OptionConfig               `yaml:"options,omitempty"`
	Import      string                        `yaml:"import,omitempty"`
	TaskDefs    map[string]*TaskDef           `yaml:"tasks,omitempty"`
	Runner      map[string]interface{}        `yaml:"runner,omitempty"`
	Script      interface{}                   `yaml:"script,omitempty"`
	StepDefs    []map[interface{}]interface{} `yaml:"steps,omitempty"`
	Autoenv     bool                          `yaml:"autoenv,omitempty"`
	Autodir     bool                          `yaml:"autodir,omitempty"`
	BindEnvVar  bool                          `yaml:"bindParamsFromEnv,omitempty"`
	Interactive bool                          `yaml:"interactive,omitempty"`
	Private     bool                          `yaml:"private,omitempty"`
}

type TaskDefs added in v0.26.0

type TaskDefs []*TaskDef

func (TaskDefs) GoString added in v0.26.0

func (d TaskDefs) GoString() string

type TaskName

type TaskName struct {
	Components []string
}

func (TaskName) AsStepKey

func (t TaskName) AsStepKey() Key

func (TaskName) Parent

func (t TaskName) Parent() (TaskName, error)

func (TaskName) ShortString

func (t TaskName) ShortString() string

func (TaskName) Simple

func (t TaskName) Simple() string

func (TaskName) String

func (t TaskName) String() string

type TaskNamer

type TaskNamer struct {
	AppName string
}

func NewTaskNamer

func NewTaskNamer(appName string) *TaskNamer

func (TaskNamer) FromInput

func (p TaskNamer) FromInput(input *InputConfig) TaskName

func (TaskNamer) FromInputName

func (p TaskNamer) FromInputName(inputName string) TaskName

func (TaskNamer) FromResolvedInput

func (p TaskNamer) FromResolvedInput(variable *Input) TaskName

func (TaskNamer) FromString

func (p TaskNamer) FromString(flowKeyStr string) TaskName

type TaskRegistry

type TaskRegistry struct {
	// contains filtered or unexported fields
}

func NewTaskRegistry

func NewTaskRegistry() *TaskRegistry

func (*TaskRegistry) AllTaskKeys

func (p *TaskRegistry) AllTaskKeys() []string

func (*TaskRegistry) FindTask

func (p *TaskRegistry) FindTask(name TaskName) *Task

func (*TaskRegistry) RegisterTasks

func (p *TaskRegistry) RegisterTasks(task *Task)

func (*TaskRegistry) Tasks

func (p *TaskRegistry) Tasks() map[string]*Task

type TaskRunner

type TaskRunner struct {
	*Task
	Values   map[string]interface{}
	Template *TaskTemplate
}

func NewTaskRunner

func NewTaskRunner(taskDef *Task, taskTemplate *TaskTemplate, vars map[string]interface{}) (TaskRunner, error)

func (TaskRunner) AsStepCaller

func (t TaskRunner) AsStepCaller() Caller

func (TaskRunner) GenerateAutoenv

func (t TaskRunner) GenerateAutoenv() (map[string]string, error)

func (TaskRunner) GenerateAutoenvRecursively

func (t TaskRunner) GenerateAutoenvRecursively(path string, env map[string]interface{}, toEnvName func(string) string) (map[string]string, error)

func (TaskRunner) GetKey

func (t TaskRunner) GetKey() Key

func (*TaskRunner) Run

func (t *TaskRunner) Run(project *Application, asInput bool, caller ...*Task) (string, error)

type TaskStep

type TaskStep struct {
	Name          string
	TaskKeyString string
	Arguments     task.Arguments
	Silent        bool
}

func (TaskStep) GetName

func (s TaskStep) GetName() string

func (TaskStep) Run

func (s TaskStep) Run(context ExecutionContext) (StepStringOutput, error)

func (TaskStep) Silenced added in v0.26.0

func (s TaskStep) Silenced() bool

type TaskStepLoader

type TaskStepLoader struct{}

func NewTaskStepLoader

func NewTaskStepLoader() TaskStepLoader

func (TaskStepLoader) LoadStep

func (l TaskStepLoader) LoadStep(stepConfig StepDef, context LoadingContext) (Step, error)

type TaskTemplate

type TaskTemplate struct {
	// contains filtered or unexported fields
}

func NewTaskTemplate

func NewTaskTemplate(task *Task, values map[string]interface{}) *TaskTemplate

func (*TaskTemplate) Render

func (t *TaskTemplate) Render(expr string, name string) (string, error)

func (*TaskTemplate) WithAdditionalValues added in v0.28.0

func (t *TaskTemplate) WithAdditionalValues(vs map[string]interface{}) *TaskTemplate

Directories

Path Synopsis
api
cli
env
util

Jump to

Keyboard shortcuts

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