util

package
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 49 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddParamToGlobalScope added in v3.0.3

func AddParamToGlobalScope(wf *wfv1.Workflow, log *log.Entry, param wfv1.Parameter) bool

func ApplyPodSpecPatch added in v3.5.0

func ApplyPodSpecPatch(podSpec apiv1.PodSpec, podSpecPatchYamls ...string) (*apiv1.PodSpec, error)

func ApplySubmitOpts

func ApplySubmitOpts(wf *wfv1.Workflow, opts *wfv1.SubmitOpts) error

Apply the Submit options into workflow object

func ConvertYAMLToJSON

func ConvertYAMLToJSON(str string) (string, error)

func CreateServerDryRun

func CreateServerDryRun(ctx context.Context, wf *wfv1.Workflow, wfClientset wfclientset.Interface) (*wfv1.Workflow, error)

CreateServerDryRun fills the workflow struct with the server's representation without creating it and returns an error, if there is any

func FindWaitCtrIndex added in v3.1.13

func FindWaitCtrIndex(pod *apiv1.Pod) (int, error)

func FormulateResubmitWorkflow

func FormulateResubmitWorkflow(ctx context.Context, wf *wfv1.Workflow, memoized bool, parameters []string) (*wfv1.Workflow, error)

FormulateResubmitWorkflow formulate a new workflow from a previous workflow, optionally re-using successful nodes

func FormulateRetryWorkflow added in v3.4.0

func FormulateRetryWorkflow(ctx context.Context, wf *wfv1.Workflow, restartSuccessful bool, nodeFieldSelector string, parameters []string) (*wfv1.Workflow, []string, error)

FormulateRetryWorkflow formulates a previous workflow to be retried, deleting all failed steps as well as the onExit node (and children)

func FromUnstructured

func FromUnstructured(un *unstructured.Unstructured) (*wfv1.Workflow, error)

FromUnstructured converts an unstructured object to a workflow. This function performs a lot of allocations and con resulting in a lot of memory being used. Users should avoid invoking this function if the data they need is available from `unstructured.Unstructured`. especially if they're looping. Available values include: `GetLabels()`, `GetName()`, `GetNamespace()` etc. Single values can be accessed using `unstructured.Nested*`, e.g. `unstructured.NestedString(un.Object, "spec", "phase")`.

func FromUnstructuredObj

func FromUnstructuredObj(un *unstructured.Unstructured, v interface{}) error

func GeneratePodName added in v3.4.4

func GeneratePodName(workflowName, nodeName, templateName, nodeID string, version PodNameVersion) string

GeneratePodName return a deterministic pod name

func GetNodeType

func GetNodeType(tmpl *wfv1.Template) wfv1.NodeType

func GetTemplateFromNode added in v3.4.1

func GetTemplateFromNode(node wfv1.NodeStatus) string

func HasWindowsOSNodeSelector added in v3.1.13

func HasWindowsOSNodeSelector(nodeSelector map[string]string) bool

func InstanceIDRequirement

func InstanceIDRequirement(instanceID string) labels.Requirement

InstanceIDRequirement returns the label requirement to filter against a controller instance (or not)

func IsJSONStr

func IsJSONStr(str string) bool

func IsWindowsUNCPath added in v3.1.13

func IsWindowsUNCPath(path string, tmpl *wfv1.Template) bool

IsWindowsUNCPath checks if path is prefixed with \\ This can be used to skip any processing of paths that point to SMB shares, local named pipes and local UNC path

func IsWorkflowCompleted

func IsWorkflowCompleted(wf *wfv1.Workflow) bool

IsWorkflowCompleted returns whether or not a workflow is considered completed

func IsWorkflowSuspended

func IsWorkflowSuspended(wf *wfv1.Workflow) bool

IsWorkflowSuspended returns whether or not a workflow is considered suspended

func JoinWorkflowMetaData

func JoinWorkflowMetaData(wfMetaData, wfDefaultMetaData *metav1.ObjectMeta)

JoinWorkflowMetaData will join the workflow metadata with the following order of preference 1. Workflow, 2 WorkflowTemplate (WorkflowTemplateRef), 3. WorkflowDefault.

func JoinWorkflowSpec

func JoinWorkflowSpec(wfSpec, wftSpec, wfDefaultSpec *wfv1.WorkflowSpec) (*wfv1.Workflow, error)

JoinWorkflowSpec will join the workflow specs with the following order of preference 1. Workflow Spec, 2 WorkflowTemplate Spec (WorkflowTemplateRef), 3. WorkflowDefault Spec.

func MergeTo

func MergeTo(patch, target *wfv1.Workflow) error

