types

package
v0.8.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// ContextPrefixFailedTimes is the prefix that refer to the failed times of the step in workflow context config map.
	ContextPrefixFailedTimes = "failed_times"
	// ContextPrefixBackoffTimes is the prefix that refer to the backoff times in workflow context config map.
	ContextPrefixBackoffTimes = "backoff_times"
	// ContextPrefixBackoffReason is the prefix that refer to the current backoff reason in workflow context config map
	ContextPrefixBackoffReason = "backoff_reason"
	// ContextKeyLastExecuteTime is the key that refer to the last execute time in workflow context config map.
	ContextKeyLastExecuteTime = "last_execute_time"
	// ContextKeyNextExecuteTime is the key that refer to the next execute time in workflow context config map.
	ContextKeyNextExecuteTime = "next_execute_time"
	// ContextKeyLogConfig is key for log config.
	ContextKeyLogConfig = "logConfig"
)
View Source
const (
	// WorkflowStepTypeSuspend type suspend
	WorkflowStepTypeSuspend = "suspend"
	// WorkflowStepTypeApplyComponent type apply-component
	WorkflowStepTypeApplyComponent = "apply-component"
	// WorkflowStepTypeBuiltinApplyComponent type builtin-apply-component
	WorkflowStepTypeBuiltinApplyComponent = "builtin-apply-component"
	// WorkflowStepTypeStepGroup type step-group
	WorkflowStepTypeStepGroup = "step-group"
)
View Source
const (
	// LabelWorkflowRunName is the label key for workflow run name
	LabelWorkflowRunName = "workflowrun.oam.dev/name"
	// LabelWorkflowRunNamespace is the label key for workflow run namespace
	LabelWorkflowRunNamespace = "workflowrun.oam.dev/namespace"
)
View Source
const (
	// StatusReasonWait is the reason of the workflow progress condition which is Wait.
	StatusReasonWait = "Wait"
	// StatusReasonSkip is the reason of the workflow progress condition which is Skip.
	StatusReasonSkip = "Skip"
	// StatusReasonRendering is the reason of the workflow progress condition which is Rendering.
	StatusReasonRendering = "Rendering"
	// StatusReasonExecute is the reason of the workflow progress condition which is Execute.
	StatusReasonExecute = "Execute"
	// StatusReasonSuspend is the reason of the workflow progress condition which is Suspend.
	StatusReasonSuspend = "Suspend"
	// StatusReasonTerminate is the reason of the workflow progress condition which is Terminate.
	StatusReasonTerminate = "Terminate"
	// StatusReasonParameter is the reason of the workflow progress condition which is ProcessParameter.
	StatusReasonParameter = "ProcessParameter"
	// StatusReasonInput is the reason of the workflow progress condition which is Input.
	StatusReasonInput = "Input"
	// StatusReasonOutput is the reason of the workflow progress condition which is Output.
	StatusReasonOutput = "Output"
	// StatusReasonFailedAfterRetries is the reason of the workflow progress condition which is FailedAfterRetries.
	StatusReasonFailedAfterRetries = "FailedAfterRetries"
	// StatusReasonTimeout is the reason of the workflow progress condition which is Timeout.
	StatusReasonTimeout = "Timeout"
	// StatusReasonAction is the reason of the workflow progress condition which is Action.
	StatusReasonAction = "Action"
)
View Source
const (
	// AnnotationWorkflowRunDebug is the annotation for debug
	AnnotationWorkflowRunDebug = "workflowrun.oam.dev/debug"
	// AnnotationCelExpressions set to "true" opts a WorkflowRun in to $( )
	// expressions, where the EnableCelExpressions feature gate is on.
	AnnotationCelExpressions = "workflowrun.oam.dev/cel-expressions"
	// AnnotationControllerRequirement indicates the controller version that can process the workflow run
	AnnotationControllerRequirement = "workflowrun.oam.dev/controller-version-require"
)
View Source
const (
	// MessageSuspendFailedAfterRetries is the message of failed after retries
	MessageSuspendFailedAfterRetries = "The workflow suspends automatically because the failed times of steps have reached the limit"
)

Variables

View Source
var (
	// MaxForEachItems caps the iterations of a forEach step, since every iteration is
	// recorded in the run's status object.
	MaxForEachItems = 50
	// MaxWorkflowStepErrorRetryTimes is the max retry times of the failed workflow step.
	MaxWorkflowStepErrorRetryTimes = 10
	// MaxWorkflowWaitBackoffTime is the max time to wait before reconcile wait workflow again
	MaxWorkflowWaitBackoffTime = 60
	// MaxWorkflowFailedBackoffTime is the max time to wait before reconcile failed workflow again
	MaxWorkflowFailedBackoffTime = 300
)

Functions

func IsStepFinish

func IsStepFinish(phase v1alpha1.WorkflowStepPhase, reason string) bool

