Documentation
¶
Overview ¶
Package common provide base components for implementing runners.
Index ¶
- Variables
- type DependencyCycleError
- type DependencyNotFoundWhileCrossLinkingError
- type ForceLogLevelHook
- type InfiniteRecursionError
- type LogEntriesDropperFormatter
- type Option
- type ProcessingUnitDependencyError
- type ProcessingUnitError
- type Stack
- type StackRunner
- type Unit
- func (unit *Unit) FindUnitInPath(targetDirs []string) bool
- func (unit *Unit) FlushOutput() error
- func (unit *Unit) OutputFile(l log.Logger, opts *options.TerragruntOptions) string
- func (unit *Unit) OutputJSONFile(l log.Logger, opts *options.TerragruntOptions) string
- func (unit *Unit) PlanFile(l log.Logger, opts *options.TerragruntOptions) string
- func (unit *Unit) String() string
- type UnitRunner
- type UnitStatus
- type UnitWriter
- type Units
- type UnitsMap
- type UnrecognizedDependencyError
Constants ¶
This section is empty.
Variables ¶
var ErrNoUnitsFound = errors.New("could not find any subfolders with Terragrunt configuration files")
Functions ¶
This section is empty.
Types ¶
type DependencyCycleError ¶
type DependencyCycleError []string
func (DependencyCycleError) Error ¶
func (err DependencyCycleError) Error() string
type DependencyNotFoundWhileCrossLinkingError ¶
func (DependencyNotFoundWhileCrossLinkingError) Error ¶
func (err DependencyNotFoundWhileCrossLinkingError) Error() string
type ForceLogLevelHook ¶
type ForceLogLevelHook struct {
// contains filtered or unexported fields
}
ForceLogLevelHook is a log hook which can change log level for messages which contains specific substrings
func NewForceLogLevelHook ¶
func NewForceLogLevelHook(forcedLevel log.Level) *ForceLogLevelHook
NewForceLogLevelHook creates default log reduction hook
func (*ForceLogLevelHook) Fire ¶
func (hook *ForceLogLevelHook) Fire(entry *logrus.Entry) error
Fire implements logrus.Hook.Fire()
func (*ForceLogLevelHook) Levels ¶
func (hook *ForceLogLevelHook) Levels() []logrus.Level
Levels implements logrus.Hook.Levels()
type InfiniteRecursionError ¶
func (InfiniteRecursionError) Error ¶
func (err InfiniteRecursionError) Error() string
type LogEntriesDropperFormatter ¶
type LogEntriesDropperFormatter struct {
// contains filtered or unexported fields
}
LogEntriesDropperFormatter is a custom formatter which will ignore log entries which has lower level than preconfigured in logger
type Option ¶
type Option func(StackRunner)
Option is a function that modifies a Stack.
func WithChildTerragruntConfig ¶
func WithChildTerragruntConfig(config *config.TerragruntConfig) Option
WithChildTerragruntConfig sets the TerragruntConfig on any Stack implementation.
func WithParseOptions ¶
WithParseOptions sets the parserOptions on any Stack implementation.
func WithReport ¶
type ProcessingUnitDependencyError ¶
func (ProcessingUnitDependencyError) Error ¶
func (err ProcessingUnitDependencyError) Error() string
func (ProcessingUnitDependencyError) ExitStatus ¶
func (err ProcessingUnitDependencyError) ExitStatus() (int, error)
func (ProcessingUnitDependencyError) Unwrap ¶
func (err ProcessingUnitDependencyError) Unwrap() error
type ProcessingUnitError ¶
type ProcessingUnitError struct {
UnderlyingError error
UnitPath string
HowThisUnitWasFound string
}
func (ProcessingUnitError) Error ¶
func (err ProcessingUnitError) Error() string
func (ProcessingUnitError) Unwrap ¶
func (err ProcessingUnitError) Unwrap() error
type Stack ¶
type Stack struct {
Report *report.Report
TerragruntOptions *options.TerragruntOptions
ChildTerragruntConfig *config.TerragruntConfig
Units Units
ParserOptions []hclparse.Option
}
Stack represents a stack of units that you can "spin up" or "spin down"
func (*Stack) FindUnitByPath ¶
FindUnitByPath finds a unit in the stack by its path
type StackRunner ¶
type StackRunner interface {
// Run - Execute all units in the stack according to the specified Terraform command and options.
Run(ctx context.Context, l log.Logger, opts *options.TerragruntOptions) error
// LogUnitDeployOrder Log the order in which units will be deployed for the given Terraform command.
LogUnitDeployOrder(l log.Logger, terraformCommand string) error
// JSONUnitDeployOrder Return the deployment order of units as a JSON string for the specified Terraform command.
JSONUnitDeployOrder(terraformCommand string) (string, error)
// ListStackDependentUnits Build and return a map of each unit to the list of units that depend on it.
ListStackDependentUnits() map[string][]string
// GetStack Retrieve the underlying Stack object managed by this runner.
GetStack() *Stack
// SetTerragruntConfig Set the child Terragrunt configuration for the stack.
SetTerragruntConfig(config *config.TerragruntConfig)
// SetParseOptions Set the parser options used for HCL parsing in the stack.
SetParseOptions(parserOptions []hclparse.Option)
// SetReport Attach a report object to the stack for collecting run data and summaries.
SetReport(report *report.Report)
}
StackRunner is the abstraction for running stack of units.
type Unit ¶
type Unit struct {
TerragruntOptions *options.TerragruntOptions
Logger log.Logger
Path string
Dependencies Units
Config config.TerragruntConfig
AssumeAlreadyApplied bool
FlagExcluded bool
}
Unit represents a single module (i.e. folder with Terraform templates), including the Terragrunt configuration for that module and the list of other modules that this module depends on
func (*Unit) FindUnitInPath ¶
FindUnitInPath returns true if a unit is located under one of the target directories
func (*Unit) FlushOutput ¶
FlushOutput flushes buffer data to the output writer.
func (*Unit) OutputFile ¶
OutputFile - return plan file location, if output folder is set
func (*Unit) OutputJSONFile ¶
OutputJSONFile - return plan JSON file location, if JSON output folder is set
type UnitRunner ¶
type UnitRunner struct {
Err error
Unit *Unit
Status UnitStatus
}
UnitRunner handles the logic for running a single unit.
func NewUnitRunner ¶
func NewUnitRunner(unit *Unit) *UnitRunner
func (*UnitRunner) Run ¶
func (runner *UnitRunner) Run(ctx context.Context, opts *options.TerragruntOptions, r *report.Report) error
Run a unit right now by executing the runTerragrunt command of its TerragruntOptions field.
type UnitStatus ¶
type UnitStatus int
UnitStatus represents the status of a unit that we are trying to apply or destroy as part of the run --all apply or run --all destroy command
const ( Waiting UnitStatus = iota Running Finished )
type UnitWriter ¶
type UnitWriter struct {
// contains filtered or unexported fields
}
UnitWriter represents a Writer with data buffering. We should avoid outputting data directly to the output out, since when units run in parallel, the output data may be mixed with each other, thereby spoiling each other's results.
func NewUnitWriter ¶
func NewUnitWriter(out io.Writer) *UnitWriter
NewUnitWriter returns a new UnitWriter instance.
func (*UnitWriter) Flush ¶
func (writer *UnitWriter) Flush() error
Flush flushes buffer data to the `out` writer.
type Units ¶
type Units []*Unit
func (Units) CheckForCycles ¶
CheckForCycles checks for dependency cycles in the given list of units and return an error if one is found.
func (Units) WriteDot ¶
WriteDot is used to emit a GraphViz compatible definition for a directed graph. It can be used to dump a .dot file. This is a similar implementation to terraform's digraph https://github.com/hashicorp/terraform/blob/v1.5.7/internal/dag/dag.go adding some styling to units that are excluded from the execution in *-all commands
type UnitsMap ¶
func (UnitsMap) CrossLinkDependencies ¶
func (unitsMap UnitsMap) CrossLinkDependencies(canonicalTerragruntConfigPaths []string) (Units, error)
CrossLinkDependencies Go through each unit in the given map and cross-link its dependencies to the other units in that same map. If a dependency is referenced that is not in the given map, return an error.
func (UnitsMap) FindByPath ¶
FindByPath returns the unit that matches the given path, or nil if no such unit exists in the map.
func (UnitsMap) MergeMaps ¶
MergeMaps the given external dependencies into the given map of units if those dependencies aren't already in the units map
func (UnitsMap) SortedKeys ¶
SortedKeys Return the keys for the given map in sorted order. This is used to ensure we always iterate over maps of units in a consistent order (Go does not guarantee iteration order for maps, and usually makes it random)
type UnrecognizedDependencyError ¶
type UnrecognizedDependencyError struct {
UnitPath string
DependencyPath string
TerragruntConfigPaths []string
}
func (UnrecognizedDependencyError) Error ¶
func (err UnrecognizedDependencyError) Error() string