MergeTo will merge one workflow (the "patch" workflow) into another (the "target" workflow. If the target workflow defines a field, this take precedence over the patch.

func NewWorkflowInformer

func NewWorkflowInformer(dclient dynamic.Interface, ns string, resyncPeriod time.Duration, tweakListRequestListOptions internalinterfaces.TweakListOptionsFunc, tweakWatchRequestListOptions internalinterfaces.TweakListOptionsFunc, indexers cache.Indexers) cache.SharedIndexInformer

NewWorkflowInformer returns the workflow informer used by the controller. This is actually a custom built UnstructuredInformer which is in actuality returning unstructured.Unstructured objects. We no longer return WorkflowInformer due to: https://github.com/kubernetes/kubernetes/issues/57705 https://github.com/argoproj/argo-workflows/issues/632

func OverrideOutputParametersWithDefault added in v3.6.1

func OverrideOutputParametersWithDefault(outputs *wfv1.Outputs) error

func PopulateSubmitOpts

func PopulateSubmitOpts(command *cobra.Command, submitOpts *wfv1.SubmitOpts, parameterFile *string, includeDryRun bool)

func RandSuffix added in v3.3.0

func RandSuffix() string

RandSuffix generates a random suffix suitable for suffixing resource name.

func ReadFromFilePathsOrUrls

func ReadFromFilePathsOrUrls(filePathsOrUrls ...string) ([][]byte, error)

ReadFromFilePathsOrUrls reads the content of a single or a list of file paths and/or urls

func ReadFromStdin

func ReadFromStdin() ([]byte, error)

Reads from stdin

func ReadFromUrl

func ReadFromUrl(url string) ([]byte, error)

Reads the content of a url

func ReadManifest

func ReadManifest(manifestPaths ...string) ([][]byte, error)

ReadManifest reads from stdin, a single file/url, or a list of files and/or urls

func ReadParametersFile added in v3.3.2

func ReadParametersFile(file string, opts *wfv1.SubmitOpts) error

func ResumeWorkflow

func ResumeWorkflow(ctx context.Context, wfIf v1alpha1.WorkflowInterface, hydrator hydrator.Interface, workflowName string, nodeFieldSelector string) error

ResumeWorkflow resumes a workflow by setting spec.suspend to nil and any suspended nodes to Successful. Retries conflict errors

func SelectorMatchesNode

func SelectorMatchesNode(selector fields.Selector, node wfv1.NodeStatus) bool

func SetWorkflow

func SetWorkflow(ctx context.Context, wfClient v1alpha1.WorkflowInterface, hydrator hydrator.Interface, name string, nodeFieldSelector string, values SetOperationValues) error

func StopWorkflow

func StopWorkflow(ctx context.Context, wfClient v1alpha1.WorkflowInterface, hydrator hydrator.Interface, name string, nodeFieldSelector string, message string) error

StopWorkflow terminates a workflow by setting its spec.shutdown to ShutdownStrategyStop Or terminates a single resume step referenced by nodeFieldSelector

func SubmitWorkflow

func SubmitWorkflow(ctx context.Context, wfIf v1alpha1.WorkflowInterface, wfClientset wfclientset.Interface, namespace string, wf *wfv1.Workflow, opts *wfv1.SubmitOpts) (*wfv1.Workflow, error)

SubmitWorkflow validates and submits a single workflow and overrides some of the fields of the workflow

func SuspendWorkflow

func SuspendWorkflow(ctx context.Context, wfIf v1alpha1.WorkflowInterface, workflowName string) error

SuspendWorkflow suspends a workflow by setting spec.suspend to true. Retries conflict errors

func TerminateWorkflow

func TerminateWorkflow(ctx context.Context, wfClient v1alpha1.WorkflowInterface, name string) error

TerminateWorkflow terminates a workflow by setting its spec.shutdown to ShutdownStrategyTerminate

func ToUnstructured

func ToUnstructured(wf *wfv1.Workflow) (*unstructured.Unstructured, error)

ToUnstructured converts an workflow to an Unstructured object

Types

type AlreadyShutdownError added in v3.4.12

type AlreadyShutdownError struct {
	// contains filtered or unexported fields
}

func (AlreadyShutdownError) Error added in v3.4.12

func (e AlreadyShutdownError) Error() string

type PodNameVersion added in v3.2.5

type PodNameVersion string

PodNameVersion stores which type of pod names should be used. v1 represents the node id. v2 is the combination of a node id and template name.

const (
	// PodNameV1 is the v1 name that uses node ids for pod names
	PodNameV1 PodNameVersion = "v1"
	// PodNameV2 is the v2 name that uses node id combined with
	// the template name
	PodNameV2             PodNameVersion = "v2"
	DefaultPodNameVersion PodNameVersion = PodNameV2
)

func GetPodNameVersion added in v3.2.5

func GetPodNameVersion() PodNameVersion

GetPodNameVersion returns the pod name version to be used

func GetWorkflowPodNameVersion added in v3.2.7

func GetWorkflowPodNameVersion(wf *v1alpha1.Workflow) PodNameVersion

GetWorkflowPodNameVersion gets the pod name version from the annotation of a given workflow

func (PodNameVersion) String added in v3.2.5

func (v PodNameVersion) String() string

String stringifies the pod name version

type SetOperationValues

type SetOperationValues struct {
	Phase            wfv1.NodePhase
	Message          string
	OutputParameters map[string]string
}

type WorkflowLister

type WorkflowLister interface {
	List() ([]*wfv1.Workflow, error)
}

WorkflowLister implements the List() method of v1alpha.WorkflowLister interface but does so using an Unstructured informer and converting objects to workflows. Ignores objects that failed to convert.

func NewWorkflowLister

func NewWorkflowLister(informer cache.SharedIndexInformer) WorkflowLister

NewWorkflowLister returns a new workflow lister

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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