Help us shape the future of Go! Take the 2026 Go Developer Survey

template

package
v0.0.114 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyWritten = errors.New("context position is already written")

Functions

func ResolveDeferredInputs added in v0.0.66

func ResolveDeferredInputs(snapshot json.RawMessage, input map[string]any) (map[string]any, error)

func ScopeID

func ScopeID(meta recipe.NodeMetadata, fallback string, scopeType ScopeType) string

ScopeID exposes the internal scope id logic for validation pre-seeding.

Types

type CELOptionsProvider

type CELOptionsProvider = cel.OptionsProvider

CELOptionsProvider supplies type options (must be applied at env creation) and function options (require adapter) for CEL.

func MergeCELOptionsProviders

func MergeCELOptionsProviders(providers ...CELOptionsProvider) CELOptionsProvider

type DiagnosticsObserver added in v0.0.11

type DiagnosticsObserver interface {
	VarsResolved(scope ScopeType, nodePath string, vars map[string]interface{})
}

type DynamicOutputs

type DynamicOutputs map[string]interface{}

DynamicOutputs marks a map whose keys are not known until runtime (e.g. child recipe outputs). During validation we want template resolution to tolerate missing keys and return a benign placeholder instead of failing with "no such key". DynamicOutputs is a marker type we use when seeding validation placeholders for steps whose outputs are not knowable at compile time (e.g., child recipes). It aliases a simple map so normal execution still gets a concrete map, while validation can wrap it in a permissive accessor.

type ExecutionOutput added in v0.0.110

type ExecutionOutput struct {
	Outputs      map[string]any
	ArtifactRefs map[string]recipeartifacts.Ref
	Artifacts    []jobdb.Artifact
	Jobs         jobcontext.StartedJobsContext
}

ExecutionOutput is prepared by a scope body and published by its caller only after the execution engine accepts the scope outcome. Values are immutable after publication; preparing this record does not copy them or update a map.

type ExpressionSegment

type ExpressionSegment struct {
	Expression string // Raw CEL expression
	Pos        int    // Start position in original input
}

ExpressionSegment represents a CEL expression in a template

func (ExpressionSegment) Position

func (e ExpressionSegment) Position() int

type RenderMode

type RenderMode int

RenderMode defines how templates should be resolved (interpolation vs pure CEL).

const (
	// ModeInterpolation supports string interpolation with embedded expressions
	ModeInterpolation RenderMode = iota
	// ModePureCEL requires pure CEL expression only (for when conditions)
	ModePureCEL
)

type ResolutionContext

type ResolutionContext struct {
	Permissions permissions.State
	GitProfile  gitprofile.Selection

	ToolScopes []toolenv.Scope
	// ExecutionNeeds is lexical same-job state, never a persistent job override.
	ExecutionNeeds execution.Requirements

	// Scope type: "root", "sequence", "state_machine", "state"
	ScopeType ScopeType
	Options   ResolutionOptions
	// EffectiveConst is inherited down the node tree and prevents git state advancement.
	EffectiveConst bool

	// Parent context (nil for root)
	Parent *ResolutionContext

	// Template data for current scope
	TemplateData templateData

	// CEL environment for when expressions
	CELEnv *cel.Env

	CurrentRunID string // Track current run for this scope
	// contains filtered or unexported fields
}

ResolutionContext represents template resolution context

func NewRecipeResolutionContext

func NewRecipeResolutionContext(commitContext *contextual.GitCommitContext, recipeInputs map[string]interface{}, execCtx contextual.JobContext, opts ...ResolutionOptions) (*ResolutionContext, error)

NewRecipeResolutionContext creates a new resolution context for a recipe

func (*ResolutionContext) AddExecution

func (rc *ResolutionContext) AddExecution(output map[string]interface{}) error

func (*ResolutionContext) AddExecutionWithArtifactData

func (rc *ResolutionContext) AddExecutionWithArtifactData(output map[string]interface{}, artifactRefs map[string]recipeartifacts.Ref, artifacts []jobdb.Artifact) error

func (*ResolutionContext) AddExecutionWithArtifacts

func (rc *ResolutionContext) AddExecutionWithArtifacts(output map[string]interface{}, artifactRefs map[string]recipeartifacts.Ref) error

func (*ResolutionContext) AddExecutionWithContextData added in v0.0.42

func (rc *ResolutionContext) AddExecutionWithContextData(output map[string]interface{}, artifactRefs map[string]recipeartifacts.Ref, artifacts []jobdb.Artifact, jobs jobcontext.StartedJobsContext) error

func (*ResolutionContext) AdoptExecution added in v0.0.110

func (rc *ResolutionContext) AdoptExecution(src *ResolutionContext)

AdoptExecution keeps the completed view's bindings. Ancestors and execution bookkeeping are already shared; there is no graph traversal or map copying.

