variables

package
v4.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package variables is the catalog of every Argo Workflows expression variable. Each variable is declared once via Define (in util/variables/keys/) and obtains a *Key handle. A *Scope's storage is unexported, so Key.Set and Key.SetSkipped are its only write paths and both key entries through the catalog — the Scope write sites therefore cannot drift from the catalog.

Scopes that are not a *Scope (the metric, loop and retry substitution maps are plain map[string]string) still derive their keys from the catalog via Key.Template / Key.Concretize, but, being ordinary maps, are not structurally constrained to it.

Index

Constants

This section is empty.

Variables

Functions

func GenerateMarkdown

func GenerateMarkdown() string

GenerateMarkdown renders the catalog as Markdown. Sections: alphabetical index, by Kind, matrix by TemplateKind, by LifecyclePhase.

Types

type Key

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

Key is the handle for a single variable. Obtainable only via Define.

func All

func All() []*Key

All returns a snapshot of every registered Key, sorted by Template.

func Define

func Define(spec Spec) *Key

Define registers a variable and returns its handle. Panics on duplicate or empty Template — these are programmer errors.

func (*Key) Concretize

func (k *Key) Concretize(args ...string) string

Concretize substitutes placeholders in Template with the given args.

func (*Key) Set

func (k *Key) Set(s *Scope, value any, args ...string)

Set writes through a Key

func (*Key) SetSkipped

func (k *Key) SetSkipped(s *Scope, value any, args ...string)

SetSkipped writes through a Key, marking the variable as skipped

func (*Key) Template

func (k *Key) Template() string

Template returns the key template (e.g. "steps.<name>.id"). Used by tests.

type Kind

type Kind int
const (
	KindGlobal Kind = iota
	KindRuntime
	KindInput
	KindOutput
	KindNodeRef
	KindItem
	KindRetry
	KindNodeCtx
	KindMetric
	KindCronWorkflow
)

func (Kind) String

func (k Kind) String() string

type LifecyclePhase

type LifecyclePhase string

LifecyclePhase is a coarse point-in-time within one workflow execution. Phase names are surfaced verbatim in the generated docs.

const (
	PhWorkflowStart      LifecyclePhase = "workflow-start"
	PhPreDispatch        LifecyclePhase = "pre-dispatch"
	PhDuringExecute      LifecyclePhase = "during-execute"
	PhInsideLoop         LifecyclePhase = "inside-loop"
	PhInsideRetry        LifecyclePhase = "inside-retry"
	PhAfterNodeInit      LifecyclePhase = "after-node-init"
	PhAfterPodStart      LifecyclePhase = "after-pod-start"
	PhAfterNodeComplete  LifecyclePhase = "after-node-complete"
	PhAfterNodeSucceeded LifecyclePhase = "after-node-succeeded"
	PhAfterLoop          LifecyclePhase = "after-loop"
	PhExitHandler        LifecyclePhase = "exit-handler"
	PhMetricEmission     LifecyclePhase = "metric-emission"
	PhCronEval           LifecyclePhase = "cron-eval"
)

func ReachablePhases

func ReachablePhases(k TemplateKind) []LifecyclePhase

ReachablePhases returns the lifecycle phases that can actually fire from inside a template body of the given kind. Used by the doc generator to gate matrix `•` marks: a variable is only shown reachable from a TemplateKind column if at least one of its declared phases is in this set. This prevents "narrow" phases (PhInsideLoop, PhInsideRetry, PhExitHandler, PhCronEval) from leaking into columns that never enter those phases — e.g. `item` showing up under the exit-handler column.

TmplExitHandler is treated as a context, not a body type: any leaf body (container/script/etc.) can serve as an onExit handler, but the matrix renders it as a separate column for catalog readers, so its column reflects exit-handler semantics rather than generic body semantics.

type Scope

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

Scope holds variable values. Writes only via Key.Set.

func NewScope

func NewScope() *Scope

func (*Scope) AsAnyMap

func (s *Scope) AsAnyMap() map[string]any

AsAnyMap returns a snapshot. Nil-safe.

func (*Scope) AsStringMap

func (s *Scope) AsStringMap() map[string]string

AsStringMap returns a snapshot of string-valued entries. Nil-safe.

func (*Scope) IsSkipped

func (s *Scope) IsSkipped(key string) bool

type Spec

type Spec struct {
	Template    string
	Kind        Kind
	ValueType   string
	AppliesTo   []TemplateKind
	Phases      []LifecyclePhase
	Description string
}

Spec holds a Key's metadata. Passed to Define.

type TemplateKind

type TemplateKind string

TemplateKind categorises a wfv1.Template by its body type.

const (
	TmplAll          TemplateKind = "any"
	TmplContainer    TemplateKind = "container"
	TmplContainerSet TemplateKind = "container-set"
	TmplScript       TemplateKind = "script"
	TmplResource     TemplateKind = "resource"
	TmplSteps        TemplateKind = "steps"
	TmplDAG          TemplateKind = "dag"
	TmplData         TemplateKind = "data"
	TmplSuspend      TemplateKind = "suspend"
	TmplHTTP         TemplateKind = "http"
	TmplPlugin       TemplateKind = "plugin"
	TmplExitHandler  TemplateKind = "exit-handler"
	TmplCronWorkflow TemplateKind = "cron-workflow"
)

Directories

Path Synopsis
Package keys is the single location where every workflow variable is declared.
Package keys is the single location where every workflow variable is declared.

Jump to

Keyboard shortcuts

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