Documentation
¶
Index ¶
- Constants
- func Merge(atmosConfig *schema.AtmosConfiguration, inputs []map[string]any) (map[string]any, error)
- func MergeWithContext(atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, ...) (map[string]any, error)
- func MergeWithOptions(atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, ...) (map[string]any, error)
- func MergeWithOptionsAndContext(atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, ...) (map[string]any, error)
- func MergeWithProvenance(atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, ...) (map[string]any, error)
- type MergeContext
- func (mc *MergeContext) Clone() *MergeContext
- func (mc *MergeContext) EnableProvenance()
- func (mc *MergeContext) FormatError(err error, additionalInfo ...string) error
- func (mc *MergeContext) GetDepth() int
- func (mc *MergeContext) GetImportChainString() string
- func (c *MergeContext) GetImportDepth() int
- func (mc *MergeContext) GetProvenance(path string) []ProvenanceEntry
- func (mc *MergeContext) GetProvenancePaths() []string
- func (mc *MergeContext) GetProvenanceType() ProvenanceType
- func (mc *MergeContext) HasFile(filePath string) bool
- func (mc *MergeContext) HasProvenance(path string) bool
- func (mc *MergeContext) IsProvenanceEnabled() bool
- func (mc *MergeContext) RecordProvenance(path string, entry ProvenanceEntry)
- func (mc *MergeContext) WithFile(filePath string) *MergeContext
- type ProvenanceEntry
- type ProvenanceEntryParams
- type ProvenanceStorage
- func (ps *ProvenanceStorage) Clear()
- func (ps *ProvenanceStorage) Clone() *ProvenanceStorage
- func (ps *ProvenanceStorage) Get(path string) []ProvenanceEntry
- func (ps *ProvenanceStorage) GetLatest(path string) *ProvenanceEntry
- func (ps *ProvenanceStorage) GetPaths() []string
- func (ps *ProvenanceStorage) Has(path string) bool
- func (ps *ProvenanceStorage) Record(path string, entry ProvenanceEntry)
- func (ps *ProvenanceStorage) Remove(path string)
- func (ps *ProvenanceStorage) Size() int
- type ProvenanceTracker
- type ProvenanceType
Constants ¶
const ( ListMergeStrategyReplace = "replace" ListMergeStrategyAppend = "append" ListMergeStrategyMerge = "merge" )
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
func Merge( atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, ) (map[string]any, error)
Merge takes a list of maps as input, deep-merges the items in the order they are defined in the list, and returns a single map with the merged contents.
func MergeWithContext ¶ added in v1.191.0
func MergeWithContext( atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, context *MergeContext, ) (map[string]any, error)
MergeWithContext performs a merge operation with file context tracking for better error messages.
func MergeWithOptions ¶ added in v1.3.1
func MergeWithOptions( atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, appendSlice bool, sliceDeepCopy bool, ) (map[string]any, error)
MergeWithOptions takes a list of maps and options as input, deep-merges the items in the order they are defined in the list, and returns a single map with the merged contents.
func MergeWithOptionsAndContext ¶ added in v1.191.0
func MergeWithOptionsAndContext( atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, appendSlice bool, sliceDeepCopy bool, context *MergeContext, ) (map[string]any, error)
MergeWithOptionsAndContext performs merge with options and context tracking.
func MergeWithProvenance ¶ added in v1.194.0
func MergeWithProvenance( atmosConfig *schema.AtmosConfiguration, inputs []map[string]any, ctx *MergeContext, positions u.PositionMap, ) (map[string]any, error)
MergeWithProvenance merges multiple maps and records provenance information. It tracks where each value originated (file, line, column) and at what import depth.
Parameters.
- atmosConfig: Atmos configuration with TrackProvenance flag.
- inputs: Maps to merge (in order: first is base, last wins).
- ctx: Merge context with provenance storage.
- positions: Map of JSONPath -> Position from YAML parsing.
Returns the merged map with provenance recorded in ctx.
Types ¶
type MergeContext ¶ added in v1.191.0
type MergeContext struct {
// CurrentFile is the file currently being processed.
CurrentFile string
// ImportChain tracks the chain of imports leading to the current file.
// The first element is the root file, the last is the current file.
ImportChain []string
// ParentContext is the parent merge context for nested operations.
ParentContext *MergeContext
// Provenance stores optional provenance tracking for configuration values.
// This is nil by default (provenance disabled) for zero performance overhead.
// Call EnableProvenance() to activate provenance tracking.
Provenance *ProvenanceStorage
// Positions stores YAML position information for values in the current file.
// This maps JSONPath-style paths to line/column positions in the YAML file.
// Used by MergeWithProvenance to record accurate provenance data.
Positions u.PositionMap
}
MergeContext tracks file paths and import chains during merge operations to provide better error messages when merge conflicts occur. It also optionally tracks provenance information for configuration values.
MergeContext implements the ProvenanceTracker interface, providing a concrete implementation for stack component provenance tracking.
func NewMergeContext ¶ added in v1.191.0
func NewMergeContext() *MergeContext
NewMergeContext creates a new merge context.
func (*MergeContext) Clone ¶ added in v1.191.0
func (mc *MergeContext) Clone() *MergeContext
Clone creates a copy of the merge context.
func (*MergeContext) EnableProvenance ¶ added in v1.194.0
func (mc *MergeContext) EnableProvenance()
EnableProvenance activates provenance tracking for this context. This must be called before any provenance recording occurs. Once enabled, all merge operations will track the source of each value.
func (*MergeContext) FormatError ¶ added in v1.191.0
func (mc *MergeContext) FormatError(err error, additionalInfo ...string) error
FormatError formats an error with merge context information.
func (*MergeContext) GetDepth ¶ added in v1.191.0
func (mc *MergeContext) GetDepth() int
GetDepth returns the depth of the import chain.
func (*MergeContext) GetImportChainString ¶ added in v1.191.0
func (mc *MergeContext) GetImportChainString() string
GetImportChainString returns a formatted string of the import chain.
func (*MergeContext) GetImportDepth ¶ added in v1.194.0
func (c *MergeContext) GetImportDepth() int
GetImportDepth returns the current import depth from the merge context. Returns 0 if context is nil or has no parent chain.
func (*MergeContext) GetProvenance ¶ added in v1.194.0
func (mc *MergeContext) GetProvenance(path string) []ProvenanceEntry
GetProvenance returns the provenance chain for a given path. Returns nil if provenance is not enabled or no provenance exists for the path.
func (*MergeContext) GetProvenancePaths ¶ added in v1.194.0
func (mc *MergeContext) GetProvenancePaths() []string
GetProvenancePaths returns all paths that have provenance information. Returns nil if provenance is not enabled.
func (*MergeContext) GetProvenanceType ¶ added in v1.194.0
func (mc *MergeContext) GetProvenanceType() ProvenanceType
GetProvenanceType returns the appropriate provenance type for the current file. Returns ProvenanceTypeInline if this is the root file (first in import chain), or ProvenanceTypeImport if this is an imported file.
func (*MergeContext) HasFile ¶ added in v1.191.0
func (mc *MergeContext) HasFile(filePath string) bool
HasFile checks if a file is already in the import chain (to detect circular imports).
func (*MergeContext) HasProvenance ¶ added in v1.194.0
func (mc *MergeContext) HasProvenance(path string) bool
HasProvenance checks if provenance exists for a given path. Returns false if provenance is not enabled.
func (*MergeContext) IsProvenanceEnabled ¶ added in v1.194.0
func (mc *MergeContext) IsProvenanceEnabled() bool
IsProvenanceEnabled returns true if provenance tracking is enabled.
func (*MergeContext) RecordProvenance ¶ added in v1.194.0
func (mc *MergeContext) RecordProvenance(path string, entry ProvenanceEntry)
RecordProvenance records provenance information for a value at the given path. This is a no-op if provenance is not enabled (Provenance is nil).
func (*MergeContext) WithFile ¶ added in v1.191.0
func (mc *MergeContext) WithFile(filePath string) *MergeContext
WithFile creates a new context for processing a specific file.
type ProvenanceEntry ¶ added in v1.194.0
type ProvenanceEntry struct {
// File is the source file path where this value was defined.
File string
// Line is the line number (1-indexed) where this value appears.
Line int
// Column is the column number (1-indexed) where this value starts.
Column int
// Type indicates how this value was introduced (import, inline, override, computed, default).
Type ProvenanceType
// ValueHash is a hash of the value for change detection.
// This allows detecting when a value was overridden with the same value.
ValueHash string
// Depth is the inheritance depth (0=parent stack, 1=direct import, 2+=nested imports).
Depth int
}
ProvenanceEntry represents the provenance information for a single value. It tracks where a value came from in the configuration file hierarchy.
func NewProvenanceEntry ¶ added in v1.194.0
func NewProvenanceEntry(params ProvenanceEntryParams) *ProvenanceEntry
NewProvenanceEntry creates a new provenance entry.
func (*ProvenanceEntry) Clone ¶ added in v1.194.0
func (p *ProvenanceEntry) Clone() *ProvenanceEntry
Clone creates a deep copy of the provenance entry.
func (*ProvenanceEntry) Equals ¶ added in v1.194.0
func (p *ProvenanceEntry) Equals(other *ProvenanceEntry) bool
Equals checks if two provenance entries are equal. Two entries are equal if they have the same file, line, column, type, value hash, and depth.
func (*ProvenanceEntry) IsValid ¶ added in v1.194.0
func (p *ProvenanceEntry) IsValid() bool
IsValid checks if the provenance entry has valid data. A valid entry must have a file path and a positive line number.
func (*ProvenanceEntry) String ¶ added in v1.194.0
func (p *ProvenanceEntry) String() string
String returns a human-readable representation of the provenance entry.
type ProvenanceEntryParams ¶ added in v1.194.0
type ProvenanceEntryParams struct {
File string
Line int
Column int
Type ProvenanceType
Value any
Depth int
}
ProvenanceEntryParams contains parameters for creating a provenance entry.
type ProvenanceStorage ¶ added in v1.194.0
type ProvenanceStorage struct {
// contains filtered or unexported fields
}
ProvenanceStorage stores provenance information for configuration values. It maps JSONPath-style paths to a chain of provenance entries showing the inheritance/override history of each value.
func NewProvenanceStorage ¶ added in v1.194.0
func NewProvenanceStorage() *ProvenanceStorage
NewProvenanceStorage creates a new provenance storage.
func (*ProvenanceStorage) Clear ¶ added in v1.194.0
func (ps *ProvenanceStorage) Clear()
Clear removes all provenance entries.
func (*ProvenanceStorage) Clone ¶ added in v1.194.0
func (ps *ProvenanceStorage) Clone() *ProvenanceStorage
Clone creates a deep copy of the provenance storage.
func (*ProvenanceStorage) Get ¶ added in v1.194.0
func (ps *ProvenanceStorage) Get(path string) []ProvenanceEntry
Get returns the provenance chain for a given path. Returns nil if no provenance exists for the path. The returned slice is ordered from base → override.
func (*ProvenanceStorage) GetLatest ¶ added in v1.194.0
func (ps *ProvenanceStorage) GetLatest(path string) *ProvenanceEntry
GetLatest returns the most recent (final) provenance entry for a path. Returns nil if no provenance exists for the path.
func (*ProvenanceStorage) GetPaths ¶ added in v1.194.0
func (ps *ProvenanceStorage) GetPaths() []string
GetPaths returns all paths that have provenance information. The paths are returned in sorted order for consistent iteration.
func (*ProvenanceStorage) Has ¶ added in v1.194.0
func (ps *ProvenanceStorage) Has(path string) bool
Has checks if provenance exists for a given path.
func (*ProvenanceStorage) Record ¶ added in v1.194.0
func (ps *ProvenanceStorage) Record(path string, entry ProvenanceEntry)
Record adds a provenance entry for a given path. Multiple entries can be recorded for the same path to track inheritance chains.
func (*ProvenanceStorage) Remove ¶ added in v1.194.0
func (ps *ProvenanceStorage) Remove(path string)
Remove deletes provenance information for a given path.
func (*ProvenanceStorage) Size ¶ added in v1.194.0
func (ps *ProvenanceStorage) Size() int
Size returns the number of paths with provenance information.
type ProvenanceTracker ¶ added in v1.194.0
type ProvenanceTracker interface {
// RecordProvenance records provenance information for a value at the given path.
// The path should use JSONPath-style syntax (e.g., "vars.tags.environment").
// Multiple entries for the same path represent the inheritance chain (base → override).
RecordProvenance(path string, entry ProvenanceEntry)
// GetProvenance returns the complete provenance chain for a given path.
// The chain is ordered from base → override, with the last entry being the final value.
// Returns nil if no provenance exists for the path.
GetProvenance(path string) []ProvenanceEntry
// HasProvenance checks if provenance information exists for the given path.
// Returns false if provenance tracking is disabled or path has no provenance.
HasProvenance(path string) bool
// GetProvenancePaths returns all paths that have provenance information.
// Returns nil if provenance tracking is disabled.
// The order of paths is not guaranteed.
GetProvenancePaths() []string
// IsProvenanceEnabled returns true if provenance tracking is currently active.
// When disabled, RecordProvenance calls should be no-ops for performance.
IsProvenanceEnabled() bool
// EnableProvenance activates provenance tracking for this tracker.
// This should be called before any provenance recording occurs.
// Once enabled, all merge/load operations should track provenance.
EnableProvenance()
}
ProvenanceTracker provides a generic interface for tracking configuration provenance. This interface allows different configuration systems (stacks, atmos.yaml, vendor, workflows) to implement provenance tracking in a consistent way.
Implementations should:
- Track the source file, line, and column for each configuration value
- Support hierarchical paths (JSONPath-style) for nested values
- Record inheritance/override chains when values are merged
- Be thread-safe if used in concurrent scenarios
Example implementations:
- MergeContext: Tracks provenance for stack component merging
- Future: AtmosConfigContext for atmos.yaml imports
- Future: VendorContext for vendor.yaml provenance
- Future: WorkflowContext for workflow definitions
type ProvenanceType ¶ added in v1.194.0
type ProvenanceType string
ProvenanceType represents the type of provenance entry.
const ( // ProvenanceTypeImport indicates the value was imported from another file. ProvenanceTypeImport ProvenanceType = "import" // ProvenanceTypeInline indicates the value was defined inline in the current file. ProvenanceTypeInline ProvenanceType = "inline" // ProvenanceTypeOverride indicates the value overrides a previous value. ProvenanceTypeOverride ProvenanceType = "override" // ProvenanceTypeComputed indicates the value was computed (e.g., from a template). ProvenanceTypeComputed ProvenanceType = "computed" // ProvenanceTypeDefault indicates the value is a default value. ProvenanceTypeDefault ProvenanceType = "default" )