func (*ResolutionContext) AdoptRestart added in v0.0.110

func (rc *ResolutionContext) AdoptRestart(src *ResolutionContext)

AdoptRestart installs the patched graph while keeping enclosing native map views connected. This copying is confined to restart patch preparation.

func (*ResolutionContext) ApplyContextPatch

func (rc *ResolutionContext) ApplyContextPatch(p coretask.ContextPatch) error

ApplyContextPatch mutates template-visible context for this ResolutionContext.

Job patches are applied to this context and all ancestors (global visibility). Scoped patches are applied to the currently-visible scope containers only (e.g. a sequence's "sequence" map, or a state machine's "states" map).

func (*ResolutionContext) CloneForRestart added in v0.0.110

func (rc *ResolutionContext) CloneForRestart() (*ResolutionContext, error)

CloneForRestart isolates the resolver graph before applying a restart patch. Ordinary scope execution uses ExecutionView and never clones stored data.

func (*ResolutionContext) EvaluateCEL

func (rc *ResolutionContext) EvaluateCEL(expr string) (bool, error)

EvaluateCEL handles pure CEL evaluation for when conditions

func (*ResolutionContext) ExecutionView added in v0.0.110

func (rc *ResolutionContext) ExecutionView() *ResolutionContext

ExecutionView creates a lexical resolver header for serial orchestration. All context maps, payloads, and execution bookkeeping are shared. Only the header's temporary permissions/profile/options and last-result bindings vary.

func (*ResolutionContext) GetGitCommitContext

func (rc *ResolutionContext) GetGitCommitContext() contextual.GitCommitContext

func (*ResolutionContext) GetLastArtifactRefs

func (rc *ResolutionContext) GetLastArtifactRefs() []recipeartifacts.Ref

func (*ResolutionContext) GetLastArtifacts

func (rc *ResolutionContext) GetLastArtifacts() []jobdb.Artifact

func (*ResolutionContext) GetLastExecution

func (rc *ResolutionContext) GetLastExecution() map[string]interface{}

func (*ResolutionContext) GetLastJobs added in v0.0.42

func (*ResolutionContext) InputSnapshot added in v0.0.66

func (rc *ResolutionContext) InputSnapshot() (json.RawMessage, error)

InputSnapshot preserves the template context for manifest defaults discovered only inside a live task. It contains unresolved references, never fetched values.

func (*ResolutionContext) NewChildContext

func (rc *ResolutionContext) NewChildContext(scopeType ScopeType, metadata recipe.NodeMetadata, fallback string, inputs map[string]interface{}) (*ResolutionContext, error)

NewChildContext creates a child resolution context

func (*ResolutionContext) NextWorkspaceID added in v0.0.54

func (rc *ResolutionContext) NextWorkspaceID(node string) string

NextWorkspaceID is local to the execution history. Job and goal IDs may change on restart, while names in the copied history must remain identical.

func (*ResolutionContext) PublishExecution added in v0.0.110

func (scope *ResolutionContext) PublishExecution(output ExecutionOutput) error

PublishExecution is called by serial orchestration after DoScope accepts the result. Tasks must never receive a resolver or call this publication method.

func (*ResolutionContext) PublishWorkspaceResult added in v0.0.54

func (rc *ResolutionContext) PublishWorkspaceResult(from *ResolutionContext)

PublishWorkspaceResult exports data, never the active Git state.

func (*ResolutionContext) RememberArtifacts

func (rc *ResolutionContext) RememberArtifacts(artifacts []jobdb.Artifact)

func (*ResolutionContext) ResolveCompositeInputs added in v0.0.54

func (rc *ResolutionContext) ResolveCompositeInputs(input map[string]interface{}) (map[string]interface{}, error)

Composite bindings are evaluated in the calling workspace, before the override.

func (*ResolutionContext) ResolveExecutionNeeds added in v0.0.52

func (rc *ResolutionContext) ResolveExecutionNeeds(needs *recipe.ExecutionNeeds) error

ResolveExecutionNeeds uses the same resolver as node inputs, after local vars are available. Each context owns its overlay; leaving it restores its parent.

func (*ResolutionContext) ResolveInputs added in v0.0.66

func (rc *ResolutionContext) ResolveInputs(input map[string]any) (map[string]any, error)

ResolveInputs is the only template entry point that can produce references. Callers must subsequently validate the destination schema.

func (*ResolutionContext) ResolveMap

func (rc *ResolutionContext) ResolveMap(input map[string]interface{}) (map[string]interface{}, error)

func (*ResolutionContext) ResolveTemplateWithMode

func (rc *ResolutionContext) ResolveTemplateWithMode(expr string, mode RenderMode) (interface{}, error)

ResolveTemplateWithMode handles expression evaluation with a specific mode

func (*ResolutionContext) ResolveValueWithLocals added in v0.0.24

