component

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 31 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ComponentKey is the key used for component fields in stack configuration maps.
	ComponentKey = "component"
	// TypeKey is the key used for component type fields in stack configuration maps.
	TypeKey = "type"
	// StackKey is the key used for stack fields in logging and context.
	StackKey = "stack"
)

Variables

This section is empty.

Functions

func ApplyWorkdirSubpathToSection added in v1.217.0

func ApplyWorkdirSubpathToSection(info *schema.ConfigAndStacksInfo) (string, error)

ApplyWorkdirSubpathToSection resolves provWorkdir.WorkdirPathKey in info.ComponentSection against info.BaseComponentPath (joining the subpath only when it exists on disk; see ResolveWorkdirSubpath) and returns the resolved path, or "" when WorkdirPathKey is absent or empty. Stat errors propagate as a non-nil error.

Mutates info.ComponentSection in place: writes the resolved path back to provWorkdir.WorkdirPathKey and sets a private-typed sentinel under workdirSubpathAppliedKey. ComponentSection is a shared map[string]any; the caller is responsible for ensuring no goroutine reads or writes the same section concurrently for the duration of this call.

The mutation is idempotent: the sentinel prevents re-resolving across repeat calls (e.g. terraform init then terraform plan within one command lifecycle).

func BuildAndResolveWorkdirPath added in v1.217.0

func BuildAndResolveWorkdirPath(
	atmosConfig *schema.AtmosConfiguration,
	info *schema.ConfigAndStacksInfo,
	componentType string,
) (string, bool, error)

BuildAndResolveWorkdirPath computes the effective component working directory for a workdir-enabled component by deriving the workdir root from provWorkdir.BuildPath and joining metadata.component onto it (only when the subpath actually exists on disk; see ResolveWorkdirSubpath).

Used by code paths that run after ProcessStacks has rebuilt ComponentSection (which does not carry WorkdirPathKey). Returns the resolved path, an existence flag (true when the resolved directory exists on disk), and any non-ENOENT stat error.

The componentType parameter is one of cfg.{Terraform,Helmfile,Packer,Ansible}ComponentType.

func BuildGraph added in v1.222.0

func BuildGraph(stacks map[string]any, componentType string, leftDelims ...string) (*dependency.Graph, error)

func ContextFromOptions

func ContextFromOptions(opts ...ExecutionOption) context.Context

ContextFromOptions returns the last supplied context or a background fallback.

func Count added in v1.196.0

func Count() int

Count returns the number of registered providers.

func Dependencies

func Dependencies(section map[string]any, kind, stack, leftDelim string) ([]schema.ComponentDependency, bool, error)

Dependencies returns normalized component dependencies and whether they use the modern declaration format. Graph consumers share the same legacy fallback and required-value handling as the single-type graph executor.

func DryRunDefersMissingPath

func DryRunDefersMissingPath(info *schema.ConfigAndStacksInfo) bool

DryRunDefersMissingPath reports whether an absent component directory is expected for this run. A dry run never downloads JIT source, so a source component that has not been provisioned yet has no directory to find, and executors must not reject it as a missing component. Components without a source keep failing when their local directory is missing.

func ExecuteGraph added in v1.222.0

func ExecuteGraph(ctx context.Context, opts *GraphExecutionOptions) error

ExecuteGraph runs selected components in dependency order and stops before starting another component when the caller context is canceled.

func FilterGraph added in v1.222.0

func FilterGraph(graph *dependency.Graph, info *schema.ConfigAndStacksInfo, selection *GraphSelection) *dependency.Graph

func GraphNodeID added in v1.222.0

func GraphNodeID(componentName, stackName string) string

func InvokingCommandFromOptions

func InvokingCommandFromOptions(opts ...ExecutionOption) *cobra.Command

InvokingCommandFromOptions extracts the invoking *cobra.Command (if any) set via WithInvokingCommand among opts.

func IsExplicitComponentPath added in v1.201.0

func IsExplicitComponentPath(component string) bool

IsExplicitComponentPath determines if a component argument represents an explicit filesystem path. Returns true if the argument should be treated as a filesystem path rather than a component name.

