Documentation
¶
Index ¶
- Constants
- func BuildCellRecipeSelector(repositorySource string, recipeName string, ref string) (string, error)
- func ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, ...) (map[string]interface{}, []jobdb.Artifact, error)
- func ExecuteRecipeWithExecutor(exec RecipeExecutor, ctx workflow.Context, r recipe.Recipe, ...) (map[string]interface{}, []jobdb.Artifact, error)
- func ExecutionConsumerVersions(overrides map[string]string) map[string]string
- func GenerateTestContext() (contextual.JobContext, contextual.GitCommitContext)
- func IsCellRecipeName(value string) bool
- func IsGitRecipeSelector(selector string) bool
- func IsLocalRecipeFileReference(value string) bool
- func NewRecipeJobWorker(opts RecipeJobWorkerOptions) jobworkflow.ExecutionWorker
- func NewRecipeWorker(dependencies ops.ServiceDependencies2, ...) (*jobworkflow.WorkSet, error)
- func NewRecipeWorkerWithOptions(dependencies ops.ServiceDependencies2, ...) (*jobworkflow.WorkSet, error)
- func NewWorkspaceResolutionTaskWorker() jobworkflow.TaskWorker
- func NormalizeGitRepositorySource(source string) (string, error)
- func RepositoryNameFromSource(source string) string
- func ValidateRecipeSelector(selector string) error
- type CELVariables
- type DefaultRecipeExecutor
- func (d DefaultRecipeExecutor) ExecuteChildGroup(ctx workflow.Context, parent *template.ResolutionContext, ...) error
- func (d DefaultRecipeExecutor) ExecuteNode(ctx workflow.Context, parentResCtx *template.ResolutionContext, n *recipe.Node) error
- func (d DefaultRecipeExecutor) ExecuteOp(ctx workflow.Context, parentResolutionContext *template.ResolutionContext, ...) error
- func (d DefaultRecipeExecutor) ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, ...) (map[string]interface{}, []jobdb.Artifact, error)
- func (d DefaultRecipeExecutor) ExecuteSequence(ctx workflow.Context, rCtx *template.ResolutionContext, ...) error
- func (d DefaultRecipeExecutor) ExecuteStateMachine(ctx workflow.Context, parentContext *template.ResolutionContext, ...) error
- func (d DefaultRecipeExecutor) WithDelegate(delegate RecipeExecutor) DefaultRecipeExecutor
- type EnvironmentInfo
- type ExecutionHandoff
- type ExecutionInfo
- type ExecutionMode
- type ExecutionOptions
- type InlineResolutionOptions
- type InlineResolutionResult
- type NoOpStateObserver
- type NormalizedOpInput
- type RecipeContext
- type RecipeExecutor
- type RecipeInfo
- type RecipeJobWorkerOptions
- type RecipeRefResolver
- type RecipeRefYAMLLoader
- type RecipeSourceKind
- type RecipeSourceResolution
- type RecipeSourceResolver
- type RecipeSourceResolverOptions
- type RecipeSourceYAMLLoader
- type ResolvedRecipeSource
- type ScopedContext
- func (sc *ScopedContext) GetCELVariables(currentOutputs map[string]interface{}) map[string]interface{}
- func (sc *ScopedContext) GetStepOutput(stepID string) (interface{}, bool)
- func (sc *ScopedContext) GetTemplateData() map[string]interface{}
- func (sc *ScopedContext) MergeOutputs() map[string]interface{}
- func (sc *ScopedContext) SetStepOutput(stepID string, output interface{})
- type StateContext
- type StateInfo
- type StateObserver
- type StepResult
- type TransitionSelectionObserver
- type ValidationMode
- type ValidationOptions
- type WithinRecipeResolutionResult
- type WorkspaceResolutionInput
- type WorkspaceResolutionOutput
Constants ¶
const ( CellRecipeDirectory = ".c2/recipes" DefaultRecipeName = "build" DefaultRecipeRef = "main" SharedBuildRecipeSelector = "git+https://github.com/colony-2/recipes.git//build.yaml@main" )
const RootSourceResolutionTaskType = "recipe_root_source_resolve"
const WithinRecipeResolutionTaskType = "recipe_within_resolution"
const WorkspaceResolutionTaskType = "recipe_workspace_resolve"
Variables ¶
This section is empty.
Functions ¶
func BuildCellRecipeSelector ¶
func ExecuteRecipe ¶
func ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)
ExecuteRecipe keeps the existing public entry point, delegating to the default executor.
func ExecuteRecipeWithExecutor ¶
func ExecuteRecipeWithExecutor(exec RecipeExecutor, ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)
ExecuteRecipeWithExecutor allows callers to run with a custom executor (e.g., decorator).
func ExecutionConsumerVersions ¶ added in v0.0.72
ExecutionConsumerVersions supplies provenance through JobDB's execution headers and activation records. Embedders may add their own versions or override c2j's build label. Their host revision must not be attributed to c2j.
func GenerateTestContext ¶
func GenerateTestContext() (contextual.JobContext, contextual.GitCommitContext)
func IsCellRecipeName ¶
func IsGitRecipeSelector ¶
func NewRecipeJobWorker ¶
func NewRecipeJobWorker(opts RecipeJobWorkerOptions) jobworkflow.ExecutionWorker
func NewRecipeWorker ¶
func NewRecipeWorker(dependencies ops.ServiceDependencies2, activityRegistry *workerops.ActivityRegistry, provider ...template.CELOptionsProvider) (*jobworkflow.WorkSet, error)
func NewRecipeWorkerWithOptions ¶
func NewRecipeWorkerWithOptions(dependencies ops.ServiceDependencies2, activityRegistry *workerops.ActivityRegistry, opts RecipeJobWorkerOptions) (*jobworkflow.WorkSet, error)
func NewWorkspaceResolutionTaskWorker ¶ added in v0.0.54
func NewWorkspaceResolutionTaskWorker() jobworkflow.TaskWorker
func ValidateRecipeSelector ¶
Types ¶
type CELVariables ¶
type CELVariables struct {
Outputs map[string]interface{} `json:"Outputs"`
State *StateInfo `json:"State"`
States map[string]map[string]interface{} `json:"States"`
Inputs map[string]interface{} `json:"ContainerInputs"`
Context *RecipeContext `json:"Context"`
Steps map[string]interface{} `json:"Steps"` // Access to step outputs within current state
}
CELVariables represents the variables available in CEL expressions
type DefaultRecipeExecutor ¶
type DefaultRecipeExecutor struct {
// contains filtered or unexported fields
}
DefaultRecipeExecutor preserves the existing execution behavior, with optional CEL provider injection.
func NewDefaultRecipeExecutor ¶
func NewDefaultRecipeExecutor(provider template.CELOptionsProvider) DefaultRecipeExecutor
NewDefaultRecipeExecutor builds an executor with a default CEL provider.
func (DefaultRecipeExecutor) ExecuteChildGroup ¶ added in v0.0.24
func (d DefaultRecipeExecutor) ExecuteChildGroup(ctx workflow.Context, parent *template.ResolutionContext, metadata recipe.NodeMetadata, group recipe.ChildGroupData) error
func (DefaultRecipeExecutor) ExecuteNode ¶
func (d DefaultRecipeExecutor) ExecuteNode(ctx workflow.Context, parentResCtx *template.ResolutionContext, n *recipe.Node) error
ExecuteWorkflow implements the WorkflowExecutor interface for unified recipes
func (DefaultRecipeExecutor) ExecuteOp ¶
func (d DefaultRecipeExecutor) ExecuteOp(ctx workflow.Context, parentResolutionContext *template.ResolutionContext, metadata recipe.NodeMetadata, op string) error
func (DefaultRecipeExecutor) ExecuteRecipe ¶
func (d DefaultRecipeExecutor) ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)
func (DefaultRecipeExecutor) ExecuteSequence ¶
func (d DefaultRecipeExecutor) ExecuteSequence(ctx workflow.Context, rCtx *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, sequence []recipe.Node) error
func (DefaultRecipeExecutor) ExecuteStateMachine ¶
func (d DefaultRecipeExecutor) ExecuteStateMachine(ctx workflow.Context, parentContext *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, stateMap *recipe.StateMap, opts ...ExecutionOptions) error
ExecuteStateMachine runs the state machine with the new StateMap format
func (DefaultRecipeExecutor) WithDelegate ¶
func (d DefaultRecipeExecutor) WithDelegate(delegate RecipeExecutor) DefaultRecipeExecutor
WithDelegate returns a copy of the executor that will dispatch recursive executor calls (ExecuteNode/ExecuteSequence/ExecuteStateMachine/ExecuteOp) to the provided delegate. This allows decorators to wrap the default executor without reimplementing execution logic.
type EnvironmentInfo ¶
EnvironmentInfo contains environment context
type ExecutionHandoff ¶ added in v0.0.52
func ExecutionHandoffFromOutcome ¶ added in v0.0.72
func ExecutionHandoffFromOutcome(outcome jobworkflow.JobRunOutcome) (*ExecutionHandoff, error)
ExecutionHandoffFromOutcome decodes only this run's acknowledged environment handoff. Ordinary waits and unrelated Yield metadata are not environment changes.
type ExecutionInfo ¶
type ExecutionInfo struct {
StartedAt time.Time `json:"started_at"`
Timeout time.Duration `json:"timeout"`
}
ExecutionInfo contains execution context
type ExecutionMode ¶
type ExecutionMode string
const ( ExecutionModeRun ExecutionMode = "run" ExecutionModeValidate ExecutionMode = "validate" )
type ExecutionOptions ¶
type ExecutionOptions struct {
Mode ExecutionMode
Validation ValidationOptions
// Optional CEL options provider to inject extra functions/types.
CELOptionsProvider template.CELOptionsProvider
StateObserver StateObserver
DiagnosticsObserver template.DiagnosticsObserver
// ResolvedSelectors carries internal selector pins for the current recipe run.
ResolvedSelectors map[string]string
// ResolvedGitRefs carries internal repo/ref pins for the current recipe run.
ResolvedGitRefs map[string]string
}
type InlineResolutionOptions ¶ added in v0.0.29
type InlineResolutionOptions struct {
ProjectID string
RootFile string
WorkingDir string
Resolver RecipeSourceResolver
RootSource *RecipeSourceResolution
}
type InlineResolutionResult ¶ added in v0.0.29
func ResolveInlineRecipes ¶ added in v0.0.29
func ResolveInlineRecipes(ctx context.Context, rec recipe.Recipe, opts InlineResolutionOptions) (InlineResolutionResult, error)
type NoOpStateObserver ¶
type NoOpStateObserver struct{}
func (NoOpStateObserver) StateEntered ¶
func (NoOpStateObserver) StateEntered(stateName string)
func (NoOpStateObserver) StateExited ¶
func (NoOpStateObserver) StateExited(stateName string)
func (NoOpStateObserver) TransitionEvalauted ¶
func (NoOpStateObserver) TransitionEvalauted(expression string, result bool, nextStateIfExpressionTrue string)
type NormalizedOpInput ¶
type NormalizedOpInput struct {
Data map[string]interface{}
StoredArtifactKeys []jobdb.ArtifactKey
}
func NormalizeOpInput ¶
func NormalizeOpInput(inputType reflect.Type, raw map[string]interface{}) (NormalizedOpInput, error)
type RecipeContext ¶
type RecipeContext struct {
Recipe RecipeInfo `json:"recipe"`
Environment EnvironmentInfo `json:"environment"`
Execution ExecutionInfo `json:"execution"`
}
RecipeContext contains system-provided context variables
type RecipeExecutor ¶
type RecipeExecutor interface {
ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)
ExecuteNode(ctx workflow.Context, parentResCtx *template.ResolutionContext, n *recipe.Node) error
ExecuteStateMachine(ctx workflow.Context, parentContext *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, stateMap *recipe.StateMap, opts ...ExecutionOptions) error
ExecuteOp(ctx workflow.Context, parentResolutionContext *template.ResolutionContext, metadata recipe.NodeMetadata, op string) error
ExecuteChildGroup(ctx workflow.Context, parent *template.ResolutionContext, metadata recipe.NodeMetadata, group recipe.ChildGroupData) error
ExecuteSequence(ctx workflow.Context, rCtx *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, sequence []recipe.Node) error
}
RecipeExecutor defines the surface area for executing recipes, states, and ops. This enables decorator implementations (e.g., analysis) without changing call sites.
type RecipeInfo ¶
type RecipeInfo struct {
Name string `json:"name"`
Version string `json:"version"`
ExecutionID string `json:"execution_id"`
}
RecipeInfo contains information about the current recipe
type RecipeJobWorkerOptions ¶
type RecipeJobWorkerOptions struct {
// Logger optionally overrides the runtime logger (for request-scoped replay).
Logger *slog.Logger
ConsumerVersions map[string]string
Allocation execution.Allocation
ReadOnlyReplay bool
StageExecution func(jobdb.JobKey, execution.Demand)
WrapTaskWorker func(jobworkflow.TaskWorker) jobworkflow.TaskWorker
CELOptionsProvider template.CELOptionsProvider
BeforeScope func(context.Context, string, *template.ResolutionContext) error
// Executor overrides recipe execution for instrumentation. When nil, DefaultRecipeExecutor is used.
Executor RecipeExecutor
// ExecutorFactory overrides Executor when provided, allowing per-run executors.
ExecutorFactory func() RecipeExecutor
// RootSourceResolver resolves non-embedded root recipe selectors at execution time.
RootSourceResolver RecipeSourceResolver
// OnRecipeLoaded is called after the recipe artifact has been loaded and parsed.
OnRecipeLoaded func(recipeName string)
// OnRecipeSourceResolved is called after the root recipe source has been resolved.
OnRecipeSourceResolved func(RecipeSourceResolution)
}
type RecipeRefResolver ¶
type RecipeRefResolver interface {
ResolveRecipeRef(ctx context.Context, projectID string, selector string) (RecipeSourceResolution, error)
LoadRecipeRef(ctx context.Context, projectID string, selector string) (*recipe.Recipe, error)
}
type RecipeRefYAMLLoader ¶
type RecipeSourceKind ¶
type RecipeSourceKind string
const ( RecipeSourceKindArtifact RecipeSourceKind = "artifact" RecipeSourceKindServerRef RecipeSourceKind = "serverRef" RecipeSourceKindGit RecipeSourceKind = "git" )
type RecipeSourceResolution ¶
type RecipeSourceResolution struct {
SourceKind RecipeSourceKind `json:"source_kind"`
SubmittedSelector string `json:"submitted_selector"`
ResolvedSelector string `json:"resolved_selector,omitempty"`
ResolvedCommit string `json:"resolved_commit,omitempty"`
ArtifactName string `json:"artifact_name,omitempty"`
WasAlreadyPinned bool `json:"was_already_pinned"`
}
func (RecipeSourceResolution) EffectiveSelector ¶
func (r RecipeSourceResolution) EffectiveSelector() string
type RecipeSourceResolver ¶
type RecipeSourceResolver interface {
Resolve(ctx context.Context, projectID string, selector string) (RecipeSourceResolution, error)
Load(ctx context.Context, projectID string, resolution RecipeSourceResolution) (recipe.Recipe, error)
}
func NewRecipeSourceResolver ¶
func NewRecipeSourceResolver(opts RecipeSourceResolverOptions) RecipeSourceResolver
type RecipeSourceResolverOptions ¶
type RecipeSourceResolverOptions struct {
// GitRepository is retained for API compatibility. Git selectors are
// resolved through SelectorCache so extension and recipe sources share one
// materialization path.
GitRepository gitpkg.Repository
SelectorCache *selectorcache.Cache
RecipeRefResolver RecipeRefResolver
}
type RecipeSourceYAMLLoader ¶
type ResolvedRecipeSource ¶
type ResolvedRecipeSource struct {
RecipeSourceResolution
RecipeYAML string `json:"recipe_yaml,omitempty"`
}
func ParseResolvedRecipeSourceJSON ¶
func ParseResolvedRecipeSourceJSON(raw []byte) (*ResolvedRecipeSource, error)
func ParseResolvedRecipeSourceTaskData ¶
func ParseResolvedRecipeSourceTaskData(td jobdb.TaskData) (*ResolvedRecipeSource, error)
func (ResolvedRecipeSource) LoadRecipe ¶
func (r ResolvedRecipeSource) LoadRecipe() (recipe.Recipe, error)
type ScopedContext ¶
type ScopedContext struct {
// Parent scope (nil for root)
Parent *ScopedContext
// Local step outputs for this scope only
LocalStepOutputs map[string]interface{}
// Reference to the global state context
StateContext *StateContext
// Scope identifier for debugging
ScopeID string
}
ScopedContext represents an isolated execution context for nested compositions
func NewScopedContext ¶
func NewScopedContext(parent *ScopedContext, stateCtx *StateContext, scopeID string) *ScopedContext
NewScopedContext creates a new scoped context
func (*ScopedContext) GetCELVariables ¶
func (sc *ScopedContext) GetCELVariables(currentOutputs map[string]interface{}) map[string]interface{}
GetCELVariables prepares variables for CEL evaluation with proper scoping
func (*ScopedContext) GetStepOutput ¶
func (sc *ScopedContext) GetStepOutput(stepID string) (interface{}, bool)
GetStepOutput retrieves a step output from the current scope only
func (*ScopedContext) GetTemplateData ¶
func (sc *ScopedContext) GetTemplateData() map[string]interface{}
GetTemplateData prepares template data with proper scoping
func (*ScopedContext) MergeOutputs ¶
func (sc *ScopedContext) MergeOutputs() map[string]interface{}
MergeOutputs merges the outputs from a nested scope back to parent This is used when a nested composition completes
func (*ScopedContext) SetStepOutput ¶
func (sc *ScopedContext) SetStepOutput(stepID string, output interface{})
SetStepOutput sets a step output in the current scope
type StateContext ¶
type StateContext struct {
CurrentState string `json:"current_state"`
Inputs map[string]interface{} `json:"inputs"`
StateOutputs map[string]map[string]interface{} `json:"state_outputs"`
Attempts map[string]int `json:"attempts"`
StateInfo map[string]*StateInfo `json:"state_info"`
RecipeContext *RecipeContext `json:"recipe_context,omitempty"`
StepOutputs map[string]interface{} `json:"step_outputs"` // Track step outputs within current state
}
StateContext maintains the runtime context for state machine execution
type StateInfo ¶
type StateInfo struct {
Name string `json:"name"`
Attempts int `json:"attempts"`
EnteredAt time.Time `json:"entered_at"`
}
StateInfo tracks metadata for each state
type StateObserver ¶
type StepResult ¶
type StepResult struct {
Outputs map[string]interface{}
}
StepResult stores the result of a workflow step
type TransitionSelectionObserver ¶ added in v0.0.11
type ValidationMode ¶
type ValidationMode string
const ( ValidateAll ValidationMode = "all" ValidatePathOnly ValidationMode = "path_only" )
type ValidationOptions ¶
type ValidationOptions struct {
Mode ValidationMode
CollectAll bool
}
type WithinRecipeResolutionResult ¶
type WithinRecipeResolutionResult struct {
ResolvedSelectors map[string]string `json:"resolved_selectors,omitempty"`
ResolvedGitRefs map[string]string `json:"resolved_git_refs,omitempty"`
}
func ParseWithinRecipeResolutionJSON ¶
func ParseWithinRecipeResolutionJSON(raw []byte) (*WithinRecipeResolutionResult, error)
func ParseWithinRecipeResolutionTaskData ¶
func ParseWithinRecipeResolutionTaskData(td jobdb.TaskData) (*WithinRecipeResolutionResult, error)
type WorkspaceResolutionInput ¶ added in v0.0.54
type WorkspaceResolutionInput struct {
Permissions *permissions.State `json:"permissions,omitempty"`
GitProfile gitprofile.Selection `json:"git_profile,omitzero"`
Cell string `json:"cell"`
Initial string `json:"initial,omitempty"`
Ref string `json:"ref,omitempty"`
ScopeID string `json:"scope_id"`
ParentScopeID string `json:"parent_scope_id,omitempty"`
Resolution cellref.Context `json:"resolution"`
}
type WorkspaceResolutionOutput ¶ added in v0.0.54
type WorkspaceResolutionOutput struct {
Workspace contextual.WorkspaceContext `json:"workspace"`
Git contextual.GitBaseContext `json:"git"`
}
Source Files
¶
- artifact_bindings.go
- artifact_job_context.go
- artifact_keys.go
- artifact_map.go
- catch_validation.go
- child_group.go
- compiler.go
- composite_inputs.go
- consumer_versions.go
- execution_options.go
- execution_requirements.go
- execution_scope.go
- extension_functions.go
- extension_helpers.go
- failure.go
- inline_resolution.go
- job_worker.go
- normalize_op_input.go
- op_input_validation.go
- ops_test_init.go
- recipe_inputs.go
- recipe_retriever.go
- replay_log.go
- root_source.go
- scope.go
- selector_helpers.go
- shared_test_tools.go
- statemachine_compiler.go
- statemachine_context.go
- task_output.go
- validation_context.go
- validation_helpers.go
- validation_placeholders.go
- within_recipe_resolution.go
- workspace.go