Documentation ¶
Index ¶
- Variables
- func RegisterRenderer(name string, create RendererCreateFunc)
- func RegisterTask(k ToolKind, tk TaskKind, create TaskCreateFunc)
- func RegisterTool(k ToolKind, create ToolCreateFunc)
- func ResolveEnv(ctx RenderingContext, parent rs.Field, envFieldName, envTagName string) error
- type ConfigResolvingContext
- type Context
- type Env
- type EnvEntry
- type EnvValues
- type ExecSpecGetFunc
- type ExecValues
- type GlobalEnvSet
- type GlobalEnvValues
- type IfaceFactory
- type IfaceFactoryFunc
- type IfaceFactoryImpl
- type IfaceTypeKey
- type Renderer
- type RendererAttribute
- type RendererCreateFunc
- type RendererManager
- type RenderingContext
- type ReplaceEntries
- type ReplaceEntry
- type Resolvable
- type RunTaskOrRunCmd
- type RuntimeOptions
- type Shell
- type ShellManager
- type ShellUser
- type Task
- type TaskCreateFunc
- type TaskExecContext
- type TaskExecOptions
- type TaskExecSpec
- type TaskExecStage
- type TaskExecState
- type TaskKey
- type TaskKind
- type TaskManager
- type TaskMatrixExecOptions
- type TaskName
- type TaskUser
- type Tool
- type ToolCreateFunc
- type ToolKey
- type ToolKind
- type ToolManager
- type ToolName
- type ToolUser
- type TypeManager
Constants ¶
This section is empty.
Variables ¶
var GlobalInterfaceTypeHandler rs.InterfaceTypeHandler = globalTypeManager
Functions ¶
func RegisterRenderer ¶
func RegisterRenderer(name string, create RendererCreateFunc)
RegisterRenderer associates a renderer factory with name
func RegisterTask ¶
func RegisterTask(k ToolKind, tk TaskKind, create TaskCreateFunc)
RegisterTask associates a task factory with task kind
func RegisterTool ¶
func RegisterTool(k ToolKind, create ToolCreateFunc)
RegisterTool associates a tool factory with tool kind
func ResolveEnv ¶
func ResolveEnv(ctx RenderingContext, parent rs.Field, envFieldName, envTagName string) error
ResolveEnv resolve struct field with `Env` type in struct parent and add these env entries to ctx during resolving, so later entries can rely on former entries' value
NOTE: parent should be initialized with rs.Init before calling this function
Types ¶
type ConfigResolvingContext ¶
type ConfigResolvingContext interface { Context ShellManager ToolManager TaskManager RendererManager // cache fs ToolCacheFS(t Tool) *fshelper.OSFS TaskCacheFS(t Task) *fshelper.OSFS RendererCacheFS(name string) *fshelper.OSFS }
ConfigResolvingContext interface definition for config resolving
func NewConfigResolvingContext ¶
func NewConfigResolvingContext( parent context.Context, ifaceTypeHandler rs.InterfaceTypeHandler, globalEnv *GlobalEnvSet, ) ConfigResolvingContext
type Context ¶
type Context interface { TaskExecContext SetRuntimeOptions(opts RuntimeOptions) RunTask(ToolKey, TaskKey) error }
Context for user facing tasks
type EnvEntry ¶
type EnvEntry struct { rs.BaseField `yaml:"-" json:"-"` // Name of the entry (in other words, key) Name string `yaml:"name"` // Value associated to the name Value string `yaml:"value"` }
EnvEntry is a single name/value pair
type ExecSpecGetFunc ¶
type ExecValues ¶
type ExecValues interface { SetOutputPrefix(s string) OutputPrefix() string SetTaskColors(prefixColor, outputColor termenv.Color) PrefixColor() termenv.Color OutputColor() termenv.Color CurrentTool() ToolKey CurrentTask() TaskKey SetTask(k ToolKey, tK TaskKey) TranslateANSIStream() bool RetainANSIStyle() bool ColorOutput() bool FailFast() bool ClaimWorkers(n int) int SetState(s TaskExecState) State() TaskExecState }
type GlobalEnvSet ¶ added in v0.9.0
type GlobalEnvSet [constant.GlobalEnv_Count]tlang.LazyValueType[string]
func (*GlobalEnvSet) Get ¶ added in v0.9.0
func (s *GlobalEnvSet) Get(name string) (ret tlang.LazyValueType[string], ok bool)
type GlobalEnvValues ¶ added in v0.5.1
type GlobalEnvValues interface { WorkDir() string CacheDir() string GitBranch() string GitWorkTreeClean() bool GitTag() string GitDefaultBranch() string GitCommit() string GitValues() map[string]tlang.LazyValueType[string] HostKernel() string HostKernelVersion() string HostArch() string HostOS() string HostOSVersion() string HostValues() map[string]tlang.LazyValueType[string] }
type IfaceFactory ¶ added in v0.4.3
type IfaceFactory struct {
Factories []*IfaceFactoryImpl
}
type IfaceFactoryFunc ¶ added in v0.4.3
type IfaceFactoryFunc func(subMatches []string) interface{}
type IfaceFactoryImpl ¶ added in v0.4.3
type IfaceFactoryImpl struct { // Name is the raw information about what instance we are creating // currently only used in json schema generation Name string Create IfaceFactoryFunc // contains filtered or unexported fields }
type IfaceTypeKey ¶ added in v0.4.3
type Renderer ¶
type Renderer interface { rs.Field // Init the renderer and add itself to the context Init(cacheFS *fshelper.OSFS) error Alias() string RenderYaml(rc RenderingContext, rawData interface{}, attributes []RendererAttribute) (result []byte, err error) }
Renderer to handle rendering suffix
type RendererAttribute ¶ added in v0.5.0
type RendererAttribute string
type RendererCreateFunc ¶
type RendererManager ¶
type RendererManager interface { AllRenderers() map[string]Renderer AddRenderer(name string, renderer Renderer) }
RendererManager to manage renderers
type RenderingContext ¶
type RenderingContext interface { context.Context expand.Environ rs.InterfaceTypeHandler rs.RenderingHandler EnvValues // FS returns the filesystem with cwd set to DUKKHA_WORKDIR FS() *fshelper.OSFS // AddValues will merge provided values into existing values AddValues(values map[string]any) error Env() map[string]tlang.LazyValueType[string] Values() map[string]any GlobalCacheFS(subdir string) *fshelper.OSFS Stdin() io.Reader Stdout() io.Writer Stderr() io.Writer SetStdIO(in io.Reader, out, err io.Writer) }
type ReplaceEntries ¶
type ReplaceEntries map[string]ReplaceEntry
type ReplaceEntry ¶
type Resolvable ¶ added in v0.5.0
type Resolvable interface { rs.Field // DoAfterFieldsResolved is a helper function to ensure no data race // // The implementation MUST be safe to be used concurrently DoAfterFieldsResolved( rc RenderingContext, depth int, resolveEnv bool, do func() error, tagNames ...string, ) error }
Resolvable represents a kind of struct that can be resolved at runtime
type RunTaskOrRunCmd ¶
type RunTaskOrRunCmd interface{}
one of `tools.TaskExecRequest`, `[]dukkha.TaskExecSpec`
type RuntimeOptions ¶ added in v0.4.0
type RuntimeOptions struct { FailFast bool ColorOutput bool TranslateANSIStream bool RetainANSIStyle bool Workers int }
RuntimeOptions for task execution
type ShellManager ¶
type Task ¶
type Task interface { Resolvable // ToolKind is the tool managing this task (e.g. docker) ToolKind() ToolKind // ToolName it the name of the tool this task belongs to ToolName() ToolName // Kind of the task (e.g. build) Kind() TaskKind // Name of the task (e.g. foo) Name() TaskName // Key is the composite key of task kind and name Key() TaskKey // Init this task Init(cacheFS *fshelper.OSFS) error // GetMatrixSpecs for matrix execution // // The implementation MUST be thread safe GetMatrixSpecs(rc RenderingContext) ([]matrix.Entry, error) // GetExecSpecs generate commands using current field values // // The implementation MUST be thread safe GetExecSpecs(rc TaskExecContext, options TaskMatrixExecOptions) ([]TaskExecSpec, error) // GetHookExecSpecs generate hook run target // // The implementation MUST be thread safe GetHookExecSpecs(rc TaskExecContext, state TaskExecStage) ([]TaskExecSpec, error) }
Task implementation requirements
type TaskCreateFunc ¶
type TaskExecContext ¶
type TaskExecContext interface { context.Context RenderingContext ShellUser ToolUser TaskUser DeriveNew() Context Cancel() // WithCustomParent divert from current context.Context // intended to be only used for defered `after` hooks WithCustomParent(parent context.Context) TaskExecContext ExecValues }
TaskExecContext interface definition for task execution
type TaskExecOptions ¶
type TaskExecOptions interface {
NextMatrixExecOptions() TaskMatrixExecOptions
}
func CreateTaskExecOptions ¶
func CreateTaskExecOptions(id, totalMatrix int) TaskExecOptions
type TaskExecSpec ¶
type TaskExecSpec struct { // StdoutAsReplace to replace same string in following TaskExecSpecs // use output to stdout of this exec StdoutAsReplace string // ShowStdout when StdoutAsReplace is set ShowStdout bool FixStdoutValueForReplace func(data []byte) []byte // StderrAsReplace to replace same string in following TaskExecSpecs // use output to stderr of this exec StderrAsReplace string // ShowStderr when StderrAsReplace is set ShowStderr bool FixStderrValueForReplace func(data []byte) []byte Chdir string // EnvSuggest to provide environment variables when not set by user EnvSuggest Env // EnvOverride to override existing environment variables EnvOverride Env Command []string AlterExecFunc func( replace ReplaceEntries, stdin io.Reader, stdout, stderr io.Writer, ) (RunTaskOrRunCmd, error) Stdin io.Reader // IgnoreError to ignore error generated after running this spec // this option applies to all sub specs (as returned in AlterExecFunc) IgnoreError bool // UseShell if true, write command to local script cache // and execute with the target shell (as referenced by ShellName) UseShell bool // ShellName to reference a shell to execute command // when `UseShell` is true // // the availability of the shells denpends on `shells` in dukkha config // a special shell name is `embedded`, which will use the built-in shell // for command evaluation ShellName string }
TaskExecSpec is the specification
type TaskExecStage ¶
type TaskExecStage uint8
const ( StageBefore TaskExecStage = iota + 1 StageBeforeMatrix StageAfterMatrixSuccess StageAfterMatrixFailure StageAfterMatrix StageAfterSuccess StageAfterFailure StageAfter )
func (TaskExecStage) String ¶
func (s TaskExecStage) String() string
type TaskExecState ¶ added in v0.5.0
type TaskExecState int
const ( TaskExecPending TaskExecState = iota TaskExecNotStarted TaskExecWorking TaskExecSucceeded TaskExecFailed TaskExecCanceled )
type TaskManager ¶
type TaskMatrixExecOptions ¶
type Tool ¶
type Tool interface { Resolvable // Kind of the tool, e.g. golang, docker Kind() ToolKind // Name of the tool, e.g. my-tool Name() ToolName // Key Key() ToolKey // GetCmd get cli command to run this tool GetCmd() []string GetTask(TaskKey) (Task, bool) AllTasks() map[TaskKey]Task Init(cacheFS *fshelper.OSFS) error AddTasks(tasks []Task) error // Run task Run(taskCtx TaskExecContext, tsk TaskKey) error }
Tool implementation requirements
type ToolCreateFunc ¶
type ToolCreateFunc func() Tool
type ToolManager ¶
type TypeManager ¶ added in v0.4.3
type TypeManager struct {
// contains filtered or unexported fields
}
func (*TypeManager) Create ¶ added in v0.4.3
func (h *TypeManager) Create(typ reflect.Type, yamlKey string) (interface{}, error)
Create implements rs.InterfaceTypeHandler
func (*TypeManager) Types ¶ added in v0.4.3
func (h *TypeManager) Types() map[IfaceTypeKey]*IfaceFactory