An argument is considered an explicit path if it: - Is "." (current directory) - Starts with "./" or "../" (Unix-style relative path) - Starts with ".\\" or "..\\" (Windows-style relative path) - Is an absolute path (filepath.IsAbs handles both Unix and Windows)

Otherwise, it's treated as a component name (even if it contains slashes like "vpc/security-group").

func ListAllComponents added in v1.221.0

func ListAllComponents(ctx context.Context, componentType string, stacksMap map[string]any) ([]string, error)

ListAllComponents lists all components of a given type across all stacks. This is useful for shell completion and interactive prompts. Returns a sorted, deduplicated list of component names.

func ListProviders added in v1.196.0

func ListProviders() map[string][]ComponentProvider

ListProviders returns all registered providers grouped by category. The map key is the group name, and the value is a slice of providers in that group.

func ListTypes added in v1.196.0

func ListTypes() []string

ListTypes returns all registered component types sorted alphabetically. Example: ["helmfile", "mock", "packer", "terraform"].

func MetadataOutputCaptureFromOptions

func MetadataOutputCaptureFromOptions(opts ...ExecutionOption) (io.Writer, io.Writer)

MetadataOutputCaptureFromOptions extracts the exec-metadata stdout/stderr tee writers (if any) set via WithMetadataOutputCapture among opts, so callers that retry the underlying invocation (executeShellCommandWithRetry) can reset them between attempts.

func MetadataParserFromOptions

func MetadataParserFromOptions(opts ...ExecutionOption) func(subCommand, component string, exitCode int, output string) any

MetadataParserFromOptions extracts the parser closure (if any) set via WithExecMetadataParser among opts.

func ProvisionAndResolveComponentPath added in v1.217.0

func ProvisionAndResolveComponentPath(
	ctx context.Context,
	writers provisioner.OutputWriters,
	atmosConfig *schema.AtmosConfiguration,
	info *schema.ConfigAndStacksInfo,
	componentType, fallbackComponentPath string,
) (string, bool, error)

ProvisionAndResolveComponentPath performs JIT source provisioning when the component declares a source, then resolves the effective component path by applying metadata.component as a subpath onto WorkdirPathKey when set. Returns the (possibly updated) component path, an existence flag, and any error.

Error classification:

  • AutoProvisionSource failures wrap errUtils.ErrProvisionerFailed (matches the established pattern in pkg/provisioner/registry.go and internal/exec/terraform_shell.go).
  • Path resolution / stat / abs-subpath rejection failures wrap errUtils.ErrWorkdirProvision.

componentType is one of cfg.{Terraform,Helmfile,Packer,Ansible}ComponentType. The caller owns ctx — typically constructed with a per-call-site timeout (e.g., context.WithTimeout(parent, 5*time.Minute)) before invocation.

func Register added in v1.196.0

func Register(provider ComponentProvider) error

Register adds a component provider to the registry. This is called during package init() for built-in components. If a provider with the same type already exists, it will be replaced (last registration wins, allowing plugin override).

Returns an error if the provider is nil or has an empty type.

func Reset added in v1.196.0

func Reset()

Reset clears the registry (for testing only). This should not be used in production code.

func ResolveConfiguredSubpath

func ResolveConfiguredSubpath(info *schema.ConfigAndStacksInfo, workdirRoot string) (string, error)

ResolveConfiguredSubpath selects the explicit module under a copied local source root. Unlike the legacy metadata.component hint, an explicit source subdirectory must exist and cannot silently fall back to the root. Use it for paths that are resolved after the source is provisioned; callers that run before it use ResolvePendingSubpath.

func ResolvePendingSubpath

func ResolvePendingSubpath(info *schema.ConfigAndStacksInfo, workdirRoot string) (string, bool, error)

ResolvePendingSubpath is ResolveConfiguredSubpath for callers that run before the source is provisioned, when an explicit source subdirectory may not exist yet. It returns the path the module will have and whether it exists now; every other failure, including an invalid subdirectory, is still an error.

func ResolveRetainedWorkdir

func ResolveRetainedWorkdir(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, componentType, fallbackComponentPath string) (string, error)