IsStepFinish will decide whether step is finish.

func IterationName

func IterationName(loop, label, name string) string

IterationName is what the pass of a forEach loop over a step-group for the item labelled label calls its body step, or a body output, name: <loop>-<label>-<name>. A loop over one step names its pass <loop>-<label>. The label is the item's key, or its index when the loop has none.

func SetNamespaceInCtx

func SetNamespaceInCtx(ctx context.Context, namespace string) context.Context

SetNamespaceInCtx set namespace in context.

Types

type Action

type Action interface {
	Suspend(message string)
	Resume(message string)
	Terminate(message string)
	Wait(message string)
	Fail(message string)
	Message(message string)
	GetStatus() v1alpha1.StepStatus
}

Action is that workflow provider can do.

type ContextDataResetter added in v0.6.0

type ContextDataResetter func(processCtx process.Context)

ContextDataResetter reset process.Context after the step is finished

type Engine

type Engine interface {
	Run(ctx monitorContext.Context, taskRunners []TaskRunner, dag bool) error
	GetStepStatus(stepName string) v1alpha1.WorkflowStepStatus
	GetCommonStepStatus(stepName string) v1alpha1.StepStatus
	SetParentRunner(name string)
	GetOperation() *Operation
	// SetDependsOn records the dependsOn of a step generated at run time, which the
	// workflow spec does not list.
	SetDependsOn(name string, dependsOn []string)
}

Engine is the engine to run workflow

type ExpressionOptions

type ExpressionOptions struct {
	Roots     []cel.Root
	Resolvers map[string]cel.Resolver
}

ExpressionOptions turns on $( ) expressions in step properties, forEach items and if conditions. The workflow answers context, steps and each; a host adds roots of its own with a resolver for each.

type ExpressionStep

type ExpressionStep struct {
	Name string
	Type string
}

ExpressionStep is the step whose expressions are resolved: its name as it runs, so an iteration's step has its own, and its type.

type LogConfig

type LogConfig struct {
	Data   bool       `json:"data,omitempty"`
	Source *LogSource `json:"source,omitempty"`
}

LogConfig is the config of the log

type LogSource

type LogSource struct {
	URL       string     `json:"url,omitempty"`
	Resources []Resource `json:"resources,omitempty"`
}

LogSource is the source of the log

type Operation

type Operation struct {
	Suspend            bool
	Terminated         bool
	Waiting            bool
	Skip               bool
	FailedAfterRetries bool
}

Operation is workflow operation object.

type Parameter

type Parameter struct {
	Name     string      `json:"name"`
	Short    string      `json:"short,omitempty"`
	Required bool        `json:"required,omitempty"`
	Default  interface{} `json:"default,omitempty"`
	Usage    string      `json:"usage,omitempty"`
	Ignore   bool        `json:"ignore,omitempty"`
	Type     cue.Kind    `json:"type,omitempty"`
	Alias    string      `json:"alias,omitempty"`
	JSONType string      `json:"jsonType,omitempty"`
}

Parameter defines a parameter for cli from capability template

type PreCheckOptions

type PreCheckOptions struct {
	BasicValue cue.Value
	// Condition evaluates the step's $( ) if, when its run resolves expressions;
	// nil otherwise, and an if that is one is then CUE, as it always was.
	Condition func() (bool, error)
}

PreCheckOptions is the options for pre check.

type PreCheckResult

type PreCheckResult struct {
	Skip    bool
	Timeout bool
	// Wait holds the step back, with Message saying why: its $( ) if reads
	// something still to be answered.
	Wait bool
	// Fail fails the step, with Message saying why: its $( ) if cannot be
	// evaluated in a run that does not read expressions, or its if holds a
	// $( ) that is not the whole condition.
	Fail    bool
	Message string
}

PreCheckResult is the result of pre check.

type PropertyEvaluator

type PropertyEvaluator interface {
	Properties(ctx context.Context, step ExpressionStep, properties *runtime.RawExtension, wfCtx wfContext.Context,
		pCtx process.Context, status map[string]v1alpha1.StepStatus) (*runtime.RawExtension, error)
	// Condition evaluates a step's $( ) if.
	Condition(ctx context.Context, step ExpressionStep, cond string, wfCtx wfContext.Context,
		pCtx process.Context, status map[string]v1alpha1.StepStatus) (bool, error)
}

PropertyEvaluator resolves the $( ) expressions in a step's properties. An error that is cel.ErrNotReady means the step waits and tries again.

type Resource

type Resource struct {
	Name          string            `json:"name,omitempty"`
	Namespace     string            `json:"namespace,omitempty"`
	Cluster       string            `json:"cluster,omitempty"`
	LabelSelector map[string]string `json:"labelSelector,omitempty"`
}

Resource is the log resources

type StatusPatcher added in v0.4.0

