utils

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: 34 Imported by: 3

Documentation

Index

Constants

View Source
const SystemNamespace = "vela-system"

SystemNamespace is the shared namespace where reusable Workflows are looked up as a fallback, mirroring how X-Definitions resolve from vela-system.

Variables

This section is empty.

Functions

func BeEquivalentToError

func BeEquivalentToError(expected error) types.GomegaMatcher

BeEquivalentToError matches the error to take care of nil.

func CRDDeclaresField

func CRDDeclaresField(ctx context.Context, cli client.Reader, crdName string, path ...string) (bool, error)

CRDDeclaresField reports whether every served version of the installed CRD declares the field at path in its schema. "[]" in path steps into an array's items.

The API server prunes a field its CRD does not declare, without an error, so a controller newer than its CRDs loses fields silently. Read as unstructured so the caller's scheme need not know CustomResourceDefinition.

func CleanStatusFromStep added in v0.4.0

func CleanStatusFromStep(steps []oamv1alpha1.WorkflowStep, stepStatus []v1alpha1.WorkflowStepStatus, mode oamv1alpha1.WorkflowExecuteMode, contextCM *corev1.ConfigMap, stepName string) ([]v1alpha1.WorkflowStepStatus, *corev1.ConfigMap, error)

CleanStatusFromStep cleans status and context data from a specified step

func GetDataFromContext

func GetDataFromContext(ctx context.Context, ctxName, name, ns string, paths ...string) (cue.Value, error)

GetDataFromContext get data from workflow context

func GetLogConfigFromStep

func GetLogConfigFromStep(ctx context.Context, ctxName, name, ns, step string) (*types.LogConfig, error)

GetLogConfigFromStep get log config from step

func GetLogsFromPod

func GetLogsFromPod(ctx context.Context, clientSet kubernetes.Interface, cli client.Client, podName, ns, cluster string, opts *corev1.PodLogOptions) (io.ReadCloser, error)

GetLogsFromPod get logs from pod

func GetLogsFromURL

func GetLogsFromURL(ctx context.Context, url string) (io.ReadCloser, error)

GetLogsFromURL get logs from url

func GetPodListFromResources

func GetPodListFromResources(ctx context.Context, cli client.Client, resources []types.Resource) ([]corev1.Pod, error)

GetPodListFromResources get pod list from resources

func GetWorkflow added in v0.7.3

func GetWorkflow(ctx context.Context, cli client.Reader, namespace, name string) (*oamv1alpha1.Workflow, error)

GetWorkflow gets the Workflow referenced by a WorkflowRun. It first looks in the given namespace, then falls back to SystemNamespace so a Workflow created in vela-system can be referenced by a WorkflowRun in any namespace.

func JSONMarshal

func JSONMarshal(o interface{}) []byte

JSONMarshal returns the JSON encoding

func NewRecycleCronJob added in v0.5.0

func NewRecycleCronJob(cli client.Client, duration time.Duration, cron, label string) manager.Runnable

NewRecycleCronJob returns a new recycleCronJob

func OperateSteps added in v0.5.0

func OperateSteps(status []v1alpha1.WorkflowStepStatus, i, j int, phase v1alpha1.WorkflowStepPhase)

OperateSteps handles the operations to the steps

func RestartFromStep added in v0.4.0

func RestartFromStep(ctx context.Context, cli client.Client, run *v1alpha1.WorkflowRun, stepName string) error

RestartFromStep restart workflow from a failed step

func RestartWorkflow added in v0.4.0

func RestartWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.WorkflowRun, step string) error

RestartWorkflow restart workflow

func ResumeWorkflow

func ResumeWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.WorkflowRun, stepName string) error

ResumeWorkflow resume workflow

func SuspendWorkflow added in v0.5.0

func SuspendWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.WorkflowRun, stepName string) error

SuspendWorkflow suspend workflow

func TerminateStatus added in v0.6.5

func TerminateStatus(status *v1alpha1.WorkflowRunStatus)

TerminateStatus marks status terminated: not suspended, and every running or suspending step and sub-step failed with reason Terminate, as is a failed one unless it failed after its retries or on a timeout.

func TerminateWorkflow

func TerminateWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.WorkflowRun) error

TerminateWorkflow terminate workflow

func WarnIfCRDLacksForEach

func WarnIfCRDLacksForEach(ctx context.Context, cli client.Reader, crdName string, stepsPath ...string)

WarnIfCRDLacksForEach logs when the installed CRD predates the forEach step field, so that a looped step running once is explained in the controller's log. It never fails startup: the check is advice, and a controller may lack permission to read CRDs.

Types

type AlreadyExistMatcher

type AlreadyExistMatcher struct {
}

AlreadyExistMatcher matches the error to be already exist

func (AlreadyExistMatcher) FailureMessage

func (matcher AlreadyExistMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (AlreadyExistMatcher) Match

func (matcher AlreadyExistMatcher) Match(actual interface{}) (success bool, err error)

Match matches error.

func (AlreadyExistMatcher) NegatedFailureMessage

func (matcher AlreadyExistMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type ErrorMatcher

type ErrorMatcher struct {
	ExpectedError error
}

ErrorMatcher matches errors.

func (ErrorMatcher) FailureMessage

func (matcher ErrorMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (ErrorMatcher) Match

func (matcher ErrorMatcher) Match(actual interface{}) (success bool, err error)

Match matches an error.

func (ErrorMatcher) NegatedFailureMessage

func (matcher ErrorMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type NotFoundMatcher

type NotFoundMatcher struct {
}

NotFoundMatcher matches the error to be not found.

func (NotFoundMatcher) FailureMessage

func (matcher NotFoundMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (NotFoundMatcher) Match

func (matcher NotFoundMatcher) Match(actual interface{}) (success bool, err error)

Match matches the api error.

func (NotFoundMatcher) NegatedFailureMessage

func (matcher NotFoundMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type WorkflowOperator

type WorkflowOperator interface {
	Suspend(ctx context.Context) error
	Resume(ctx context.Context) error
	Rollback(ctx context.Context) error
	Restart(ctx context.Context) error
	Terminate(ctx context.Context) error
}

WorkflowOperator is operation handler for workflow's suspend/resume/rollback/restart/terminate

func NewWorkflowRunOperator

func NewWorkflowRunOperator(cli client.Client, w io.Writer, run *v1alpha1.WorkflowRun) WorkflowOperator

NewWorkflowRunOperator get an workflow operator with k8sClient, ioWriter(optional, useful for cli) and workflow run

type WorkflowStepOperator added in v0.5.0

type WorkflowStepOperator interface {
	Suspend(ctx context.Context, step string) error
	Resume(ctx context.Context, step string) error
	Restart(ctx context.Context, step string) error
}

WorkflowStepOperator is operation handler for workflow steps' operations

func NewWorkflowRunStepOperator added in v0.5.0

func NewWorkflowRunStepOperator(cli client.Client, w io.Writer, run *v1alpha1.WorkflowRun) WorkflowStepOperator

NewWorkflowRunStepOperator get an workflow step operator with k8sClient, ioWriter(optional, useful for cli) and workflow run

Directories

Path Synopsis
Package servingcert keeps a self-signed CA and a serving cert for an in-cluster Service in a Secret, and renews them.
Package servingcert keeps a self-signed CA and a serving cert for an in-cluster Service in a Secret, and renews them.
Package stepsecret resolves the Secrets a workflow step names, which it reads as the controller.
Package stepsecret resolves the Secrets a workflow step names, which it reads as the controller.

Jump to

Keyboard shortcuts

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