ResolveRetainedWorkdir records, without provisioning anything, the directory an earlier run populated and returns it. Reviewed saved plans use it to find their retained workdir in a new process, where only provisioning would otherwise set provWorkdir.WorkdirPathKey. The plan ran with the provider's module source, so an enabled workdir follows source target rules, including an explicit working_directory, even when the discovered section carries no source.

func ResolveWorkdirSubpath added in v1.217.0

func ResolveWorkdirSubpath(metadataSubpath, workdirRoot string) (string, error)

ResolveWorkdirSubpath returns workdirRoot joined with metadataSubpath if the joined directory exists on disk, otherwise workdirRoot unchanged.

The metadata.component field has two valid uses for JIT components: (1) a real subdirectory inside the cloned repo where the module lives (e.g. `modules/iam-policy` for repos that organize modules under `modules/`), and (2) an inheritance/identity pointer naming an abstract base component when the cloned repo's files live at its root. Disambiguating by string shape alone is unreliable, so we disambiguate by filesystem existence: after the source provisioner has cloned, either the joined directory exists (case 1) or it doesn't (case 2). Stat failures other than ENOENT surface as errors so corrupt state isn't masked.

".." segments in the subpath are intentionally permitted: upstream modules often reference shared files via relative parent paths, and metadata.component is YAML-author controlled (same trust class as !exec / !template / !terraform.state). Absolute subpaths are rejected because they violate the documented contract.

Types

type AllStacksDeferredContexts

type AllStacksDeferredContexts map[string]StackComponentDeferredContexts

AllStacksDeferredContexts holds every stack's deferred contexts keyed by [stack][componentType]component. This is the shape threaded from ProcessYAMLConfigFiles through FindStacksMap to the per-invocation Stage 3 resolver (see resolveDeferredYamlFunctions).

type ComponentDeferredContexts

type ComponentDeferredContexts map[string]*m.DeferredMergeContext

ComponentDeferredContexts holds the per-section *merge.DeferredMergeContext produced while merging a single component's configuration, keyed by section name (vars, settings, env, auth, providers, required_providers, hooks, test, generate — see the cfg.*SectionName constants used as keys). Each context tracks the deferred YAML functions (!template, !terraform.output, !labels, etc.) collected for that section during the raw structural merge; a later, per-invocation stage resolves them with a real YAMLFunctionProcessor and deep-merges the result against any concrete override at the same path.

type ComponentInfo added in v1.196.0

type ComponentInfo struct {
	Type        string
	Group       string
	Commands    []string
	Description string
}

ComponentInfo provides metadata about a component provider.

func GetInfo added in v1.196.0

func GetInfo() []ComponentInfo

GetInfo returns metadata for all registered component providers. Results are sorted by component type for consistent ordering.

type ComponentProvider added in v1.196.0

type ComponentProvider interface {
	// GetType returns the component type identifier (e.g., "terraform", "helmfile", "mock").
	GetType() string

	// GetGroup returns the component group for categorization.
	// Examples: "Infrastructure as Code", "Kubernetes", "Images", "Testing"
	GetGroup() string

	// GetBasePath returns the base directory path for this component type.
	// Example: For terraform, returns "components/terraform"
	GetBasePath(atmosConfig *schema.AtmosConfiguration) string

	// ListComponents discovers all components of this type in a stack.
	// Returns component names found in the stack configuration.
	ListComponents(ctx context.Context, stack string, stackConfig map[string]any) ([]string, error)

	// ValidateComponent validates component configuration.
	// Returns error if configuration is invalid for this component type.
	ValidateComponent(config map[string]any) error

	// Execute runs a command for this component type.
	// Context provides all necessary information for execution.
	Execute(ctx *ExecutionContext) error

	// GenerateArtifacts creates necessary files for component execution.
	// Examples: backend.tf for Terraform, varfile for Helmfile
	GenerateArtifacts(ctx *ExecutionContext) error

	// GetAvailableCommands returns list of commands this component type supports.
	// Example: For terraform: ["plan", "apply", "destroy", "workspace"]
	GetAvailableCommands() []string
}