func (rc *ResolutionContext) ResolveValueWithLocals(value interface{}, locals map[string]interface{}) (interface{}, error)

func (*ResolutionContext) ResolveValueWithMode

func (rc *ResolutionContext) ResolveValueWithMode(value interface{}, mode RenderMode) (interface{}, error)

ResolveValueWithMode recursively resolves templates in a value with a specific mode

func (*ResolutionContext) ResolveVars added in v0.0.11

func (rc *ResolutionContext) ResolveVars(vars map[string]interface{}) error

ResolveVars evaluates a vars block against the current outer vars snapshot, then atomically overlays the rendered values onto the current scope.

func (*ResolutionContext) RestartContextSnapshot added in v0.0.89

func (rc *ResolutionContext) RestartContextSnapshot() (job, visible map[string]any, err error)

RestartContextSnapshot returns detached JSON-shaped values, without resolving expressions or dereferencing artifacts, objects, configuration, or secrets. Job has the shape accepted by ContextPatch.Job; Visible uses template names.

func (*ResolutionContext) SelectGitProfile added in v0.0.92

func (rc *ResolutionContext) SelectGitProfile(spec *recipe.GitProfileSpec, op string) error

func (*ResolutionContext) TaskExecutionContext

func (rc *ResolutionContext) TaskExecutionContext() contextual.TaskExecutionContext

func (*ResolutionContext) UpdateGitState

func (rc *ResolutionContext) UpdateGitState(commit contextual.GitCommitContext)

func (*ResolutionContext) WithFailure added in v0.0.22

func (*ResolutionContext) WithLocals added in v0.0.24

func (rc *ResolutionContext) WithLocals(locals map[string]interface{}) *ResolutionContext

func (*ResolutionContext) WithWorkspace added in v0.0.54

WithWorkspace keeps output containers and lexical paths, but forks Git state.

type ResolutionMode

type ResolutionMode string
const (
	ModeRun      ResolutionMode = "run"
	ModeValidate ResolutionMode = "validate"
)

type ResolutionOptions

type ResolutionOptions struct {
	Mode                ResolutionMode
	ValidationMode      string
	ClampSliceIndex     bool
	AllowFutureStepRefs bool
	CatchBeforeRetry    bool
	// ResolvedSelectors carries compiler-internal selector pins for the current run.
	ResolvedSelectors map[string]string
	// ResolvedGitRefs carries compiler-internal repo/ref pins for the current run.
	ResolvedGitRefs map[string]string
	// CELOptionsProvider allows callers (server/api testserver, cortex) to inject CEL functions.
	// It is given the adapter to allow proper wrapping of complex return types.
	CELOptionsProvider  CELOptionsProvider
	DiagnosticsObserver DiagnosticsObserver
}

func DefaultResolutionOptions

func DefaultResolutionOptions() ResolutionOptions

type RunOutput

type RunOutput = contextual.RunOutput

RunOutput represents a single execution run

type ScopeMetadata

type ScopeMetadata struct {
	ExecutionID string    `json:"execution_id"`
	Timestamp   time.Time `json:"timestamp"`
}

ScopeMetadata contains execution context metadata

type ScopeType

type ScopeType string

ScopeType defines resolver scope kinds.

const (
	ScopeRecipe       ScopeType = "recipe"
	ScopeSequence     ScopeType = "sequence"
	ScopeStateMachine ScopeType = "state_machine"
	ScopeState        ScopeType = "state"
	ScopeOp           ScopeType = "op"
)

type Segment

type Segment interface {
	Position() int // For error reporting
	// contains filtered or unexported methods
}

Segment represents a parsed segment of a template

type StepOutput

type StepOutput = contextual.StepOutput

type TextSegment

type TextSegment struct {
	Text string
	Pos  int
}

TextSegment represents plain text in a template

func (TextSegment) Position

func (t TextSegment) Position() int

type TransitionData added in v0.0.11

type TransitionData struct {
	From    string                 `json:"from,omitempty"`
	To      string                 `json:"to,omitempty"`
	Payload map[string]interface{} `json:"payload"`
	Failure *recipe.RuntimeFailure `json:"failure,omitempty"`
}

TransitionData is the transition metadata visible to a target state invocation.

func EmptyTransitionData added in v0.0.11

func EmptyTransitionData() TransitionData

func NewFailureTransitionData added in v0.0.22

func NewFailureTransitionData(from string, to string, payload map[string]interface{}, failure *recipe.RuntimeFailure) TransitionData

NewFailureTransitionData takes ownership of its immutable payload and failure.

func NewTransitionData added in v0.0.11

func NewTransitionData(from string, to string, payload map[string]interface{}) TransitionData

func (TransitionData) AsMap added in v0.0.11

func (td TransitionData) AsMap() map[string]interface{}

func (TransitionData) Clone added in v0.0.11

func (td TransitionData) Clone() TransitionData

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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