Documentation
¶
Index ¶
- Constants
- func ExpandEnvContext(ctx context.Context, s string) string
- func HasValueReference(raw string) bool
- func IsExactRef(token string) bool
- func IsStepOutputReferenceToken(token string) bool
- func ReportStepOutputReferenceNotice(sink ValueReferenceNoticeSink, field, token string, ...)
- func ReportUnresolvedEnvExpansionNotices(input, field string, scope *EnvScope, sink ValueReferenceNoticeSink)
- func ValidEnvName(name string) bool
- func WithCommandSubstitutionShell(ctx context.Context, shell []string) context.Context
- func WithCommandSubstitutionWorkingDir(ctx context.Context, dir string) context.Context
- func WithEnvScope(ctx context.Context, scope *EnvScope) context.Context
- type BuiltinContext
- type CommandContext
- type CommandTarget
- type EnvEntry
- type EnvScope
- func (e *EnvScope) AllBySource(source EnvSource) map[string]string
- func (e *EnvScope) AllSecrets() map[string]string
- func (e *EnvScope) AllUserEnvs() map[string]string
- func (e *EnvScope) Debug() string
- func (e *EnvScope) Expand(s string) string
- func (e *EnvScope) Get(key string) (string, bool)
- func (e *EnvScope) GetEntry(key string) (EnvEntry, bool)
- func (e *EnvScope) Provenance(key string) string
- func (e *EnvScope) ToMap() map[string]string
- func (e *EnvScope) ToSlice() []string
- func (e *EnvScope) WithEntries(entries map[string]string, source EnvSource) *EnvScope
- func (e *EnvScope) WithEntry(key, value string, source EnvSource) *EnvScope
- func (e *EnvScope) WithEntryOrigin(key, value string, source EnvSource, origin string) *EnvScope
- func (e *EnvScope) WithStepOutputs(outputs map[string]string, stepID string) *EnvScope
- type EnvSource
- type Field
- func AgentWorkingDirField(path string) Field
- func CommandScriptField(path string, command CommandContext) Field
- func ConditionCommandField(path string, command CommandContext) Field
- func ConditionEvalField(path string) Field
- func ConditionRuntimeValueField(path string) Field
- func ConditionValueField(path string) Field
- func ConstLoadField(path string) Field
- func ContainerEnvField(path string) Field
- func ContainerField(path string) Field
- func CoordinatorArtifactBaseDirField(path string) Field
- func DAGEnvField(path string) Field
- func DAGShellField(path string) Field
- func DAGWorkingDirField(path string) Field
- func DirectCommandField(path string, command CommandContext) Field
- func DotenvPathField(path string) Field
- func DynamicParamEvalField(path string) Field
- func ExecutorConfigField(path string) Field
- func HostConfigObjectField(path string) Field
- func LogPathField(path string) Field
- func ParallelItemField(path string) Field
- func ParallelItemParamField(path string) Field
- func ParallelSubDAGField(path string) Field
- func RepeatIntegerField(path string) Field
- func RetryIntegerField(path string) Field
- func RuntimeDAGEnvField(path string) Field
- func ServerBasePathField(path string) Field
- func ShellCommandField(path string, command CommandContext) Field
- func StaticValidationField(path string) Field
- func StepArtifactOutputField(path string) Field
- func StepDirField(path string) Field
- func StepEnvField(path string) Field
- func StepShellField(path string) Field
- func StructuredOutputLiteralField(path string) Field
- func StructuredOutputPathField(path string) Field
- func SubDAGNameField(path string) Field
- func SubDAGParamsField(path string) Field
- func TemplateConfigField(path string) Field
- func TemplateScriptField(path string) Field
- func WorkflowField(path string) Field
- func WorkflowObjectField(path string) Field
- type Resolver
- func (r Resolver) Int(ctx context.Context, raw string, field Field) (int, error)
- func (r Resolver) Object(ctx context.Context, obj any, field Field) (any, error)
- func (r Resolver) ResolveRef(ctx context.Context, token string, field Field) (string, error)
- func (r Resolver) String(ctx context.Context, raw string, field Field) (string, error)
- type ResolverOption
- type RuntimeScope
- type StaticScope
- type StepInfo
- type StepOutputReference
- type ValueReferenceNotice
- type ValueReferenceNoticeClass
- type ValueReferenceNoticeCollector
- type ValueReferenceNoticeReason
- type ValueReferenceNoticeSink
- type Values
Constants ¶
const EnvSourceStep = EnvSourceOutput
EnvSourceStep is deprecated: use EnvSourceOutput instead
Variables ¶
This section is empty.
Functions ¶
func ExpandEnvContext ¶
ExpandEnvContext expands ${VAR} and $VAR in s using EnvScope from context, falling back to os.LookupEnv if no scope in context. Variables not found are preserved in their original form.
func HasValueReference ¶
HasValueReference reports whether raw contains a supported value-reference form.
func IsExactRef ¶
IsExactRef reports whether token is an exact canonical scoped reference.
func IsStepOutputReferenceToken ¶
IsStepOutputReferenceToken reports whether token is an exact Spec 007 reference.
func ReportStepOutputReferenceNotice ¶
func ReportStepOutputReferenceNotice(sink ValueReferenceNoticeSink, field, token string, reason ValueReferenceNoticeReason)
ReportStepOutputReferenceNotice reports a passive Spec 007 step-output notice.
func ReportUnresolvedEnvExpansionNotices ¶
func ReportUnresolvedEnvExpansionNotices(input, field string, scope *EnvScope, sink ValueReferenceNoticeSink)
ReportUnresolvedEnvExpansionNotices reports missing simple shell-style env references in input.
func ValidEnvName ¶
ValidEnvName reports whether name is a valid environment variable name.
func WithCommandSubstitutionShell ¶
WithCommandSubstitutionShell sets the shell used by command substitutions.
func WithCommandSubstitutionWorkingDir ¶
WithCommandSubstitutionWorkingDir sets the working directory used by command substitutions.
Types ¶
type BuiltinContext ¶
type BuiltinContext struct {
// contains filtered or unexported fields
}
BuiltinContext contains scalar Dagu-managed context values for strict value references such as ${context.run.id} and compatibility aliases such as ${run.id}.
func NewBuiltinContext ¶
func NewBuiltinContext(values map[string]string) BuiltinContext
NewBuiltinContext returns a built-in context with the provided scalar values.
type CommandContext ¶
type CommandContext struct {
Target CommandTarget
Shell []string
ShellConfigured bool
}
CommandContext contains command execution facts used by semantic policies.
type CommandTarget ¶
type CommandTarget int
CommandTarget identifies where a command is executed.
const ( CommandTargetLocal CommandTarget = iota CommandTargetSSH CommandTargetDocker )
type EnvEntry ¶
type EnvEntry struct {
Key string
Value string
Source EnvSource
Origin string // stepID for outputs, filepath for dotenv (optional metadata)
}
EnvEntry represents a single environment variable with metadata
type EnvScope ¶
type EnvScope struct {
// contains filtered or unexported fields
}
EnvScope is an isolated, immutable environment scope for DAG loading/execution. It does NOT modify the global os.Env.
func GetEnvScope ¶
GetEnvScope retrieves the EnvScope from context. Returns nil if context is nil or no EnvScope is set.
func NewEnvScope ¶
NewEnvScope creates a new EnvScope, optionally inheriting from parent. If includeOS is true, it includes os.Environ() as the base layer.
func (*EnvScope) AllBySource ¶
AllBySource returns all entries with the given source. This is useful for getting all secrets for masking, all params, etc.
func (*EnvScope) AllSecrets ¶
AllSecrets returns all entries with EnvSourceSecret. This is a convenience method for output masking.
func (*EnvScope) AllUserEnvs ¶
AllUserEnvs returns all entries excluding OS environment.
func (*EnvScope) Expand ¶
Expand expands ${VAR} and $VAR in s using this scope. Variables not found in the scope are preserved in their original form.
func (*EnvScope) GetEntry ¶
GetEntry retrieves the full entry with metadata, checking this scope then parent scopes.
func (*EnvScope) Provenance ¶
Provenance returns a human-readable description of where a variable came from. Returns empty string if the variable is not found.
func (*EnvScope) ToMap ¶
ToMap returns all variables as a map, with child entries overriding parent entries.
func (*EnvScope) WithEntries ¶
WithEntries returns a new EnvScope with the given entries added. The original scope is not modified (immutable).
func (*EnvScope) WithEntry ¶
WithEntry returns a new EnvScope with the given entry added. The original scope is not modified (immutable).
func (*EnvScope) WithEntryOrigin ¶
WithEntryOrigin returns a new EnvScope with the given entry and origin metadata. The original scope is not modified (immutable).
type EnvSource ¶
type EnvSource string
EnvSource tracks where an environment variable came from (for debugging)
const ( EnvSourceOS EnvSource = "os" // From os.Environ() EnvSourceDAGEnv EnvSource = "dag_env" // From DAG env: field EnvSourceDotEnv EnvSource = "dotenv" // From .env file EnvSourceParam EnvSource = "param" // From params EnvSourceOutput EnvSource = "output" // From step output EnvSourcePresolved EnvSource = "presolved_build" // From presolved build env transport EnvSourceSecret EnvSource = "secret" // From secrets EnvSourceStepEnv EnvSource = "step_env" // From step.env field )
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field identifies the workflow value being resolved.
func AgentWorkingDirField ¶
AgentWorkingDirField returns the policy for agent working directory values.
func CommandScriptField ¶
func CommandScriptField(path string, command CommandContext) Field
CommandScriptField returns the policy for command executor scripts.
func ConditionCommandField ¶
func ConditionCommandField(path string, command CommandContext) Field
ConditionCommandField returns the policy for command condition values.
func ConditionEvalField ¶
ConditionEvalField returns the runtime policy for dynamic precondition values.
func ConditionRuntimeValueField ¶
ConditionRuntimeValueField returns the runtime policy for value-match condition text.
func ConditionValueField ¶
ConditionValueField returns the policy for non-command condition values.
func ConstLoadField ¶
ConstLoadField returns the policy for loading const declarations.
func ContainerEnvField ¶
ContainerEnvField returns the policy for container env entries.
func ContainerField ¶
ContainerField returns the policy for container scalar values.
func CoordinatorArtifactBaseDirField ¶
CoordinatorArtifactBaseDirField returns the policy for coordinator artifact roots.
func DAGEnvField ¶
DAGEnvField returns the policy for build-time DAG env entries.
func DAGShellField ¶
DAGShellField returns the policy for DAG shell values.
func DAGWorkingDirField ¶
DAGWorkingDirField returns the policy for DAG working directory values.
func DirectCommandField ¶
func DirectCommandField(path string, command CommandContext) Field
DirectCommandField returns the policy for command args executed directly.
func DotenvPathField ¶
DotenvPathField returns the policy for dotenv path values.
func DynamicParamEvalField ¶
DynamicParamEvalField returns the policy for dynamic param eval values.
func ExecutorConfigField ¶
ExecutorConfigField returns the policy for executor configuration objects.
func HostConfigObjectField ¶
HostConfigObjectField returns the policy for host-side configuration objects.
func LogPathField ¶
LogPathField returns the policy for log path values.
func ParallelItemField ¶
ParallelItemField returns the policy for parallel item lists.
func ParallelItemParamField ¶
ParallelItemParamField returns the policy for parallel item params.
func ParallelSubDAGField ¶
ParallelSubDAGField returns the policy for parallel sub-DAG child values.
func RepeatIntegerField ¶
RepeatIntegerField returns the policy for repeat integer values.
func RetryIntegerField ¶
RetryIntegerField returns the policy for retry integer values.
func RuntimeDAGEnvField ¶
RuntimeDAGEnvField returns the policy for runtime DAG env entries.
func ServerBasePathField ¶
ServerBasePathField returns the policy for frontend server base paths.
func ShellCommandField ¶
func ShellCommandField(path string, command CommandContext) Field
ShellCommandField returns the policy for command strings executed through a shell.
func StaticValidationField ¶
StaticValidationField returns the policy for static DAG validation.
func StepArtifactOutputField ¶
StepArtifactOutputField returns the policy for stdout/stderr artifact paths.
func StepDirField ¶
StepDirField returns the policy for step working directory values.
func StepEnvField ¶
StepEnvField returns the policy for step env entries.
func StepShellField ¶
StepShellField returns the policy for step shell values.
func StructuredOutputLiteralField ¶
StructuredOutputLiteralField returns the policy for structured literal output values.
func StructuredOutputPathField ¶
StructuredOutputPathField returns the policy for structured output source paths.
func SubDAGNameField ¶
SubDAGNameField returns the policy for sub-DAG names.
func SubDAGParamsField ¶
SubDAGParamsField returns the policy for sub-DAG params.
func TemplateConfigField ¶
TemplateConfigField returns the policy for template executor configuration.
func TemplateScriptField ¶
TemplateScriptField returns the policy for template executor scripts.
func WorkflowField ¶
WorkflowField returns the policy for ordinary workflow scalar values.
func WorkflowObjectField ¶
WorkflowObjectField returns the policy for ordinary workflow object values.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves workflow values for semantic fields.
func NewResolver ¶
func NewResolver(static StaticScope, runtime RuntimeScope, opts ...ResolverOption) Resolver
NewResolver creates a resolver for the provided static and runtime scopes.
func (Resolver) ResolveRef ¶
ResolveRef resolves an exact scoped reference to a non-empty string.
type ResolverOption ¶
type ResolverOption func(*Resolver)
ResolverOption configures a Resolver.
func WithValueReferenceNotices ¶
func WithValueReferenceNotices(sink ValueReferenceNoticeSink) ResolverOption
WithValueReferenceNotices reports unresolved value references to sink.
func WithoutCommandSubstitution ¶
func WithoutCommandSubstitution() ResolverOption
WithoutCommandSubstitution prevents resolver policies from executing command substitutions.
type RuntimeScope ¶
type RuntimeScope struct {
Consts Values
Params Values
ParamsJSON string
Env *EnvScope
Steps map[string]StepInfo
Foreach Values
BuiltinContext BuiltinContext
}
RuntimeScope contains actual values available during runtime resolution.
type StaticScope ¶
StaticScope contains declarations and contracts used by static validation.
type StepInfo ¶
type StepInfo struct {
Stdout string
Stderr string
ExitCode string
Output *string // nil = no output: configured; non-nil = captured value (may be "")
Outputs *string // nil = no outputs published; non-nil = compact JSON object
DeclaredOutputs *string // nil = no declared file-based outputs published; non-nil = compact JSON object
}
StepInfo contains metadata about a step that can be accessed via property syntax.
type StepOutputReference ¶
StepOutputReference describes a step output reference in eval syntax.
func ParseStepOutputReferenceToken ¶
func ParseStepOutputReferenceToken(token string) (StepOutputReference, bool)
ParseStepOutputReferenceToken parses an exact Spec 007 reference token.
func StepOutputReferences ¶
func StepOutputReferences(raw string) []StepOutputReference
StepOutputReferences returns braced step output references found in raw.
type ValueReferenceNotice ¶
type ValueReferenceNotice struct {
Message string
FieldPath string
Token string
Reason ValueReferenceNoticeReason
Class ValueReferenceNoticeClass
}
ValueReferenceNotice describes a supported value reference left unresolved.
type ValueReferenceNoticeClass ¶
type ValueReferenceNoticeClass string
ValueReferenceNoticeClass separates references that no run can resolve from references whose value simply does not exist yet.
const ( // NoticeClassDefect marks a reference the spec cannot resolve in its // declared scope, so no run can resolve it. NoticeClassDefect ValueReferenceNoticeClass = "defect" // NoticeClassRuntimeOnly marks a well-formed reference whose availability // depends on runtime values or lifecycle scope. NoticeClassRuntimeOnly ValueReferenceNoticeClass = "runtime_only" )
type ValueReferenceNoticeCollector ¶
type ValueReferenceNoticeCollector struct {
// contains filtered or unexported fields
}
ValueReferenceNoticeCollector stores unique notices in insertion order.
func (*ValueReferenceNoticeCollector) Notices ¶
func (c *ValueReferenceNoticeCollector) Notices() []ValueReferenceNotice
Notices returns recorded notices in insertion order.
func (*ValueReferenceNoticeCollector) Report ¶
func (c *ValueReferenceNoticeCollector) Report(notice ValueReferenceNotice)
Report records notice unless the same field has already reported the same token.
type ValueReferenceNoticeReason ¶
type ValueReferenceNoticeReason string
ValueReferenceNoticeReason explains why a supported reference was preserved.
const ( ValueReferenceReasonUnknownStepID ValueReferenceNoticeReason = "unknown_step_id" ValueReferenceReasonUnknownOutputName ValueReferenceNoticeReason = "unknown_output_name" ValueReferenceReasonMissingDependency ValueReferenceNoticeReason = "missing_dependency" ValueReferenceReasonSelfReference ValueReferenceNoticeReason = "self_reference" ValueReferenceReasonUnknownContextField ValueReferenceNoticeReason = "unknown_context_field" ValueReferenceReasonUnknownEnvBinding ValueReferenceNoticeReason = "unknown_env_binding" ValueReferenceReasonUnknownConstName ValueReferenceNoticeReason = "unknown_const_name" )
func (ValueReferenceNoticeReason) Class ¶
func (r ValueReferenceNoticeReason) Class() ValueReferenceNoticeClass
Class reports whether the reason describes a defect or a runtime-only value.
Reasons that name a missing step, output, or context field are defects. Reasons that only report an absent value are runtime-only, because a scope built for inspection carries far less than a scope built for a run.
type ValueReferenceNoticeSink ¶
type ValueReferenceNoticeSink interface {
Report(ValueReferenceNotice)
}
ValueReferenceNoticeSink receives passive value-reference notices.
func SuppressStepOutputReferenceNotices ¶
func SuppressStepOutputReferenceNotices(sink ValueReferenceNoticeSink) ValueReferenceNoticeSink
SuppressStepOutputReferenceNotices drops generic notices for exact Spec 007 tokens.