ComponentProvider is the interface that component type implementations must satisfy to register with the Atmos component registry.

Component providers are registered via init() functions and enable extensible component type support without modifying core code.

func GetProvider added in v1.196.0

func GetProvider(componentType string) (ComponentProvider, bool)

GetProvider returns a component provider by type. Returns the provider and true if found, nil and false otherwise.

func MustGetProvider added in v1.196.0

func MustGetProvider(componentType string) ComponentProvider

MustGetProvider returns a component provider by type or panics if not found. This is useful in contexts where the component type is known to be registered.

type ComponentRegistry added in v1.196.0

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

ComponentRegistry manages component provider registration. It is thread-safe and supports concurrent registration and access.

type DescribeAffectedCmdArgs

type DescribeAffectedCmdArgs struct {
	CLIConfig                   *schema.AtmosConfiguration
	Base                        string // Unified base commit (ref or SHA). Takes precedence over Ref/SHA.
	CloneTargetRef              bool
	Format                      string
	IncludeDependents           bool
	IncludeSettings             bool
	IncludeSpaceliftAdminStacks bool
	OutputFile                  string
	GithubOutputFile            string // Output file for $GITHUB_OUTPUT format (key=value).
	Ref                         string
	RepoPath                    string
	SHA                         string
	SSHKeyPath                  string
	SSHKeyPassword              string
	Verbose                     bool
	Upload                      bool
	Stack                       string
	Query                       string
	ProcessTemplates            bool
	ProcessYamlFunctions        bool
	Skip                        []string
	ExcludeLocked               bool
	Tags                        []string          // Keep only components whose `metadata.tags` contain any of these (from --tags).
	LabelsRaw                   string            // Raw --labels value (comma-separated key=value pairs).
	Labels                      map[string]string // Parsed --labels: keep only components whose `metadata.labels` contain all of these.
	TagsEnvVar                  string            // Environment variable that supplied Tags (for example ATMOS_TAGS); empty when Tags came from the command line or are unset.
	LabelsEnvVar                string            // Environment variable that supplied Labels; empty when Labels came from the command line or are unset.
	Flatten                     bool              // Lift every dependent into the top-level list as `affected: dependent` (from --flatten); requires IncludeDependents.
	FlattenEnvVar               string            // Environment variable that supplied Flatten; empty when it came from the command line or is unset.
	AuthManager                 auth.AuthManager  // Optional: Auth manager for credential management (from --identity flag).
	AuthDisabled                bool              // True when --identity=false (or alias) explicitly disables authentication; routes stack resolution to ExecuteDescribeStacksWithAuthDisabled.
	HeadSHAOverride             string            // PR head SHA from CI event payload, used for upload correlation with Atmos Pro.
	CIEventType                 string            // CI event type (e.g., "pull_request", "push") for upload validation.
	TargetBranch                string            // PR target branch (e.g., "main") used to auto-fetch when refs are missing locally.
	ErrorMode                   string            // How to handle recoverable errors: "strict" (default), "warn", or "silent".
	Cmd                         *cobra.Command    // The invoking Cobra command, used to derive Flags for the exec-metadata sync capture (proexec.FlagsFromCommand).
}

type DescribeStacksErrorOptions

