locals

package
v1.205.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package locals provides resolution for file-scoped local variables in Atmos stack configurations. Locals enable users to define temporary variables that are available within a single file, similar to Terraform and Terragrunt locals.

Key features: - File-scoped: locals do not inherit across file boundaries - Dependency resolution: locals can reference other locals with topological sorting - Cycle detection: circular dependencies are detected and reported clearly - Multi-scope: locals can be defined at global, component-type, and component levels

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver handles dependency resolution and cycle detection for locals. It uses topological sorting to determine the order in which locals should be resolved.

func NewResolver

func NewResolver(locals map[string]any, filePath string) *Resolver

NewResolver creates a resolver for a set of locals. The filePath is used for error message context.

func (*Resolver) GetDependencies

func (r *Resolver) GetDependencies() map[string][]string

GetDependencies returns the dependency graph for testing/debugging.

func (*Resolver) Resolve

func (r *Resolver) Resolve(parentLocals map[string]any) (map[string]any, error)

Resolve processes all locals in dependency order, returning resolved values. Parent locals (from outer scopes) are available during resolution. Returns error if circular dependency detected or undefined local referenced.

func (*Resolver) WithTemplateContext added in v1.205.0

func (r *Resolver) WithTemplateContext(context map[string]any) *Resolver

WithTemplateContext sets additional context available during template resolution. This allows locals to reference other sections like .settings and .vars from the same file. Returns the resolver for method chaining.

func (*Resolver) WithYamlFunctionProcessor added in v1.205.0

func (r *Resolver) WithYamlFunctionProcessor(processor YamlFunctionProcessor) *Resolver

WithYamlFunctionProcessor sets a callback for processing YAML function tags. This allows locals to use YAML functions like !terraform.state and !terraform.output. Returns the resolver for method chaining.

type YamlFunctionProcessor added in v1.205.0

type YamlFunctionProcessor func(value string) (any, error)

YamlFunctionProcessor is a callback for processing YAML function tags in locals. It takes a string value (e.g., "!terraform.state component .output") and returns the resolved value. If the string is not a YAML function, it should return (nil, nil) to indicate no processing was done.

Jump to

Keyboard shortcuts

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