Documentation
¶
Index ¶
- Constants
- func Clean(atmosConfig *schema.AtmosConfiguration, opts CleanOptions) error
- func CleanAllWorkdirs(atmosConfig *schema.AtmosConfiguration) error
- func CleanWorkdir(atmosConfig *schema.AtmosConfiguration, component, stack string) error
- func ProvisionWorkdir(ctx context.Context, atmosConfig *schema.AtmosConfiguration, ...) error
- type CleanOptions
- type DefaultFileSystem
- func (f *DefaultFileSystem) CopyDir(src, dst string) error
- func (f *DefaultFileSystem) Exists(path string) bool
- func (f *DefaultFileSystem) MkdirAll(path string, perm fs.FileMode) error
- func (f *DefaultFileSystem) ReadFile(path string) ([]byte, error)
- func (f *DefaultFileSystem) RemoveAll(path string) error
- func (f *DefaultFileSystem) Stat(path string) (fs.FileInfo, error)
- func (f *DefaultFileSystem) Walk(root string, fn fs.WalkDirFunc) error
- func (f *DefaultFileSystem) WriteFile(path string, data []byte, perm fs.FileMode) error
- type DefaultHasher
- type DefaultPathFilter
- type FileSystem
- type Hasher
- type PathFilter
- type Service
- type SourceType
- type WorkdirConfig
- type WorkdirMetadata
Constants ¶
const ( // DirPermissions is the default permission for created directories (rwxr-xr-x). DirPermissions = 0o755 // FilePermissionsSecure is the secure permission for sensitive files (rw-------). FilePermissionsSecure = 0o600 // FilePermissionsStandard is the standard permission for regular files (rw-r--r--). FilePermissionsStandard = 0o644 )
File permission constants.
const ( // ComponentKey is the key used to access component name in configuration. ComponentKey = "component" // WorkdirPathKey is the key used to store/retrieve the workdir path in component configuration. // This is set by the workdir provisioner and checked by terraform execution to override // the component path with the workdir path. WorkdirPathKey = "_workdir_path" )
String literal constants.
const HookEventBeforeTerraformInit = provisioner.HookEvent("before.terraform.init")
HookEventBeforeTerraformInit is the hook event for before terraform init.
const WorkdirMetadataFile = ".workdir-metadata.json"
WorkdirMetadataFile is the name of the metadata file in each workdir.
const WorkdirPath = ".workdir"
WorkdirPath returns the standard workdir directory name.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
func Clean(atmosConfig *schema.AtmosConfiguration, opts CleanOptions) error
Clean performs cleanup based on the provided options.
func CleanAllWorkdirs ¶
func CleanAllWorkdirs(atmosConfig *schema.AtmosConfiguration) error
CleanAllWorkdirs removes all working directories in the project.
func CleanWorkdir ¶
func CleanWorkdir(atmosConfig *schema.AtmosConfiguration, component, stack string) error
CleanWorkdir removes the working directory for a specific component in a stack. The workdir name follows the stack-component naming convention (e.g., "dev-vpc").
func ProvisionWorkdir ¶
func ProvisionWorkdir( ctx context.Context, atmosConfig *schema.AtmosConfiguration, componentConfig map[string]any, authContext *schema.AuthContext, ) error
ProvisionWorkdir creates an isolated working directory and populates it with component files. This is the main provisioner function registered with the provisioner registry.
Activation rules: - Runs if provision.workdir.enabled: true (explicit opt-in for local components) - Does nothing otherwise (terraform runs in original component directory).
Types ¶
type CleanOptions ¶
type CleanOptions struct {
// Component is the specific component to clean (empty for all).
Component string
// Stack is the stack name (required when Component is specified).
Stack string
// All cleans all workdirs in the project.
All bool
}
CleanOptions configures what to clean.
type DefaultFileSystem ¶
type DefaultFileSystem struct{}
DefaultFileSystem is the default implementation of the FileSystem interface.
func NewDefaultFileSystem ¶
func NewDefaultFileSystem() *DefaultFileSystem
NewDefaultFileSystem creates a new default file system implementation.
func (*DefaultFileSystem) CopyDir ¶
func (f *DefaultFileSystem) CopyDir(src, dst string) error
CopyDir recursively copies a directory from src to dst.
func (*DefaultFileSystem) Exists ¶
func (f *DefaultFileSystem) Exists(path string) bool
Exists checks if a path exists.
func (*DefaultFileSystem) MkdirAll ¶
func (f *DefaultFileSystem) MkdirAll(path string, perm fs.FileMode) error
MkdirAll creates a directory along with any necessary parents.
func (*DefaultFileSystem) ReadFile ¶
func (f *DefaultFileSystem) ReadFile(path string) ([]byte, error)
ReadFile reads the contents of a file.
func (*DefaultFileSystem) RemoveAll ¶
func (f *DefaultFileSystem) RemoveAll(path string) error
RemoveAll removes path and any children it contains.
func (*DefaultFileSystem) Stat ¶
func (f *DefaultFileSystem) Stat(path string) (fs.FileInfo, error)
Stat returns file info for the given path.
func (*DefaultFileSystem) Walk ¶
func (f *DefaultFileSystem) Walk(root string, fn fs.WalkDirFunc) error
Walk walks the file tree rooted at root, calling fn for each file or directory.
type DefaultHasher ¶
type DefaultHasher struct{}
DefaultHasher is the default implementation of the Hasher interface.
func NewDefaultHasher ¶
func NewDefaultHasher() *DefaultHasher
NewDefaultHasher creates a new default hasher implementation.
type DefaultPathFilter ¶
type DefaultPathFilter struct{}
DefaultPathFilter is the default implementation of the PathFilter interface.
func NewDefaultPathFilter ¶
func NewDefaultPathFilter() *DefaultPathFilter
NewDefaultPathFilter creates a new default path filter implementation.
type FileSystem ¶
type FileSystem interface {
// MkdirAll creates a directory along with any necessary parents.
MkdirAll(path string, perm fs.FileMode) error
// RemoveAll removes path and any children it contains.
RemoveAll(path string) error
// Exists checks if a path exists.
Exists(path string) bool
// ReadFile reads the contents of a file.
ReadFile(path string) ([]byte, error)
// WriteFile writes data to a file with the given permissions.
WriteFile(path string, data []byte, perm fs.FileMode) error
// CopyDir recursively copies a directory from src to dst.
CopyDir(src, dst string) error
// Walk walks the file tree rooted at root, calling fn for each file or directory.
Walk(root string, fn fs.WalkDirFunc) error
// Stat returns file info for the given path.
Stat(path string) (fs.FileInfo, error)
}
FileSystem abstracts file system operations for testability.
type Hasher ¶
type Hasher interface {
// HashDir computes a hash of all files in a directory.
HashDir(path string) (string, error)
// HashFile computes a hash of a single file.
HashFile(path string) (string, error)
}
Hasher computes content hashes for change detection.
type PathFilter ¶
type PathFilter interface {
// Match returns true if the path should be included.
Match(path string, includedPaths, excludedPaths []string) (bool, error)
}
PathFilter filters paths based on include/exclude patterns.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service coordinates workdir provisioning operations. The workdir provisioner copies local component files to an isolated working directory.
func NewService ¶
func NewService() *Service
NewService creates a new workdir service with default implementations.
func NewServiceWithDeps ¶
func NewServiceWithDeps(fs FileSystem, hasher Hasher) *Service
NewServiceWithDeps creates a new workdir service with injected dependencies.
type SourceType ¶
type SourceType string
SourceType indicates the type of component source.
const ( // SourceTypeLocal indicates the component source is a local path. SourceTypeLocal SourceType = "local" )
type WorkdirConfig ¶
type WorkdirConfig struct {
// Enabled controls whether workdir provisioning is active.
// Defaults to false; set provision.workdir.enabled: true to enable.
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty" mapstructure:"enabled"`
}
WorkdirConfig holds configuration for the workdir provisioner.
type WorkdirMetadata ¶
type WorkdirMetadata struct {
// Component is the component name.
Component string `json:"component"`
// Stack is the stack name (optional, for stack-specific workdirs).
Stack string `json:"stack,omitempty"`
// SourceType indicates the source type (always "local" for workdir provisioner).
SourceType SourceType `json:"source_type"`
// Source is the original component source path.
Source string `json:"source,omitempty"`
// CreatedAt is when the workdir was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the workdir was last updated.
UpdatedAt time.Time `json:"updated_at"`
// ContentHash is a hash of the source content for change detection.
ContentHash string `json:"content_hash,omitempty"`
}
WorkdirMetadata stores metadata about a working directory. This is persisted to .workdir-metadata.json in each workdir.