type DescribeStacksErrorOptions struct {
	// StaticOnly inspects merged configuration without auth, expression evaluation, workspace
	// synthesis, or evaluated-map cache reuse. Stack name templates allow only Go's pure built-ins.
	StaticOnly bool
	// EvaluationPaths optionally narrows list columns to fields within sections.
	EvaluationPaths [][]string
	OnError         OnErrorMode
	OnWarning       func(degradation.Warning)
	// OnProgress, when non-nil, is called once per stack file immediately before it's
	// processed — stackFile is the file name, index is 0-based, total is the number of
	// stack files describe-stacks will visit this call (both counted before filtering by
	// includeEmptyStacks, so total is a stable upper bound even though some files are
	// skipped). Bundled onto this struct (rather than a new parameter) purely for plumbing
	// convenience — it shares the same threading path as OnError/OnWarning. Optional; a nil
	// OnProgress is a no-op, matching every existing caller's behavior exactly.
	OnProgress func(stackFile string, index, total int)
	// StrictAuth, when true, keeps a component-specific auth-manager construction failure
	// fatal even under OnErrorWarn (see describeStacksProcessor.resolveComponentAuthManager) --
	// only the recoverable per-value YAML-function errors (e.g. !terraform.state hitting a
	// not-yet-provisioned backend) degrade. The zero value (false) preserves the original
	// list/describe --error-mode=warn behavior, where a component whose own declared identity
	// can't be resolved gracefully falls back to the parent AuthManager instead of aborting --
	// appropriate for merely listing/describing stacks, but not for a Terraform preflight
	// about to run real commands with whatever credentials it resolves.
	StrictAuth bool
	// ExtraComponentTypes names additional component kinds, such as custom kinds declared
	// by custom commands, to process after the built-in kinds. Each kind must already be
	// registered with the component registry for its stack section to be available. The
	// zero value leaves the described component kinds exactly as before.
	ExtraComponentTypes []string
}

type ExecuteDescribeComponentParams

type ExecuteDescribeComponentParams struct {
	// ResolveSecrets retrieves actual secrets for internal value-producing callers.
	// The default preserves credential-free, masked inspection.
	ResolveSecrets       bool
	AtmosConfig          *schema.AtmosConfiguration // Optional: Use provided config instead of initializing new one.
	Component            string
	Stack                string
	ComponentType        string // Optional: if set, only try this component type.
	ProcessTemplates     bool
	ProcessYamlFunctions bool
	UseMocks             bool
	Skip                 []string
	AuthManager          auth.AuthManager
	AuthDisabled         bool
	ErrorOptions         DescribeStacksErrorOptions
	// CommandPath names the CLI command that needs the component, such as
	// ["secret", "shell"], for component admission. Empty means `describe component`.
	CommandPath []string
}

type ExecutionContext added in v1.196.0

type ExecutionContext struct {
	// Context carries caller cancellation and deadlines into component execution.
	// Use GoContext so legacy callers that omit it retain background behavior.
	Context context.Context
	// Options carries process streams, environment, and reporting through provider dispatch.
	Options []ExecutionOption
	// WorkingDir is required by providers that generate artifacts for a prepared component.
	WorkingDir          string
	AtmosConfig         *schema.AtmosConfiguration
	ComponentType       string
	Component           string
	Stack               string
	Command             string
	SubCommand          string
	ComponentConfig     map[string]any
	ConfigAndStacksInfo schema.ConfigAndStacksInfo
	Args                []string
	Flags               map[string]any
}

ExecutionContext contains component execution metadata and the caller context. Construct values with keyed fields because new execution metadata may be added over time.

func (*ExecutionContext) GoContext added in v1.229.0

func (e *ExecutionContext) GoContext() context.Context

GoContext returns the caller context or a non-nil compatibility fallback.

type ExecutionOption

type ExecutionOption func(*ExecutionOptions)

ExecutionOption is a functional option for ExecuteShellCommand.

func WithEnvironment

func WithEnvironment(env []string) ExecutionOption

WithEnvironment provides a pre-sanitized process environment for subprocess execution. When provided, ExecuteShellCommand uses this instead of re-reading os.Environ(). Pass nil to fall back to the default os.Environ() behavior.

func WithExecMetadataParser

func WithExecMetadataParser(fn func(subCommand, component string, exitCode int, output string) any) ExecutionOption

WithExecMetadataParser provides a closure that, given the invoking subcommand name, resolved component name, and command's own exit code, returns command-specific structured data (FR-006) for the execution record — or nil if there is none to report. The exitCode parameter is the terraform/tofu subprocess's own exit code (research.md Decision 27), supplied by captureExecMetadataSync at call time since it isn't known when this closure is created. Cmd/terraform supplies this closure so ExecuteTerraform's exec-metadata sync capture can obtain parsed terraform plan/apply/deploy output without internal/exec itself importing the CI plugin's parser (research.md Decision 18).

func WithGracefulInterrupt

func WithGracefulInterrupt() ExecutionOption

