Documentation
¶
Index ¶
- Constants
- func Count() int
- func IsExplicitComponentPath(component string) bool
- func ListProviders() map[string][]ComponentProvider
- func ListTypes() []string
- func Register(provider ComponentProvider) error
- func Reset()
- type ComponentInfo
- type ComponentProvider
- type ComponentRegistry
- type ExecutionContext
- type Resolver
- func (r *Resolver) ResolveComponentFromPath(atmosConfig *schema.AtmosConfiguration, path string, stack string, ...) (string, error)
- func (r *Resolver) ResolveComponentFromPathWithoutTypeCheck(atmosConfig *schema.AtmosConfiguration, path string, stack string) (string, error)
- func (r *Resolver) ResolveComponentFromPathWithoutValidation(atmosConfig *schema.AtmosConfiguration, path string, ...) (string, error)
- type StackLoader
Constants ¶
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 IsExplicitComponentPath ¶ added in v1.201.0
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 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 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.
Types ¶
type ComponentInfo ¶ added in v1.196.0
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 ExecutionContext ¶ added in v1.196.0
type ExecutionContext struct {
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 provides all necessary context for component execution.
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 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.