Documentation
¶
Index ¶
- func CoerceType(value any, targetType Type) (any, error)
- type ArgDef
- type Call
- type CallRef
- type Condition
- func (c *Condition) Evaluate(ctx context.Context, resolverData map[string]any) (bool, error)
- func (c *Condition) EvaluateWithAdditionalVars(ctx context.Context, resolverData, additionalVars map[string]any) (bool, error)
- func (c *Condition) EvaluateWithSelf(ctx context.Context, resolverData map[string]any, self any) (bool, error)
- func (c Condition) MarshalJSON() ([]byte, error)
- func (c Condition) MarshalYAML() (any, error)
- func (c *Condition) UnmarshalJSON(data []byte) error
- func (c *Condition) UnmarshalYAML(node *yaml.Node) error
- type ForEachClause
- type IterationContext
- type OnErrorBehavior
- type Type
- type Usage
- type UsageExample
- type ValueRef
- func (v ValueRef) MarshalJSON() ([]byte, error)
- func (v ValueRef) MarshalYAML() (any, error)
- func (v *ValueRef) ReferencedVariables() map[string]struct{}
- func (v *ValueRef) ReferencesVariable(varName string) bool
- func (v *ValueRef) Resolve(ctx context.Context, resolverData map[string]any, self any) (any, error)
- func (v *ValueRef) ResolveWithIterationContext(ctx context.Context, resolverData map[string]any, self any, ...) (any, error)
- func (v *ValueRef) UnmarshalJSON(data []byte) error
- func (v *ValueRef) UnmarshalYAML(node *yaml.Node) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArgDef ¶ added in v0.34.0
type ArgDef struct {
// Type is the argument's declared type. Supplied values are coerced to this
// type via CoerceType. When omitted, the value passes through unchanged.
// Supported types: string, int, float (alias: number), bool, array, object,
// time, duration, and any.
Type Type `` /* 151-byte string literal not displayed */
// Required marks the argument as mandatory at every call site.
// A required argument cannot declare a Default.
Required bool `json:"required,omitempty" yaml:"required,omitempty" doc:"Whether the argument must be supplied at every call site"`
// Default is applied when the argument is omitted at a call site.
// Only valid when Required is false.
Default any `` /* 142-byte string literal not displayed */
// Description documents the argument for readers and tooling.
Description string `json:"description,omitempty" yaml:"description,omitempty" doc:"Human-readable description of the argument" maxLength:"500"`
}
ArgDef declares a single named, typed argument accepted by a Call definition. Arguments are supplied at each call site and bound (defaulted, required-checked, and type-coerced) before the call's provider inputs are resolved.
type Call ¶ added in v0.34.0
type Call struct {
// Description documents the call definition for readers and tooling.
Description string `` /* 129-byte string literal not displayed */
// Args declares the named, typed arguments the definition accepts, keyed by
// argument name.
Args map[string]*ArgDef `json:"args,omitempty" yaml:"args,omitempty" doc:"Named, typed argument declarations keyed by argument name"`
// Provider is the provider name executed when the call is invoked.
Provider string `` /* 229-byte string literal not displayed */
// Inputs are the provider inputs. They reference arguments via the args
// namespace and are resolved after arguments are bound.
Inputs map[string]*ValueRef `json:"inputs,omitempty" yaml:"inputs,omitempty" doc:"Provider inputs; reference arguments via the args namespace"`
// Dedup enables opt-in, in-memory de-duplication of identical invocations
// within a single run. Results are keyed by the bound argument values and
// are never persisted to state or shared across runs.
Dedup bool `` /* 146-byte string literal not displayed */
}
Call is a reusable, provider-agnostic request definition. It declares typed arguments and a provider plus inputs that reference those arguments via the args namespace (_.args.x in CEL, {{ .args.x }} in Go templates). A single definition can be invoked from multiple call sites, each supplying its own argument values and producing an independent result.
type CallRef ¶ added in v0.34.0
type CallRef struct {
// Call is the name of a spec.calls definition to invoke.
Call string `` /* 208-byte string literal not displayed */
// Args supplies argument values for the call, keyed by argument name.
// Values are standard ValueRefs (literals, rslvr, expr, or tmpl) and are
// resolved in the host step's context.
Args map[string]*ValueRef `` /* 135-byte string literal not displayed */
}
CallRef is embedded into step and action types to allow invoking a Call definition in place of a direct provider. Exactly one of {Call, Provider} may be set on a host step; this invariant is enforced by validation, not by the type system.
type Condition ¶
type Condition struct {
Expr *celexp.Expression `json:"expr" yaml:"expr" doc:"CEL expression that must evaluate to boolean" example:"_.environment == 'prod'"`
}
Condition represents a conditional execution clause. It wraps a CEL expression that must evaluate to a boolean value.
Supported YAML forms:
- Boolean literal: when: true / when: false
- String shorthand: when: "_.environment == 'prod'"
- Explicit object: when: { expr: "_.environment == 'prod'" }
- Expression alias: when: { expression: "_.environment == 'prod'" }
func (*Condition) Evaluate ¶
Evaluate evaluates the condition with the given resolver data. Returns true if the condition is met, false otherwise. Returns an error if evaluation fails or if the result is not a boolean.
func (*Condition) EvaluateWithAdditionalVars ¶
func (c *Condition) EvaluateWithAdditionalVars(ctx context.Context, resolverData, additionalVars map[string]any) (bool, error)
EvaluateWithAdditionalVars evaluates the condition with additional variables. This is useful for evaluating conditions with __self set to a specific value.
func (*Condition) EvaluateWithSelf ¶
func (c *Condition) EvaluateWithSelf(ctx context.Context, resolverData map[string]any, self any) (bool, error)
EvaluateWithSelf evaluates the condition with __self set to the provided value. This is used for until: conditions where __self should be the current resolved value.
func (Condition) MarshalJSON ¶ added in v0.10.0
MarshalJSON implements custom JSON marshalling for Condition.
func (Condition) MarshalYAML ¶ added in v0.10.0
MarshalYAML implements custom YAML marshalling for Condition. If the expression is a literal "true" or "false", it marshals as a boolean. Otherwise it uses the string shorthand form for compact output.
func (*Condition) UnmarshalJSON ¶ added in v0.10.0
UnmarshalJSON implements custom JSON unmarshalling for Condition. It supports boolean literals, string shorthand, and the explicit {"expr": "..."} form.
type ForEachClause ¶
type ForEachClause struct {
// Item is the variable name alias for the current element.
// Creates both __item (always) and this custom name.
// Optional - if not specified, only __item is available.
Item string `` /* 210-byte string literal not displayed */
// Index is the variable name alias for the current 0-based index.
// Creates both __index (always) and this custom name.
// Optional - if not specified, only __index is available.
Index string `` /* 199-byte string literal not displayed */
// In specifies the array to iterate over.
// Optional - defaults to __self (current transform value) for resolvers.
In *ValueRef `json:"in,omitempty" yaml:"in,omitempty" doc:"Array to iterate over (default: __self for resolvers)"`
// Concurrency limits parallel execution.
// 0 (default) means unlimited parallelism.
Concurrency int `` /* 129-byte string literal not displayed */
// ContinueOnError controls whether a failed iteration allows execution to
// continue. It accepts a boolean or a CEL expression evaluated per iteration
// with the structured error bound as __error and the iteration variables
// (__item/__index plus any configured aliases) in scope. Truthy continues
// with the remaining iterations; falsy aborts. Overrides the deprecated
// OnError field. This field is only used by actions; resolvers ignore it.
ContinueOnError *Condition `` /* 284-byte string literal not displayed */
// OnError defines behavior when an iteration fails.
// This field is only used by actions; resolvers ignore it.
//
// Deprecated: use ContinueOnError instead.
OnError OnErrorBehavior `` /* 223-byte string literal not displayed */
// KeepSkipped controls whether items skipped by a when condition are
// retained as nil entries in the output array.
// By default (false), skipped items are removed so the output contains
// only the items that were actually processed. Set to true when you need
// the output array to remain index-aligned with the input array.
KeepSkipped bool `` /* 135-byte string literal not displayed */
}
ForEachClause defines iteration over an array. When present, the associated operation is executed once per array element and results are collected into an output array preserving order.
func (*ForEachClause) EffectiveOnError ¶ added in v0.28.0
func (f *ForEachClause) EffectiveOnError() OnErrorBehavior
EffectiveOnError returns the static, render-time error-handling behavior for the clause. A literal boolean continueOnError maps directly (true => OnErrorContinue, false => OnErrorFail); a non-literal CEL expression cannot be reduced to a static behavior here, so the deprecated OnError enum is used as the display value. This method is only a rendering approximation: the authoritative per-iteration decision -- including non-literal CEL continueOnError expressions evaluated against the iteration's __error/__item/__index context -- is made at runtime by the action executor (see Executor.actionShouldContinue / effectiveOnErrorPolicy).
type IterationContext ¶
type IterationContext struct {
Item any `json:"-" yaml:"-" doc:"Current array element (__item)"`
Index int `json:"-" yaml:"-" doc:"Current index (__index)"`
ItemAlias string `json:"-" yaml:"-" doc:"Custom name for item (if specified)"`
IndexAlias string `json:"-" yaml:"-" doc:"Custom name for index (if specified)"`
}
IterationContext holds the context for forEach iteration variables. It provides access to the current item and index during iteration.
type OnErrorBehavior ¶
type OnErrorBehavior string
OnErrorBehavior defines how to handle errors during execution. It is used by both resolvers and actions to control error propagation.
const ( // OnErrorFail stops execution and returns the error. // This is the default for transform and action phases. // In the resolve phase, the default is OnErrorContinue (fallback chain semantics). OnErrorFail OnErrorBehavior = "fail" // OnErrorContinue continues execution despite errors. // For resolve phase: tries the next source (this is the default). // For transform phase: skips the failed step, keeps current value. // For actions: continues with remaining iterations or actions. OnErrorContinue OnErrorBehavior = "continue" )
func (OnErrorBehavior) IsValid ¶
func (b OnErrorBehavior) IsValid() bool
IsValid returns true if the behavior is a valid OnErrorBehavior value.
func (OnErrorBehavior) OrDefault ¶
func (b OnErrorBehavior) OrDefault() OnErrorBehavior
OrDefault returns the behavior or the default (OnErrorFail) if empty.
type Type ¶
type Type string
Type represents the type of a resolved value.
const ( TypeString Type = "string" TypeInt Type = "int" // int64 internally TypeFloat Type = "float" // float64 TypeBool Type = "bool" TypeArray Type = "array" // []any (heterogeneous) TypeObject Type = "object" // map[string]any TypeTime Type = "time" // time.Time TypeDuration Type = "duration" // time.Duration TypeAny Type = "any" )
type Usage ¶ added in v0.34.0
type Usage struct {
// Synopsis is a one-line description of how to consume the solution.
// When set it takes precedence over the metadata description in the usage view.
Synopsis string `` /* 186-byte string literal not displayed */
// Details is free-form, multi-paragraph prose describing how the solution
// works and when to use it -- the long-form counterpart to the one-line
// description/synopsis (analogous to a command's long help or a README body).
Details string `` /* 140-byte string literal not displayed */
// Examples are curated command examples shown in the usage view.
Examples []UsageExample `json:"examples,omitempty" yaml:"examples,omitempty" doc:"Curated usage examples" maxItems:"50"`
}
Usage holds optional, author-curated documentation describing how to consume a solution. It enriches the auto-generated usage view surfaced by `inspect solution --usage`; when absent, the view is generated entirely from the solution's parameters and actions.
type UsageExample ¶ added in v0.34.0
type UsageExample struct {
// Description explains what the example does.
Description string `` /* 141-byte string literal not displayed */
// Command is the CLI invocation to run.
Command string `` /* 134-byte string literal not displayed */
}
UsageExample is a single curated example: a human description paired with the CLI command that performs it.
type ValueRef ¶
type ValueRef struct {
Literal any `json:"-" yaml:"-"`
Resolver *string `` /* 198-byte string literal not displayed */
Expr *celexp.Expression `json:"expr,omitempty" yaml:"expr,omitempty" doc:"CEL expression to evaluate"`
Tmpl *gotmpl.GoTemplatingContent `json:"tmpl,omitempty" yaml:"tmpl,omitempty" doc:"Go template to execute"`
}
ValueRef represents a value that can be literal, resolver reference, expression, or template. It is used throughout the resolver and action systems to provide flexible value specification.
func (ValueRef) MarshalJSON ¶ added in v0.7.0
MarshalJSON implements custom JSON marshalling for ValueRef. Mirrors MarshalYAML to ensure consistent serialization across formats.
func (ValueRef) MarshalYAML ¶ added in v0.7.0
MarshalYAML implements custom YAML marshalling for ValueRef. This is required to survive the deepCopySolution YAML round-trip used in compose/bundling. Without it, the Literal field (tagged yaml:"-") would be silently dropped during marshaling.
func (*ValueRef) ReferencedVariables ¶ added in v0.7.0
ReferencedVariables returns the set of all variable names referenced by this ValueRef. It collects top-level variables, underscore-prefixed variables, and template references in a single pass. Use this instead of calling ReferencesVariable multiple times to avoid redundant expression parsing.
func (*ValueRef) ReferencesVariable ¶
ReferencesVariable checks if the ValueRef references a specific variable name. This is useful for detecting references to __actions, __self, __item, etc. For expressions, it checks both top-level variables (like __actions, __self) and underscore-prefixed variables (like _.environment).
func (*ValueRef) Resolve ¶
Resolve resolves the ValueRef to a concrete value. This is a convenience method that calls ResolveWithIterationContext with nil iteration context.
func (*ValueRef) ResolveWithIterationContext ¶
func (v *ValueRef) ResolveWithIterationContext(ctx context.Context, resolverData map[string]any, self any, iterCtx *IterationContext) (any, error)
ResolveWithIterationContext resolves the ValueRef with optional forEach iteration context. It handles literal values, resolver references, CEL expressions, and Go templates.
func (*ValueRef) UnmarshalJSON ¶ added in v0.7.0
UnmarshalJSON implements custom JSON unmarshalling for ValueRef. Mirrors UnmarshalYAML to ensure consistent deserialization across formats.