type StatusPatcher func(ctx context.Context, status *v1alpha1.WorkflowRunStatus, isUpdate bool) error

StatusPatcher is the interface to patch status

type StepGeneratorOptions

type StepGeneratorOptions struct {
	ProcessCtx     process.Context
	TemplateLoader template.Loader
	StepConvertor  map[string]func(step oamv1alpha1.WorkflowStep) (oamv1alpha1.WorkflowStep, error)
	LogLevel       int
	Compiler       *cuex.Compiler
	// Expressions turns on $( ) expressions in step properties; nil leaves them
	// as written.
	Expressions *ExpressionOptions
}

StepGeneratorOptions is the options for generate step.

type TaskDiscover

type TaskDiscover interface {
	GetTaskGenerator(ctx context.Context, name string) (TaskGenerator, error)
}

TaskDiscover is the interface to obtain the TaskGenerator

type TaskGenerator

type TaskGenerator func(wfStep oamv1alpha1.WorkflowStep, options *TaskGeneratorOptions) (TaskRunner, error)

TaskGenerator will generate taskRunner.

type TaskGeneratorOptions

type TaskGeneratorOptions struct {
	ID                 string
	PrePhase           v1alpha1.WorkflowStepPhase
	StepConvertor      func(step oamv1alpha1.WorkflowStep) (oamv1alpha1.WorkflowStep, error)
	SubTaskRunners     []TaskRunner
	SubStepExecuteMode oamv1alpha1.WorkflowMode
	ProcessContext     process.Context
	// SubTaskGenerator builds a runner for a sub-step that only exists at run time,
	// such as one iteration of a for-each body.
	SubTaskGenerator func(step oamv1alpha1.WorkflowStepBase, id string) (TaskRunner, error)
	// Expressions resolves the $( ) expressions in the step's properties when it
	// runs; nil leaves them as written.
	Expressions PropertyEvaluator
}

TaskGeneratorOptions is the options for generate task.

type TaskPostStopHook

type TaskPostStopHook func(ctx wfContext.Context, taskValue cue.Value, step oamv1alpha1.WorkflowStep, status v1alpha1.StepStatus, stepStatus map[string]v1alpha1.StepStatus) error

TaskPostStopHook run after task execution.

type TaskPreCheckHook

type TaskPreCheckHook func(step oamv1alpha1.WorkflowStep, options *PreCheckOptions) (*PreCheckResult, error)

TaskPreCheckHook is the hook for pre check.

type TaskPreStartHook

type TaskPreStartHook func(ctx wfContext.Context, paramValue cue.Value, step oamv1alpha1.WorkflowStep) (cue.Value, error)

TaskPreStartHook run before task execution.

type TaskRunOptions

type TaskRunOptions struct {
	PCtx          process.Context
	PreCheckHooks []TaskPreCheckHook
	PreStartHooks []TaskPreStartHook
	PostStopHooks []TaskPostStopHook
	GetTracer     func(id string, step oamv1alpha1.WorkflowStep) monitorContext.Context
	RunSteps      func(isDag bool, runners ...TaskRunner) (*v1alpha1.WorkflowRunStatus, error)
	Debug         func(step string, v cue.Value) error
	StepStatus    map[string]v1alpha1.StepStatus
	Engine        Engine
	Compiler      *cuex.Compiler
}

TaskRunOptions is the options for task run

type TaskRunner

type TaskRunner interface {
	Name() string
	Pending(ctx monitorContext.Context, wfCtx wfContext.Context, stepStatus map[string]v1alpha1.StepStatus) (bool, v1alpha1.StepStatus)
	Run(ctx wfContext.Context, options *TaskRunOptions) (v1alpha1.StepStatus, *Operation, error)
	FillContextData(ctx monitorContext.Context, processCtx process.Context) ContextDataResetter
}

TaskRunner is a task runner

type WorkflowInstance

type WorkflowInstance struct {
	WorkflowMeta
	OwnerInfo []metav1.OwnerReference
	Debug     bool
	Context   map[string]interface{}
	Mode      *oamv1alpha1.WorkflowExecuteMode
	Steps     []oamv1alpha1.WorkflowStep
	// InferredDependsOn is, by step name, the steps each step's expressions read
	// that it waits on: the entries of its dependsOn the reads added, and the
	// earlier steps a workflow run in order puts first without one.
	InferredDependsOn map[string][]string
	Status            v1alpha1.WorkflowRunStatus
}

WorkflowInstance is the instance for workflow engine to execute

type WorkflowMeta

type WorkflowMeta struct {
	Name                 string
	Namespace            string
	Annotations          map[string]string
	Labels               map[string]string
	UID                  types.UID
	ChildOwnerReferences []metav1.OwnerReference
}

WorkflowMeta is the meta information for workflow instance

Jump to

Keyboard shortcuts

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