types

package
v0.6.0-post.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 15

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"
	// 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 (
	// 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 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
}

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

type PreCheckResult struct {
	Skip    bool
	Timeout bool
}

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)
	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      *v1alpha1.WorkflowExecuteMode
	Steps     []v1alpha1.WorkflowStep
	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