WithGracefulInterrupt lets the subprocess stop on its own when Atmos is interrupted. Terraform and OpenTofu use it so the first Ctrl-C or SIGTERM reaches them once and they can finish the in-flight resource, write state, and release the lock before Atmos exits. A second signal still terminates them. See process.InterruptGraceful.

func WithInvokingCommand

func WithInvokingCommand(cmd *cobra.Command) ExecutionOption

WithInvokingCommand provides the Cobra command the user actually invoked, so ExecuteTerraform's exec-metadata sync capture can derive Flags from the command's own record of explicitly-set flags (proexec.FlagsFromCommand) rather than info.AdditionalArgsAndFlags.

func WithMetadataOutputCapture

func WithMetadataOutputCapture(stdoutW, stderrW io.Writer) ExecutionOption

WithMetadataOutputCapture tees this specific ExecuteShellCommand call's stdout/stderr into stdoutW/stderrW, in addition to whatever WithStdoutCapture/WithStderrCapture already capture. Used internally by executeCommandPipeline to scope the exec-metadata parser's input to only the final plan/apply/deploy subprocess invocation (FR-006f), without disturbing the broader stdout/stderr buffers other consumers (e.g. cmd/terraform's capturedPlanOutput, used by CI job-summary hooks) rely on for the whole init+workspace-select+main pipeline.

func WithMetricsCallback

func WithMetricsCallback(fn func(*metricsprocess.ProcessMetrics)) ExecutionOption

WithMetricsCallback provides a closure that ExecuteShellCommand invokes once, after the subprocess exits, with the subprocess tree's collected resource-usage metrics. Used by executeMainTerraformCommand to capture the main plan/apply/deploy subprocess's own metrics for combining with atmos's self-usage — both for local display and the exec-metadata sync upload.

func WithProcessContext

func WithProcessContext(ctx context.Context) ExecutionOption

WithProcessContext provides the context used for subprocess execution.

func WithProcessStreams

func WithProcessStreams(streams process.Streams) ExecutionOption

WithProcessStreams provides the subprocess standard streams.

func WithStderrCapture

func WithStderrCapture(w io.Writer) ExecutionOption

WithStderrCapture returns an ExecutionOption that tees stderr to the provided writer. The captured output is the raw, unmasked subprocess output; only the terminal copy is masked. Callers that persist or display captured output must mask it themselves.

func WithStdoutCapture

func WithStdoutCapture(w io.Writer) ExecutionOption

WithStdoutCapture returns an ExecutionOption that tees stdout to the provided writer. The captured output is the raw, unmasked subprocess output; only the terminal copy is masked. Callers that persist or display captured output must mask it themselves.

func WithStdoutOverride

func WithStdoutOverride(w io.Writer) ExecutionOption

WithStdoutOverride returns an ExecutionOption that replaces the default stdout (os.Stdout) with a different writer. Used to redirect noisy commands (e.g., workspace select) to stderr so they don't pollute data-producing commands like output.

type ExecutionOptions

type ExecutionOptions struct {
	StdoutCapture  io.Writer
	StderrCapture  io.Writer
	StdoutOverride io.Writer
	Streams        *process.Streams
	Ctx            context.Context
	// ProcessEnv replaces os.Environ() as the process environment.
	// When set, ExecuteShellCommand uses this instead of re-reading os.Environ().
	// This is used when auth has already sanitized the environment (e.g., removed IRSA vars).
	ProcessEnv []string
	// InvokingCmd is the Cobra command the user actually invoked (e.g. the
	// terraform plan subcommand). Threaded through so ExecuteTerraform can
	// report the real Flags actually passed (FR-003b) to the exec-metadata
	// sync capture, instead of a pass-through-args collection that cannot
	// contain atmos-recognized flags (research.md Decision 14).
	InvokingCmd *cobra.Command
	// ExecMetadataParser, when set, is called once by captureExecMetadataSync
	// (sync-allowlisted commands only) to obtain command-specific structured
	// data (FR-006) for the execution record. cmd/terraform supplies this —
	// it can safely call pkg/ci/plugins/terraform's output parser, unlike
	// internal/exec, which cannot import it without reintroducing a confirmed
	// import cycle (research.md Decision 18). The output parameter is the
	// scoped exec-metadata output text executeCommandPipeline captured for
	// just the main plan/apply/deploy subprocess (FR-006f).
	ExecMetadataParser func(subCommand, component string, exitCode int, output string) any

	// ExecMetadataStdoutCapture/ExecMetadataStderrCapture, when set, additionally
	// tee this specific ExecuteShellCommand call's stdout/stderr into these
	// writers, alongside (not instead of) StdoutCapture/StderrCapture. Used
	// internally by executeCommandPipeline (via WithMetadataOutputCapture) to
	// scope the exec-metadata parser's input to only the final plan/apply/deploy
	// subprocess invocation, while StdoutCapture/StderrCapture's buffers keep
	// accumulating the whole pipeline's output for other consumers (e.g. CI
	// job-summary hooks) that legitimately need it (FR-006f, research.md
	// Decision 32).
	ExecMetadataStdoutCapture io.Writer
	ExecMetadataStderrCapture io.Writer

	// MetricsCallback, when set, is invoked once after the subprocess exits
	// with the subprocess tree's collected resource-usage metrics (nil-safe:
	// only called when a non-nil result was collected). Lets a caller (e.g.
	// executeMainTerraformCommand) capture this specific shell command's
	// subprocess-tree metrics for combining with atmos's own self-usage, for
	// both the local per-command display and the exec-metadata sync upload.
	MetricsCallback func(*metricsprocess.ProcessMetrics)

	// Interrupt selects how the subprocess reacts when Atmos receives SIGINT or SIGTERM.
	// The zero value terminates it; process.InterruptGraceful lets it stop on its own.
	Interrupt process.InterruptPolicy
}

ExecutionOptions holds optional configuration for shell command execution.

type GraphExecutionOptions added in v1.222.0

type GraphExecutionOptions struct {
	Provider      ComponentProvider
	AtmosConfig   *schema.AtmosConfiguration
	Info          *schema.ConfigAndStacksInfo
	Stacks        map[string]any
	ComponentType string
	SubCommand    string
	Flags         map[string]any
	Selection     *GraphSelection
	ReverseOrder  bool
}

type GraphNodeSkipObserver added in v1.229.0

type GraphNodeSkipObserver interface {
	OnGraphNodeSkipped(node *dependency.Node)
}

GraphNodeSkipObserver is implemented by providers that need to record graph nodes skipped after execution stops before reaching them.

type GraphSelection added in v1.222.0

type GraphSelection struct {
	NodeIDs             []string
	IncludeDependencies bool
	IncludeDependents   bool
}

type MetadataResult

type MetadataResult struct {
	Fields        map[string]any
	BaseComponent string
	Abstract      bool
	Enabled       bool
	Locked        bool
}

MetadataResult contains the effective metadata and component identity flags.

func ProcessMetadata

func ProcessMetadata(component string, componentSection map[string]any) MetadataResult

ProcessMetadata resolves the base component and abstract, enabled, and locked flags. The metadata.component field takes precedence over component; self references have no base.

type OnErrorMode

type OnErrorMode string
const (
	OnErrorStrict OnErrorMode = "strict"
	OnErrorWarn   OnErrorMode = "warn"
)

type Resolver added in v1.201.0

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

Resolver handles component path resolution and validation.

func NewResolver added in v1.201.0

func NewResolver(stackLoader StackLoader) *Resolver

NewResolver creates a new component resolver with the given stack loader.

func (*Resolver) ResolveComponentFromPath added in v1.201.0

func (r *Resolver) ResolveComponentFromPath(
	atmosConfig *schema.AtmosConfiguration,
	path string,
	stack string,
	expectedComponentType string,
) (string, error)

ResolveComponentFromPath resolves a filesystem path to a component name and validates it exists in the stack.

This function: 1. Extracts component type and name from the filesystem path 2. Verifies the component type matches the expected type 3. Validates the component exists in the specified stack configuration (if stack is provided)

Parameters:

  • atmosConfig: Atmos configuration
  • path: Filesystem path (can be ".", relative, or absolute)
  • stack: Stack name to validate against (empty string to skip stack validation)
  • expectedComponentType: Expected component type ("terraform", "helmfile", "packer")

Returns:

  • Component name as it appears in stack configuration (e.g., "vpc/security-group")
  • Error if path cannot be resolved or component doesn't exist in stack

func (*Resolver) ResolveComponentFromPathWithoutTypeCheck added in v1.201.0

func (r *Resolver) ResolveComponentFromPathWithoutTypeCheck(
	atmosConfig *schema.AtmosConfiguration,
	path string,
	stack string,
) (string, error)

ResolveComponentFromPathWithoutTypeCheck resolves a filesystem path to a component name without validating component type.

func (*Resolver) ResolveComponentFromPathWithoutValidation added in v1.201.0

func (r *Resolver) ResolveComponentFromPathWithoutValidation(
	atmosConfig *schema.AtmosConfiguration,
	path string,
	expectedComponentType string,
) (string, error)

ResolveComponentFromPathWithoutValidation resolves a filesystem path to a component name without stack validation.

This function extracts the component name from a filesystem path without validating it exists in a stack. It's used during command-line argument parsing to convert path-based component arguments (like ".") into component names. Stack validation happens later in ProcessStacks() to avoid duplicate work.

Parameters:

  • atmosConfig: Atmos configuration
  • path: Filesystem path (can be ".", relative, or absolute)
  • expectedComponentType: Expected component type ("terraform", "helmfile", "packer")

Returns:

  • Component name extracted from path (e.g., "vpc/security-group" from "/path/to/components/terraform/vpc/security-group")
  • Error if path cannot be resolved or component type doesn't match

type StackComponentDeferredContexts

type StackComponentDeferredContexts map[string]map[string]ComponentDeferredContexts

StackComponentDeferredContexts holds, for a single stack, every component's ComponentDeferredContexts keyed by [componentType]component (e.g. ["terraform"]["vpc"]). It is the shape ProcessStackConfig produces per stack.

type StackLoader added in v1.201.0

type StackLoader interface {
	FindStacksMap(atmosConfig *schema.AtmosConfiguration, ignoreMissingFiles bool) (
		map[string]any,
		map[string]map[string]any,
		error,
	)
}

StackLoader is an interface for loading stack configurations. This allows the component package to avoid depending on internal/exec.

Directories

Path Synopsis
aws
cloudformation/manifest
Package manifest validates stack manifest sections that are specific to aws/cloudformation components.
Package manifest validates stack manifest sections that are specific to aws/cloudformation components.
Package configuration composes alternate configuration formats with built-in component engines.
Package configuration composes alternate configuration formats with built-in component engines.
imagesummary
Package imagesummary reports container image summaries to CI.
Package imagesummary reports container image summaries to CI.
imagesummary/imagesummarytest
Package imagesummarytest provides a CI harness for tests of container image reporting.
Package imagesummarytest provides a CI harness for tests of container image reporting.
Package emulator implements the `emulator` component kind: a stack-scoped, long-running cloud-API emulator container (Floci, MiniStack, k3s, OpenBao, …).
Package emulator implements the `emulator` component kind: a stack-scoped, long-running cloud-API emulator container (Floci, MiniStack, k3s, OpenBao, …).
Package execution applies provider-evaluated hooks and extra arguments to Terraform commands.
Package execution applies provider-evaluated hooks and extra arguments to Terraform commands.
Package provideroptions declares, registers, and resolves the typed options a configuration provider adds to `atmos terraform` commands.
Package provideroptions declares, registers, and resolves the typed options a configuration provider adds to `atmos terraform` commands.
Package terraform implements the Terraform component provider and runtime.
Package terraform implements the Terraform component provider and runtime.
Package terragruntexec runs a Terragrunt unit through a pinned `terragrunt` executable.
Package terragruntexec runs a Terragrunt unit through a pinned `terragrunt` executable.
Package typedetect decides which component type a component name belongs to when the caller did not name the type explicitly.
Package typedetect decides which component type a component name belongs to when the caller did not name the type explicitly.

Jump to

Keyboard shortcuts

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