Documentation
¶
Index ¶
- Constants
- Variables
- func IsStepFinish(phase v1alpha1.WorkflowStepPhase, reason string) bool
- func SetNamespaceInCtx(ctx context.Context, namespace string) context.Context
- type Action
- type Engine
- type Handler
- type LogConfig
- type LogSource
- type Operation
- type Parameter
- type PreCheckOptions
- type PreCheckResult
- type Providers
- type Resource
- type StatusPatcher
- type StepGeneratorOptions
- type TaskDiscover
- type TaskGenerator
- type TaskGeneratorOptions
- type TaskPostStopHook
- type TaskPreCheckHook
- type TaskPreStartHook
- type TaskRunOptions
- type TaskRunner
- type WorkflowInstance
- type WorkflowMeta
Constants ¶
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" )
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" )
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" )
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" )
const ( // AnnotationWorkflowRunDebug is the annotation for debug AnnotationWorkflowRunDebug = "workflowrun.oam.dev/debug" // AnnotationControllerRequirement indicates the controller version that can process the workflow run AnnotationControllerRequirement = "workflowrun.oam.dev/controller-version-require" )
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 ¶
var ( // 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.
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 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
}
Engine is the engine to run workflow
type Handler ¶
type Handler func(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act Action) error
Handler is provider's processing method.
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 {
PackageDiscover *packages.PackageDiscover
BasicTemplate string
BasicValue *value.Value
}
PreCheckOptions is the options for pre check.
type PreCheckResult ¶
PreCheckResult is the result of pre check.
type Providers ¶
type Providers interface {
GetHandler(provider, name string) (Handler, bool)
Register(provider string, m map[string]Handler)
}
Providers is provider discover interface.
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 {
Providers Providers
PackageDiscover *packages.PackageDiscover
ProcessCtx process.Context
TemplateLoader template.Loader
Client client.Client
StepConvertor map[string]func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error)
LogLevel int
}
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 v1alpha1.WorkflowStep, options *TaskGeneratorOptions) (TaskRunner, error)
TaskGenerator will generate taskRunner.
type TaskGeneratorOptions ¶
type TaskGeneratorOptions struct {
ID string
PrePhase v1alpha1.WorkflowStepPhase
StepConvertor func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error)
SubTaskRunners []TaskRunner
SubStepExecuteMode v1alpha1.WorkflowMode
PackageDiscover *packages.PackageDiscover
ProcessContext process.Context
}
TaskGeneratorOptions is the options for generate task.
type TaskPostStopHook ¶
type TaskPostStopHook func(ctx wfContext.Context, taskValue *value.Value, step v1alpha1.WorkflowStep, status v1alpha1.StepStatus, stepStatus map[string]v1alpha1.StepStatus) error
TaskPostStopHook run after task execution.
type TaskPreCheckHook ¶
type TaskPreCheckHook func(step v1alpha1.WorkflowStep, options *PreCheckOptions) (*PreCheckResult, error)
TaskPreCheckHook is the hook for pre check.
type TaskPreStartHook ¶
type TaskPreStartHook func(ctx wfContext.Context, paramValue *value.Value, step v1alpha1.WorkflowStep) error
TaskPreStartHook run before task execution.
type TaskRunOptions ¶
type TaskRunOptions struct {
Data *value.Value
PCtx process.Context
PreCheckHooks []TaskPreCheckHook
PreStartHooks []TaskPreStartHook
PostStopHooks []TaskPostStopHook
GetTracer func(id string, step v1alpha1.WorkflowStep) monitorContext.Context
RunSteps func(isDag bool, runners ...TaskRunner) (*v1alpha1.WorkflowRunStatus, error)
Debug func(step string, v *value.Value) error
StepStatus map[string]v1alpha1.StepStatus
Engine Engine
}
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)
}
TaskRunner is a task runner
type WorkflowInstance ¶
type WorkflowInstance struct {
WorkflowMeta
OwnerInfo []metav1.OwnerReference
Debug bool
Context map[string]interface{}
Mode *v1alpha1.WorkflowExecuteMode
Steps []v1alpha1.WorkflowStep
Status v1alpha1.WorkflowRunStatus
}
WorkflowInstance is the instance for workflow engine to execute