Documentation
¶
Overview ¶
Package resolver provides type coercion utilities.
Type coercion functions have been moved to pkg/spec/types.go. This file is kept for backward compatibility - CoerceType is re-exported in resolver.go from the spec package.
Package resolver provides types for defining and executing data resolvers.
This file re-exports types from pkg/spec for backward compatibility. New code should import from pkg/spec directly when possible.
Index ¶
- Constants
- Variables
- func FormatDiffHuman(diff *SnapshotDiff) string
- func FormatDiffJSON(diff *SnapshotDiff) (string, error)
- func FormatDiffUnified(diff *SnapshotDiff) string
- func FormatMetricsSummary(summary *MetricsSummary) string
- func GetMaxPhase(phases []*PhaseGroup) int
- func GetPhaseForResolver(phases []*PhaseGroup, resolverName string) int
- func IsAggregatedExecutionError(err error) bool
- func IsCircularDependencyError(err error) bool
- func IsExecutionError(err error) bool
- func IsForEachTypeError(err error) bool
- func IsTypeCoercionError(err error) bool
- func IsValidationError(err error) bool
- func IsValueSizeError(err error) bool
- func RecordResolverExecution(resolverName string, result *ExecutionResult)
- func RedactError(err error, sensitive bool) error
- func RedactMapValues(m map[string]any, sensitive bool) map[string]any
- func RedactSensitiveValues(snapshot *Snapshot, resolvers []ResolverLike)
- func RedactValue(value any, sensitive bool) any
- func RegisterResolverMetrics()
- func SaveSnapshot(snapshot *Snapshot, filePath string) error
- func WithContext(ctx context.Context, rc *Context) context.Context
- type AggregatedExecutionError
- func (e *AggregatedExecutionError) Add(resolverName string, phase int, err error)
- func (e *AggregatedExecutionError) AddSkipped(resolverName string)
- func (e *AggregatedExecutionError) Error() string
- func (e *AggregatedExecutionError) HasErrors() bool
- func (e *AggregatedExecutionError) IncrementSucceeded()
- type AggregatedValidationError
- type AttemptDetail
- type CircularDependencyError
- type Condition
- type Config
- type ConfigInput
- type Context
- func (c *Context) Get(name string) (any, bool)
- func (c *Context) GetAllResults() map[string]*ExecutionResult
- func (c *Context) GetResult(name string) (*ExecutionResult, bool)
- func (c *Context) Has(name string) bool
- func (c *Context) Set(name string, value any)
- func (c *Context) SetResult(name string, result *ExecutionResult)
- func (c *Context) ToMap() map[string]any
- type DescriptorLookup
- type DiffOptions
- type DiffSummary
- type DiffType
- type ErrorBehavior
- type ExecutionError
- type ExecutionResult
- type ExecutionStatus
- type Executor
- type ExecutorOption
- func OptionsFromAppConfig(cfg ConfigInput) []ExecutorOption
- func WithDefaultTimeout(timeout time.Duration) ExecutorOption
- func WithMaxConcurrency(maxConcurrency int) ExecutorOption
- func WithMaxValueSize(bytes int64) ExecutorOption
- func WithPhaseTimeout(timeout time.Duration) ExecutorOption
- func WithProgressCallback(callback ProgressCallback) ExecutorOption
- func WithSkipValidation(enabled bool) ExecutorOption
- func WithValidateAll(enabled bool) ExecutorOption
- func WithWarnValueSize(bytes int64) ExecutorOption
- type FailedAttemptSummary
- type FailedResolver
- type FailureSummary
- type FieldChange
- type ForEachClause
- type ForEachIterationResult
- type ForEachTypeError
- type Graph
- type GraphDependency
- type GraphEdge
- type GraphNode
- type GraphStats
- type IterationContext
- type MetricsSummary
- type PhaseGroup
- type PhaseInfo
- type PhaseMetrics
- type PhaseTimeoutError
- type ProgressCallback
- type ProviderAttempt
- type ProviderSource
- type ProviderTransform
- type ProviderValidation
- type RedactedError
- type RegistryInterface
- type ResolvePhase
- type Resolver
- type ResolverDiff
- type ResolverLike
- type ResolverMetric
- type Snapshot
- type SnapshotDiff
- type SnapshotFailedAttempt
- type SnapshotMetadata
- type SnapshotPhase
- type SnapshotResolver
- type TransformPhase
- type Type
- type TypeCoercionError
- type ValidatePhase
- type ValidationFailure
- type ValueRef
- type ValueSizeError
Constants ¶
const ( TypeString = spec.TypeString TypeInt = spec.TypeInt TypeFloat = spec.TypeFloat TypeBool = spec.TypeBool TypeArray = spec.TypeArray TypeTime = spec.TypeTime TypeDuration = spec.TypeDuration TypeAny = spec.TypeAny )
Type constants re-exported from spec for backward compatibility.
const ( ErrorBehaviorFail = spec.OnErrorFail ErrorBehaviorContinue = spec.OnErrorContinue )
ErrorBehavior constants re-exported from spec for backward compatibility.
Variables ¶
var ( // ResolverExecutionDuration tracks the duration of resolver executions ResolverExecutionDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: fmt.Sprintf("%s_resolver_execution_duration_seconds", settings.CliBinaryName), Help: "Histogram of resolver execution duration in seconds", Buckets: []float64{.01, .05, .1, .25, .5, 1, 2.5, 5, 10, 30}, }, []string{resolverNameLabel, statusLabel}) // ResolverPhaseDuration tracks the duration of individual resolver phases ResolverPhaseDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: fmt.Sprintf("%s_resolver_phase_duration_seconds", settings.CliBinaryName), Help: "Histogram of resolver phase duration in seconds", Buckets: []float64{.01, .05, .1, .25, .5, 1, 2.5, 5, 10, 30}, }, []string{resolverNameLabel, phaseLabel}) // ResolverExecutionsTotal tracks the total number of resolver executions ResolverExecutionsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: fmt.Sprintf("%s_resolver_executions_total", settings.CliBinaryName), Help: "Total number of resolver executions", }, []string{resolverNameLabel, statusLabel}) // ResolverProviderCallsTotal tracks the total number of provider calls made by resolvers ResolverProviderCallsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: fmt.Sprintf("%s_resolver_provider_calls_total", settings.CliBinaryName), Help: "Total number of provider calls made by resolvers", }, []string{resolverNameLabel, providerLabel, phaseLabel}) // ResolverValueSize tracks the size of resolver values in bytes ResolverValueSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: fmt.Sprintf("%s_resolver_value_size_bytes", settings.CliBinaryName), Help: "Histogram of resolver value sizes in bytes", Buckets: []float64{100, 1000, 10000, 100000, 1000000, 10000000}, }, []string{resolverNameLabel}) // ResolverDependencyCount tracks the number of dependencies per resolver ResolverDependencyCount = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: fmt.Sprintf("%s_resolver_dependency_count", settings.CliBinaryName), Help: "Histogram of resolver dependency counts", Buckets: []float64{0, 1, 2, 5, 10, 20, 50}, }, []string{resolverNameLabel}) // ResolverFailedAttemptsTotal tracks the total number of failed provider attempts ResolverFailedAttemptsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: fmt.Sprintf("%s_resolver_failed_attempts_total", settings.CliBinaryName), Help: "Total number of failed provider attempts before success or final failure", }, []string{resolverNameLabel, providerLabel, phaseLabel}) // ResolverPhaseExecutionsTotal tracks the total number of phase executions ResolverPhaseExecutionsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: fmt.Sprintf("%s_resolver_phase_executions_total", settings.CliBinaryName), Help: "Total number of resolver phase executions", }, []string{phaseLabel}) // ResolverConcurrentExecutions tracks the current number of concurrent resolver executions ResolverConcurrentExecutions = prometheus.NewGauge(prometheus.GaugeOpts{ Name: fmt.Sprintf("%s_resolver_concurrent_executions", settings.CliBinaryName), Help: "Current number of concurrent resolver executions", }) )
var CoerceType = spec.CoerceType
CoerceType is re-exported from spec for backward compatibility.
Functions ¶
func FormatDiffHuman ¶
func FormatDiffHuman(diff *SnapshotDiff) string
FormatDiffHuman formats the diff in human-readable format
func FormatDiffJSON ¶
func FormatDiffJSON(diff *SnapshotDiff) (string, error)
FormatDiffJSON formats the diff as JSON
func FormatDiffUnified ¶
func FormatDiffUnified(diff *SnapshotDiff) string
FormatDiffUnified formats the diff in unified diff format (similar to git diff)
func FormatMetricsSummary ¶
func FormatMetricsSummary(summary *MetricsSummary) string
FormatMetricsSummary formats the metrics summary for human-readable display
func GetMaxPhase ¶
func GetMaxPhase(phases []*PhaseGroup) int
GetMaxPhase returns the maximum phase number in the phase groups
func GetPhaseForResolver ¶
func GetPhaseForResolver(phases []*PhaseGroup, resolverName string) int
GetPhaseForResolver returns the phase number for a given resolver name
func IsAggregatedExecutionError ¶
IsAggregatedExecutionError checks if an error is an AggregatedExecutionError.
func IsCircularDependencyError ¶
IsCircularDependencyError checks if an error is a CircularDependencyError.
func IsExecutionError ¶
IsExecutionError checks if an error is an ExecutionError.
func IsForEachTypeError ¶
IsForEachTypeError checks if an error is a ForEachTypeError.
func IsTypeCoercionError ¶
IsTypeCoercionError checks if an error is a TypeCoercionError.
func IsValidationError ¶
IsValidationError checks if an error is an AggregatedValidationError.
func IsValueSizeError ¶
IsValueSizeError checks if an error is a ValueSizeError.
func RecordResolverExecution ¶
func RecordResolverExecution(resolverName string, result *ExecutionResult)
RecordResolverExecution records metrics for a completed resolver execution
func RedactError ¶
RedactError wraps an error with redaction if sensitive is true. The original error is preserved and can be accessed via errors.Unwrap.
func RedactMapValues ¶
RedactMapValues redacts all values in a map if sensitive is true. Keys are preserved, only values are replaced with [REDACTED].
func RedactSensitiveValues ¶
func RedactSensitiveValues(snapshot *Snapshot, resolvers []ResolverLike)
RedactSensitiveValues redacts sensitive values in the snapshot based on resolver-like objects
func RedactValue ¶
RedactValue returns [REDACTED] for any value if sensitive is true, otherwise returns the value unchanged. This is safe for use in logs, error messages, and JSON output.
func RegisterResolverMetrics ¶
func RegisterResolverMetrics()
RegisterResolverMetrics registers all resolver-related Prometheus metrics
func SaveSnapshot ¶
SaveSnapshot saves a snapshot to a JSON file
Types ¶
type AggregatedExecutionError ¶
type AggregatedExecutionError struct {
Errors []*FailedResolver `json:"errors" yaml:"errors" doc:"All errors encountered during execution" minItems:"1"`
SkippedCount int `json:"skippedCount" yaml:"skippedCount" doc:"Number of resolvers skipped due to failed dependencies" minimum:"0" example:"3"`
SkippedNames []string `json:"skippedNames" yaml:"skippedNames" doc:"Names of skipped resolvers"`
SucceededCount int `json:"succeededCount" yaml:"succeededCount" doc:"Number of resolvers that succeeded" minimum:"0" example:"5"`
}
AggregatedExecutionError represents multiple resolver errors collected during validate-all mode. This is used when the executor is configured to continue execution after failures.
func (*AggregatedExecutionError) Add ¶
func (e *AggregatedExecutionError) Add(resolverName string, phase int, err error)
Add adds a resolver error to the aggregated error.
func (*AggregatedExecutionError) AddSkipped ¶
func (e *AggregatedExecutionError) AddSkipped(resolverName string)
AddSkipped records that a resolver was skipped due to failed dependencies.
func (*AggregatedExecutionError) Error ¶
func (e *AggregatedExecutionError) Error() string
Error implements the error interface.
func (*AggregatedExecutionError) HasErrors ¶
func (e *AggregatedExecutionError) HasErrors() bool
HasErrors returns true if there are any errors.
func (*AggregatedExecutionError) IncrementSucceeded ¶
func (e *AggregatedExecutionError) IncrementSucceeded()
IncrementSucceeded increments the count of succeeded resolvers.
type AggregatedValidationError ¶
type AggregatedValidationError struct {
ResolverName string `json:"resolverName" yaml:"resolverName" doc:"Name of the resolver that failed validation" example:"user-email"`
Value any `json:"-" yaml:"-" doc:"The value that failed validation"`
Failures []ValidationFailure `json:"failures" yaml:"failures" doc:"List of validation failures" minItems:"1"`
Sensitive bool `json:"sensitive,omitempty" yaml:"sensitive,omitempty" doc:"Whether the resolver value is sensitive"`
}
AggregatedValidationError represents validation failure with multiple messages. This collects all validation failures from a resolver's validate phase.
func (*AggregatedValidationError) AddFailure ¶
func (e *AggregatedValidationError) AddFailure(failure ValidationFailure)
AddFailure adds a validation failure to the error.
func (*AggregatedValidationError) Error ¶
func (e *AggregatedValidationError) Error() string
Error implements the error interface.
func (*AggregatedValidationError) HasFailures ¶
func (e *AggregatedValidationError) HasFailures() bool
HasFailures returns true if there are any validation failures.
func (*AggregatedValidationError) Unwrap ¶
func (e *AggregatedValidationError) Unwrap() error
Unwrap returns nil since this error aggregates multiple failures. Use errors.As with *ValidationFailure to check individual failures.
type AttemptDetail ¶
type AttemptDetail struct {
Provider string `json:"provider" doc:"Provider name"`
Error string `json:"error" doc:"Error message"`
}
AttemptDetail contains details of a failed attempt
type CircularDependencyError ¶
type CircularDependencyError struct {
Cycle []string `` /* 144-byte string literal not displayed */
}
CircularDependencyError represents a cycle detected in resolver dependencies.
func NewCircularDependencyError ¶
func NewCircularDependencyError(cycle []string) *CircularDependencyError
NewCircularDependencyError creates a new CircularDependencyError from a cycle path.
func (*CircularDependencyError) Error ¶
func (e *CircularDependencyError) Error() string
Error implements the error interface.
type Condition ¶
type Condition struct {
Expr *celexp.Expression `json:"expr" yaml:"expr" doc:"CEL expression that must evaluate to boolean" example:"_.environment == 'prod'"`
}
Condition is an alias to spec.Condition for backward compatibility. Note: The resolver package uses a custom Condition that only wraps the expr field, keeping backward compatibility with existing resolver YAML files.
type Config ¶
type Config struct {
MaxValueSizeBytes int64 `` /* 152-byte string literal not displayed */
WarnValueSizeBytes int64 `` /* 153-byte string literal not displayed */
MaxConcurrency int `` /* 164-byte string literal not displayed */
PhaseTimeout time.Duration `` /* 139-byte string literal not displayed */
}
Config contains global resolver configuration
type ConfigInput ¶
type ConfigInput struct {
// Timeout is the default timeout per resolver execution
Timeout time.Duration
// PhaseTimeout is the maximum time for each resolution phase
PhaseTimeout time.Duration
// MaxConcurrency is the maximum concurrent resolvers per phase (0 = unlimited)
MaxConcurrency int
// WarnValueSize is the warn threshold in bytes (0 = disabled)
WarnValueSize int64
// MaxValueSize is the max value size in bytes (0 = disabled)
MaxValueSize int64
// ValidateAll enables collecting all errors instead of stopping at first
ValidateAll bool
}
ConfigInput holds the configuration values for resolver executor initialization. This mirrors config.ResolverConfig but avoids circular dependencies.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a thread-safe storage for resolver results and execution metadata
func FromContext ¶
FromContext retrieves resolver context from a Go context
func (*Context) GetAllResults ¶
func (c *Context) GetAllResults() map[string]*ExecutionResult
GetAllResults returns all resolver execution results with metadata Used for observability, logging, and metrics
func (*Context) GetResult ¶
func (c *Context) GetResult(name string) (*ExecutionResult, bool)
GetResult retrieves the full resolver execution result including metadata
func (*Context) SetResult ¶
func (c *Context) SetResult(name string, result *ExecutionResult)
SetResult stores a resolver result with full execution metadata
type DescriptorLookup ¶
type DescriptorLookup func(providerName string) *provider.Descriptor
DescriptorLookup is a function that retrieves a provider descriptor by name. Used during dependency extraction to allow providers to participate in extracting dependencies from their inputs.
type DiffOptions ¶
type DiffOptions struct {
IgnoreUnchanged bool `json:"ignoreUnchanged" doc:"Whether to omit unchanged resolvers from output"`
IgnoreFields []string `json:"ignoreFields" doc:"Fields to ignore in comparison (e.g., duration, providerCalls)"`
ResolverFilter string `json:"resolverFilter" doc:"Only compare resolvers matching this pattern"`
}
DiffOptions provides options for diff comparison
type DiffSummary ¶
type DiffSummary struct {
TotalResolvers int `json:"totalResolvers" doc:"Total number of resolvers compared"`
Added int `json:"added" doc:"Number of resolvers added"`
Removed int `json:"removed" doc:"Number of resolvers removed"`
Modified int `json:"modified" doc:"Number of resolvers modified"`
Unchanged int `json:"unchanged" doc:"Number of resolvers unchanged"`
}
DiffSummary provides a summary of all changes
type DiffType ¶
type DiffType string
DiffType represents the type of difference found
const ( DiffTypeAdded DiffType = "added" // Resolver exists in after but not before DiffTypeRemoved DiffType = "removed" // Resolver exists in before but not after DiffTypeModified DiffType = "modified" // Resolver exists in both but values differ DiffTypeUnchanged DiffType = "unchanged" // Resolver exists in both and is identical )
type ErrorBehavior ¶
type ErrorBehavior = spec.OnErrorBehavior
ErrorBehavior is an alias to spec.OnErrorBehavior for backward compatibility. New code should use spec.OnErrorBehavior directly.
type ExecutionError ¶
type ExecutionError struct {
ResolverName string `json:"resolverName" yaml:"resolverName" doc:"Name of the resolver that failed" example:"my-resolver"`
Phase string `json:"phase" yaml:"phase" doc:"Execution phase where failure occurred" enum:"resolve,transform,validate" example:"resolve"`
Step int `json:"step" yaml:"step" doc:"Step number within the phase (0-indexed)" minimum:"0" example:"0"`
Provider string `json:"provider" yaml:"provider" doc:"Provider name that failed" example:"http"`
Cause error `json:"-" yaml:"-" doc:"Underlying error that caused the failure"`
}
ExecutionError represents an error during resolver execution with context about which resolver, phase, step, and provider were involved.
func NewExecutionError ¶
func NewExecutionError(resolverName, phase, provider string, step int, cause error) *ExecutionError
NewExecutionError creates a new ExecutionError with the given parameters.
func (*ExecutionError) Error ¶
func (e *ExecutionError) Error() string
Error implements the error interface.
func (*ExecutionError) Unwrap ¶
func (e *ExecutionError) Unwrap() error
Unwrap returns the underlying cause for use with errors.Is and errors.As.
type ExecutionResult ¶
type ExecutionResult struct {
// Value is the actual resolved value
Value any `json:"value" yaml:"value" doc:"The resolved value"`
// Metadata (internal use only, not accessible in CEL)
Status ExecutionStatus `json:"status" yaml:"status" doc:"Execution status" example:"success"`
Phase int `json:"phase" yaml:"phase" doc:"Execution phase number (1-based)" example:"1"`
TotalDuration time.Duration `json:"totalDuration" yaml:"totalDuration" doc:"Total execution time across all phases" example:"250ms"`
StartTime time.Time `json:"startTime" yaml:"startTime" doc:"When resolver execution started"`
EndTime time.Time `json:"endTime" yaml:"endTime" doc:"When resolver execution ended"`
Error error `json:"error,omitempty" yaml:"error,omitempty" doc:"Error if failed"`
PhaseMetrics []PhaseMetrics `json:"phaseMetrics" yaml:"phaseMetrics" doc:"Per-phase timing" maxItems:"3"`
ProviderCallCount int `json:"providerCallCount" yaml:"providerCallCount" doc:"Number of provider calls made" example:"2"`
ValueSizeBytes int64 `json:"valueSizeBytes" yaml:"valueSizeBytes" doc:"Size of the value in bytes" example:"1024"`
DependencyCount int `json:"dependencyCount" yaml:"dependencyCount" doc:"Number of dependencies" example:"3"`
FailedAttempts []ProviderAttempt `json:"failedAttempts,omitempty" yaml:"failedAttempts,omitempty" doc:"Failed provider attempts (for debugging)" maxItems:"10"`
}
ExecutionResult contains both the value and execution metadata
type ExecutionStatus ¶
type ExecutionStatus string
ExecutionStatus represents the execution status of a resolver
const ( ExecutionStatusSuccess ExecutionStatus = "success" ExecutionStatusFailed ExecutionStatus = "failed" ExecutionStatusSkipped ExecutionStatus = "skipped" )
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes resolvers in phases with concurrency control
func NewExecutor ¶
func NewExecutor(registry RegistryInterface, opts ...ExecutorOption) *Executor
NewExecutor creates a new resolver executor
type ExecutorOption ¶
type ExecutorOption func(*Executor)
ExecutorOption is a functional option for configuring the Executor
func OptionsFromAppConfig ¶
func OptionsFromAppConfig(cfg ConfigInput) []ExecutorOption
NewExecutorFromAppConfig creates a new resolver executor using app configuration. CLI flags can override these defaults using the returned executor options.
Example:
cfg := resolver.ResolverConfigInput{
Timeout: 30 * time.Second,
PhaseTimeout: 5 * time.Minute,
MaxConcurrency: 0,
}
opts := resolver.OptionsFromAppConfig(cfg)
executor := resolver.NewExecutor(registry, opts...)
func WithDefaultTimeout ¶
func WithDefaultTimeout(timeout time.Duration) ExecutorOption
WithDefaultTimeout sets the default timeout for individual resolver execution
func WithMaxConcurrency ¶
func WithMaxConcurrency(maxConcurrency int) ExecutorOption
WithMaxConcurrency sets the maximum number of resolvers that can execute concurrently per phase
func WithMaxValueSize ¶
func WithMaxValueSize(bytes int64) ExecutorOption
WithMaxValueSize sets the maximum allowed value size in bytes Values exceeding this limit will cause resolver execution to fail Set to 0 to disable the limit
func WithPhaseTimeout ¶
func WithPhaseTimeout(timeout time.Duration) ExecutorOption
WithPhaseTimeout sets the maximum time allowed for each phase to complete
func WithProgressCallback ¶
func WithProgressCallback(callback ProgressCallback) ExecutorOption
WithProgressCallback sets a callback for receiving execution progress events. This enables real-time progress reporting during resolver execution.
func WithSkipValidation ¶
func WithSkipValidation(enabled bool) ExecutorOption
WithSkipValidation disables the validation phase for all resolvers. When enabled, resolvers will execute their resolve and transform phases but skip validation entirely.
func WithValidateAll ¶
func WithValidateAll(enabled bool) ExecutorOption
WithValidateAll enables validate-all mode where execution continues even when resolvers fail, collecting all errors instead of stopping at the first error. Resolvers that depend on failed resolvers will be skipped.
func WithWarnValueSize ¶
func WithWarnValueSize(bytes int64) ExecutorOption
WithWarnValueSize sets the size threshold for warning about large values Set to 0 to disable warnings
type FailedAttemptSummary ¶
type FailedAttemptSummary struct {
ResolverName string `json:"resolverName" doc:"Resolver name"`
AttemptCount int `json:"attemptCount" doc:"Number of failed attempts"`
Attempts []AttemptDetail `json:"attempts" doc:"Details of each failed attempt"`
}
FailedAttemptSummary summarizes failed attempts for a resolver
type FailedResolver ¶
type FailedResolver struct {
ResolverName string `json:"resolverName" yaml:"resolverName" doc:"Name of the resolver that failed" example:"my-resolver"`
Phase int `json:"phase" yaml:"phase" doc:"Phase number where the error occurred" minimum:"1" example:"1"`
Err error `json:"-" yaml:"-" doc:"The underlying error"`
ErrMessage string `json:"error" yaml:"error" doc:"Error message" maxLength:"2000" example:"validation failed: value must be positive"`
}
FailedResolver represents an error from a specific resolver with context. Used within AggregatedExecutionError for validate-all mode.
func (*FailedResolver) Error ¶
func (e *FailedResolver) Error() string
Error implements the error interface.
func (*FailedResolver) Unwrap ¶
func (e *FailedResolver) Unwrap() error
Unwrap returns the underlying error for errors.Is/As support.
type FailureSummary ¶
type FailureSummary struct {
Name string `json:"name" doc:"Resolver name"`
Phase int `json:"phase" doc:"Phase where failure occurred"`
Error string `json:"error" doc:"Error message"`
}
FailureSummary contains information about a failed resolver
type FieldChange ¶
type FieldChange struct {
Field string `json:"field" doc:"Field name that changed"`
Before any `json:"before" doc:"Value before change"`
After any `json:"after" doc:"Value after change"`
}
FieldChange represents a change in a specific field
type ForEachClause ¶
type ForEachClause = spec.ForEachClause
ForEachClause is an alias to spec.ForEachClause for backward compatibility.
type ForEachIterationResult ¶
type ForEachIterationResult struct {
Index int `json:"index" yaml:"index" doc:"Index of the iteration" minimum:"0" example:"1"`
Data any `json:"data,omitempty" yaml:"data,omitempty" doc:"Result data if successful"`
Error string `json:"error,omitempty" yaml:"error,omitempty" doc:"Error message if failed" maxLength:"1000"`
Item any `json:"item,omitempty" yaml:"item,omitempty" doc:"The item that was processed"`
}
ForEachIterationResult represents the result of a single forEach iteration. Used when onError: continue allows partial results with error metadata.
type ForEachTypeError ¶
type ForEachTypeError struct {
ResolverName string `json:"resolverName" yaml:"resolverName" doc:"Name of the resolver" example:"regionConfigs"`
Step int `json:"step" yaml:"step" doc:"Transform step number (0-indexed)" minimum:"0" example:"0"`
ActualType string `json:"actualType" yaml:"actualType" doc:"Actual type received" example:"string"`
}
ForEachTypeError represents an error when forEach input is not an array.
func (*ForEachTypeError) Error ¶
func (e *ForEachTypeError) Error() string
Error implements the error interface.
type Graph ¶
type Graph struct {
Nodes []*GraphNode `json:"nodes" yaml:"nodes" doc:"Graph nodes"`
Edges []*GraphEdge `json:"edges" yaml:"edges" doc:"Graph edges"`
Phases []*PhaseInfo `json:"phases" yaml:"phases" doc:"Phase information"`
Stats *GraphStats `json:"stats" yaml:"stats" doc:"Graph statistics"`
}
Graph represents the complete resolver dependency graph
func BuildGraph ¶
func BuildGraph(resolvers []*Resolver, lookup DescriptorLookup) (*Graph, error)
BuildGraph creates a Graph from resolvers. If lookup is provided, provider-specific ExtractDependencies functions will be used when available for more accurate dependency detection.
func (*Graph) RenderASCII ¶
RenderASCII generates ASCII art representation
type GraphDependency ¶
type GraphDependency struct {
Resolver string `json:"resolver" yaml:"resolver" doc:"Target resolver name"`
Field string `json:"field" yaml:"field" doc:"Field name in reference"`
}
GraphDependency represents a dependency edge
type GraphEdge ¶
type GraphEdge struct {
From string `json:"from" yaml:"from" doc:"Source resolver name"`
To string `json:"to" yaml:"to" doc:"Target resolver name"`
Label string `json:"label" yaml:"label" doc:"Edge label"`
}
GraphEdge represents a directed edge
type GraphNode ¶
type GraphNode struct {
Name string `json:"id" yaml:"id" doc:"Resolver name"`
Type Type `json:"type" yaml:"type" doc:"Resolver type"`
Phase int `json:"phase" yaml:"phase" doc:"Execution phase (1-based)"`
Conditional bool `json:"conditional" yaml:"conditional" doc:"Whether resolver has conditional execution"`
Dependencies []GraphDependency `json:"dependencies" yaml:"dependencies" doc:"List of dependencies"`
}
GraphNode represents a resolver node in the dependency graph
type GraphStats ¶
type GraphStats struct {
TotalResolvers int `json:"totalResolvers" yaml:"totalResolvers" doc:"Total number of resolvers"`
TotalPhases int `json:"totalPhases" yaml:"totalPhases" doc:"Total number of execution phases"`
MaxParallelism int `json:"maxParallelism" yaml:"maxParallelism" doc:"Maximum parallelism across all phases"`
AvgDependencies float64 `json:"avgDependencies" yaml:"avgDependencies" doc:"Average number of dependencies per resolver"`
}
GraphStats contains graph statistics
type IterationContext ¶
type IterationContext = spec.IterationContext
IterationContext is an alias to spec.IterationContext for backward compatibility. It holds the context for forEach iteration variables.
type MetricsSummary ¶
type MetricsSummary struct {
TotalResolvers int `json:"totalResolvers" doc:"Total number of resolvers executed"`
SuccessCount int `json:"successCount" doc:"Number of successful resolvers"`
FailedCount int `json:"failedCount" doc:"Number of failed resolvers"`
SkippedCount int `json:"skippedCount" doc:"Number of skipped resolvers"`
TotalDuration time.Duration `json:"totalDuration" doc:"Total execution time"`
PhaseCount int `json:"phaseCount" doc:"Number of execution phases"`
SlowestResolvers []ResolverMetric
LargestValues []ResolverMetric
FailedAttempts []FailedAttemptSummary
Failures []FailureSummary
}
MetricsSummary contains aggregated metrics for display
func BuildMetricsSummary ¶
func BuildMetricsSummary(results map[string]*ExecutionResult, phaseCount int) *MetricsSummary
BuildMetricsSummary creates a metrics summary from execution results
type PhaseGroup ¶
type PhaseGroup struct {
Phase int `json:"phase" yaml:"phase" doc:"Phase number (1-based)" minimum:"1"`
Resolvers []*Resolver `json:"resolvers" yaml:"resolvers" doc:"Resolvers in this phase" minItems:"1"`
}
PhaseGroup represents a group of resolvers that can execute concurrently
func BuildPhases ¶
func BuildPhases(resolvers []*Resolver, lookup DescriptorLookup) ([]*PhaseGroup, error)
BuildPhases groups resolvers into execution phases based on dependencies. Phase numbers are 1-based, with phase 1 being root resolvers (no dependencies). If lookup is provided, provider-specific ExtractDependencies functions will be used when available for more accurate dependency detection.
type PhaseInfo ¶
type PhaseInfo struct {
Phase int `json:"phase" yaml:"phase" doc:"Phase number (1-based)"`
Resolvers []string `json:"resolvers" yaml:"resolvers" doc:"Resolver names in this phase"`
Parallelism int `json:"parallelism" yaml:"parallelism" doc:"Number of resolvers that can execute in parallel"`
}
PhaseInfo contains information about a phase
type PhaseMetrics ¶
type PhaseMetrics struct {
Phase string `json:"phase" yaml:"phase" doc:"Phase name (resolve, transform, validate)" example:"resolve"`
Duration time.Duration `json:"duration" yaml:"duration" doc:"Time spent in this phase" example:"100ms"`
Started time.Time `json:"started" yaml:"started" doc:"When phase started"`
Ended time.Time `json:"ended" yaml:"ended" doc:"When phase ended"`
}
PhaseMetrics contains timing information for a single phase
type PhaseTimeoutError ¶
type PhaseTimeoutError struct {
Phase int `json:"phase" yaml:"phase" doc:"Phase number that timed out" minimum:"1" example:"1"`
ResolversWaiting []string `json:"resolversWaiting" yaml:"resolversWaiting" doc:"Resolvers that were still waiting when timeout occurred"`
}
PhaseTimeoutError represents a timeout during phase execution.
func (*PhaseTimeoutError) Error ¶
func (e *PhaseTimeoutError) Error() string
Error implements the error interface.
type ProgressCallback ¶
type ProgressCallback interface {
// OnPhaseStart is called when a new execution phase begins
OnPhaseStart(phaseNum int, resolverNames []string)
// OnResolverComplete is called when a resolver completes successfully
OnResolverComplete(resolverName string)
// OnResolverFailed is called when a resolver fails
OnResolverFailed(resolverName string, err error)
// OnResolverSkipped is called when a resolver is skipped due to when condition
OnResolverSkipped(resolverName string)
}
ProgressCallback is an interface for receiving execution progress events. Implementations can use this to display progress bars, log events, etc.
type ProviderAttempt ¶
type ProviderAttempt struct {
Provider string `json:"provider" yaml:"provider" doc:"Provider name" example:"http"`
Phase string `json:"phase" yaml:"phase" doc:"Phase where provider was called" example:"resolve"`
Error string `json:"error,omitempty" yaml:"error,omitempty" doc:"Error message if failed" maxLength:"500"`
Duration time.Duration `json:"duration" yaml:"duration" doc:"Time spent in this attempt" example:"50ms"`
OnError string `json:"onError,omitempty" yaml:"onError,omitempty" doc:"Error handling behavior" example:"continue"`
Timestamp time.Time `json:"timestamp" yaml:"timestamp" doc:"When the attempt occurred"`
SourceStep int `json:"sourceStep" yaml:"sourceStep" doc:"Source/step index in phase (0-based)" example:"0"`
}
ProviderAttempt records a single provider execution attempt
type ProviderSource ¶
type ProviderSource struct {
Provider string `` /* 223-byte string literal not displayed */
Inputs map[string]*ValueRef `json:"inputs" yaml:"inputs" doc:"Provider inputs"`
When *Condition `json:"when,omitempty" yaml:"when,omitempty" doc:"Source-level condition"`
OnError ErrorBehavior `` /* 222-byte string literal not displayed */
}
ProviderSource represents a single source in the resolve phase
type ProviderTransform ¶
type ProviderTransform struct {
Provider string `` /* 217-byte string literal not displayed */
Inputs map[string]*ValueRef `json:"inputs" yaml:"inputs" doc:"Provider inputs"`
When *Condition `json:"when,omitempty" yaml:"when,omitempty" doc:"Step-level condition"`
OnError ErrorBehavior `` /* 131-byte string literal not displayed */
ForEach *ForEachClause `json:"forEach,omitempty" yaml:"forEach,omitempty" doc:"Iterate over array, executing provider for each element"`
}
ProviderTransform represents a single transform step
type ProviderValidation ¶
type ProviderValidation struct {
Provider string `` /* 224-byte string literal not displayed */
Inputs map[string]*ValueRef `json:"inputs" yaml:"inputs" doc:"Provider inputs"`
Message *ValueRef `json:"message,omitempty" yaml:"message,omitempty" doc:"Error message on validation failure"`
}
ProviderValidation represents a single validation rule
type RedactedError ¶
type RedactedError struct {
Original error `json:"-" yaml:"-" doc:"Original unredacted error"`
Redacted string `json:"error" yaml:"error" doc:"Redacted error message safe for display" maxLength:"100" example:"[REDACTED]"`
}
RedactedError wraps an error to provide a redacted version for sensitive contexts.
func NewRedactedError ¶
func NewRedactedError(original error) *RedactedError
NewRedactedError creates a new RedactedError.
func (*RedactedError) Error ¶
func (e *RedactedError) Error() string
Error returns the redacted error message.
func (*RedactedError) Unwrap ¶
func (e *RedactedError) Unwrap() error
Unwrap returns the original error for privileged access.
type RegistryInterface ¶
type RegistryInterface interface {
Register(p provider.Provider) error
Get(name string) (provider.Provider, error)
List() []provider.Provider
// DescriptorLookup returns a function that looks up provider descriptors by name.
// Returns nil if the registry does not support descriptor lookup.
DescriptorLookup() DescriptorLookup
}
RegistryInterface defines the interface for provider registries
type ResolvePhase ¶
type ResolvePhase struct {
With []ProviderSource `json:"with" yaml:"with" doc:"Ordered list of value sources" minItems:"1" maxItems:"50"`
Until *Condition `json:"until,omitempty" yaml:"until,omitempty" doc:"Stop condition (default: first non-null)"`
When *Condition `json:"when,omitempty" yaml:"when,omitempty" doc:"Phase-level condition"`
}
ResolvePhase defines how to obtain an initial value
type Resolver ¶
type Resolver struct {
// Metadata
Name string `` /* 233-byte string literal not displayed */
Description string `` /* 159-byte string literal not displayed */
DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty" doc:"Display name for UI" maxLength:"80" example:"Environment"`
Sensitive bool `json:"sensitive,omitempty" yaml:"sensitive,omitempty" doc:"Whether value should be redacted in logs" example:"false"`
Example any `json:"example,omitempty" yaml:"example,omitempty" doc:"Example value for documentation"`
// Type declaration
Type Type `json:"type,omitempty" yaml:"type,omitempty" doc:"Expected type of the resolved value" example:"string"`
// Conditional execution
When *Condition `json:"when,omitempty" yaml:"when,omitempty" doc:"Condition for executing this resolver"`
// Explicit dependencies
DependsOn []string `` /* 187-byte string literal not displayed */
// Timeout
Timeout *time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty" doc:"Maximum execution time (default: 30s)" example:"30s"`
// Phases
Resolve *ResolvePhase `json:"resolve" yaml:"resolve" doc:"Value resolution phase"`
Transform *TransformPhase `json:"transform,omitempty" yaml:"transform,omitempty" doc:"Value transformation phase"`
Validate *ValidatePhase `json:"validate,omitempty" yaml:"validate,omitempty" doc:"Value validation phase"`
}
Resolver represents a single resolver definition
func GetResolversInPhase ¶
func GetResolversInPhase(phases []*PhaseGroup, phaseNum int) []*Resolver
GetResolversInPhase returns all resolvers in a specific phase
type ResolverDiff ¶
type ResolverDiff struct {
Type DiffType `json:"type" doc:"Type of difference (added, removed, modified, unchanged)"`
Before *SnapshotResolver `json:"before,omitempty" doc:"Value before change"`
After *SnapshotResolver `json:"after,omitempty" doc:"Value after change"`
Changes []FieldChange `json:"changes,omitempty" doc:"List of field changes"`
}
ResolverDiff represents the difference for a single resolver
type ResolverLike ¶
ResolverLike is an interface for objects that have a Name and Sensitive flag nolint:revive // ResolverLike name is intentional to indicate compatibility with Resolver type
type ResolverMetric ¶
type ResolverMetric struct {
Name string `json:"name" doc:"Resolver name"`
Duration time.Duration `json:"duration,omitempty" doc:"Execution duration"`
Size int64 `json:"size,omitempty" doc:"Value size in bytes"`
Phase int `json:"phase" doc:"Execution phase number"`
}
ResolverMetric contains metrics for a single resolver nolint:revive // ResolverMetric name is intentional for clarity in metrics context
type Snapshot ¶
type Snapshot struct {
Metadata SnapshotMetadata `json:"metadata" doc:"Snapshot metadata"`
Parameters map[string]any `json:"parameters" doc:"Parameters used in execution"`
Resolvers map[string]*SnapshotResolver `json:"resolvers" doc:"Resolver execution results"`
Phases []SnapshotPhase `json:"phases" doc:"Phase execution information"`
}
Snapshot represents a complete snapshot of resolver execution
func CaptureSnapshot ¶
func CaptureSnapshot( ctx context.Context, solutionName string, solutionVersion string, buildVersion string, parameters map[string]any, totalDuration time.Duration, overallStatus ExecutionStatus, ) (*Snapshot, error)
CaptureSnapshot creates a snapshot from execution context and results
func LoadSnapshot ¶
LoadSnapshot loads a snapshot from a JSON file
type SnapshotDiff ¶
type SnapshotDiff struct {
Before *SnapshotMetadata `json:"before" doc:"Metadata of the before snapshot"`
After *SnapshotMetadata `json:"after" doc:"Metadata of the after snapshot"`
Resolvers map[string]*ResolverDiff `json:"resolvers" doc:"Differences in resolvers"`
Summary *DiffSummary `json:"summary" doc:"Summary of changes"`
}
SnapshotDiff represents the differences between two snapshots
func DiffSnapshots ¶
func DiffSnapshots(before, after *Snapshot) *SnapshotDiff
DiffSnapshots compares two snapshots and returns their differences
func DiffSnapshotsWithOptions ¶
func DiffSnapshotsWithOptions(before, after *Snapshot, opts *DiffOptions) *SnapshotDiff
DiffSnapshotsWithOptions compares two snapshots with custom options
type SnapshotFailedAttempt ¶
type SnapshotFailedAttempt struct {
Provider string `json:"provider" doc:"Provider name"`
SourceStep int `json:"sourceStep" doc:"Source/step index in phase"`
Error string `json:"error" doc:"Error message"`
Duration string `json:"duration" doc:"Time spent on this attempt"`
Timestamp string `json:"timestamp" doc:"When attempt occurred"`
}
SnapshotFailedAttempt contains information about a failed provider attempt
type SnapshotMetadata ¶
type SnapshotMetadata struct {
Solution string `json:"solution" doc:"Solution name"`
Version string `json:"version,omitempty" doc:"Solution version"`
Timestamp time.Time `json:"timestamp" doc:"When snapshot was captured"`
ScafctlVersion string `json:"scafctlVersion" doc:"scafctl version"`
TotalDuration string `json:"totalDuration" doc:"Total execution duration"`
Status string `json:"status" doc:"Overall execution status (success, failed)"`
}
SnapshotMetadata contains metadata about the snapshot
type SnapshotPhase ¶
type SnapshotPhase struct {
Phase int `json:"phase" doc:"Phase number (1-based)"`
Duration string `json:"duration" doc:"Phase execution duration"`
Resolvers []string `json:"resolvers" doc:"Resolver names in this phase"`
}
SnapshotPhase contains information about a phase execution
type SnapshotResolver ¶
type SnapshotResolver struct {
Value any `json:"value" doc:"Resolved value (or <redacted> if sensitive)"`
Status string `json:"status" doc:"Execution status (success, failed, skipped)"`
Phase int `json:"phase" doc:"Execution phase number"`
Duration string `json:"duration" doc:"Execution duration"`
ProviderCalls int `json:"providerCalls" doc:"Number of provider calls made"`
ValueSizeBytes int64 `json:"valueSizeBytes,omitempty" doc:"Size of value in bytes"`
Sensitive bool `json:"sensitive,omitempty" doc:"Whether value was redacted"`
Error string `json:"error,omitempty" doc:"Error message if failed"`
FailedAttempts []SnapshotFailedAttempt `json:"failedAttempts,omitempty" doc:"Failed provider attempts (onError: continue)"`
}
SnapshotResolver contains execution result for a single resolver
type TransformPhase ¶
type TransformPhase struct {
With []ProviderTransform `json:"with" yaml:"with" doc:"Ordered list of transformations" minItems:"1" maxItems:"50"`
When *Condition `json:"when,omitempty" yaml:"when,omitempty" doc:"Phase-level condition"`
}
TransformPhase defines how to derive a new value
type TypeCoercionError ¶
type TypeCoercionError struct {
ResolverName string `json:"resolverName" yaml:"resolverName" doc:"Name of the resolver" example:"age-value"`
Phase string `json:"phase" yaml:"phase" doc:"Phase where coercion was attempted" enum:"resolve,transform" example:"resolve"`
SourceType string `json:"sourceType" yaml:"sourceType" doc:"Original type of the value" example:"string"`
TargetType Type `json:"targetType" yaml:"targetType" doc:"Target type for coercion" example:"int"`
Cause error `json:"-" yaml:"-" doc:"Underlying coercion error"`
}
TypeCoercionError represents a failure to coerce a value to the expected type.
func (*TypeCoercionError) Error ¶
func (e *TypeCoercionError) Error() string
Error implements the error interface.
func (*TypeCoercionError) Unwrap ¶
func (e *TypeCoercionError) Unwrap() error
Unwrap returns the underlying cause.
type ValidatePhase ¶
type ValidatePhase struct {
With []ProviderValidation `json:"with" yaml:"with" doc:"Validation rules" minItems:"1" maxItems:"20"`
When *Condition `json:"when,omitempty" yaml:"when,omitempty" doc:"Phase-level condition"`
}
ValidatePhase defines validation constraints
type ValidationFailure ¶
type ValidationFailure struct {
Rule int `json:"rule" yaml:"rule" doc:"Rule number (0-indexed) that failed" minimum:"0" example:"0"`
Provider string `json:"provider" yaml:"provider" doc:"Validation provider name" example:"validation"`
Message string `` /* 129-byte string literal not displayed */
Cause error `json:"-" yaml:"-" doc:"Underlying error from the validation provider"`
Sensitive bool `json:"sensitive,omitempty" yaml:"sensitive,omitempty" doc:"Whether this failure contains sensitive information"`
}
ValidationFailure represents a single validation rule failure.
func (*ValidationFailure) Error ¶
func (f *ValidationFailure) Error() string
Error implements the error interface for a single failure.
type ValueRef ¶
ValueRef is an alias to spec.ValueRef for backward compatibility. It represents a value that can be literal, resolver reference, expression, or template.
type ValueSizeError ¶
type ValueSizeError struct {
ResolverName string `json:"resolverName" yaml:"resolverName" doc:"Name of the resolver with oversized value" example:"large-data"`
ActualSize int64 `json:"actualSize" yaml:"actualSize" doc:"Actual size of the value in bytes" minimum:"0" example:"10485760"`
MaxSize int64 `json:"maxSize" yaml:"maxSize" doc:"Maximum allowed size in bytes" minimum:"1" example:"1048576"`
}
ValueSizeError represents a value that exceeds the maximum allowed size.
func (*ValueSizeError) Error ¶
func (e *ValueSizeError) Error() string
Error implements the error interface.