Documentation
¶
Overview ¶
Package component provides types for representing discovered Terragrunt components.
These include units and stacks.
This package contains only data types and their associated methods, with no discovery logic. It exists separately from the discovery package to allow other packages (like filter) to depend on these types without creating circular dependencies.
Index ¶
- type Component
- type Components
- type DiscoveryContext
- type Kind
- type Stack
- func (s *Stack) AddDependency(dependency Component)
- func (s *Stack) AddDependent(dependent Component)
- func (s *Stack) Config() *config.StackConfig
- func (s *Stack) Dependencies() Components
- func (s *Stack) Dependents() Components
- func (s *Stack) DiscoveryContext() *DiscoveryContext
- func (s *Stack) External() bool
- func (s *Stack) Kind() Kind
- func (s *Stack) Path() string
- func (s *Stack) Reading() []string
- func (s *Stack) SetDiscoveryContext(ctx *DiscoveryContext)
- func (s *Stack) SetExternal()
- func (s *Stack) SetPath(path string)
- func (s *Stack) SetReading(files ...string)
- func (s *Stack) Sources() []string
- func (s *Stack) StoreConfig(cfg *config.StackConfig)
- type ThreadSafeComponents
- type Unit
- func (u *Unit) AddDependency(dependency Component)
- func (u *Unit) AddDependent(dependent Component)
- func (u *Unit) Config() *config.TerragruntConfig
- func (u *Unit) Dependencies() Components
- func (u *Unit) Dependents() Components
- func (u *Unit) DiscoveryContext() *DiscoveryContext
- func (u *Unit) External() bool
- func (u *Unit) Kind() Kind
- func (u *Unit) Path() string
- func (u *Unit) Reading() []string
- func (u *Unit) SetDiscoveryContext(ctx *DiscoveryContext)
- func (u *Unit) SetExternal()
- func (u *Unit) SetPath(path string)
- func (u *Unit) SetReading(files ...string)
- func (u *Unit) Sources() []string
- func (u *Unit) StoreConfig(cfg *config.TerragruntConfig)
- func (u *Unit) WithConfig(cfg *config.TerragruntConfig) *Unit
- func (u *Unit) WithReading(files ...string) *Unit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
Kind() Kind
Path() string
SetPath(string)
External() bool
SetExternal()
Reading() []string
SetReading(...string)
Sources() []string
DiscoveryContext() *DiscoveryContext
SetDiscoveryContext(*DiscoveryContext)
AddDependency(Component)
AddDependent(Component)
Dependencies() Components
Dependents() Components
// contains filtered or unexported methods
}
Component represents a discovered Terragrunt configuration. This interface is implemented by Unit and Stack.
type Components ¶
type Components []Component
Components is a list of discovered Terragrunt components.
func (Components) CycleCheck ¶
func (c Components) CycleCheck() (Component, error)
CycleCheck checks for cycles in the dependency graph. If a cycle is detected, it returns the first Component that is part of the cycle, and an error. If no cycle is detected, it returns nil and nil.
func (Components) Filter ¶
func (c Components) Filter(kind Kind) Components
Filter filters the Components by config type.
func (Components) FilterByPath ¶
func (c Components) FilterByPath(path string) Components
FilterByPath filters the Components by path.
func (Components) Paths ¶
func (c Components) Paths() []string
Paths returns the paths of the Components.
func (Components) RemoveByPath ¶
func (c Components) RemoveByPath(path string) Components
RemoveByPath removes the Component with the given path from the Components.
type DiscoveryContext ¶
DiscoveryContext is the context in which a Component was discovered.
It's useful to know this information, because it can help us determine how the Component should be run or enqueued later.
type Kind ¶
type Kind string
Kind is the type of Terragrunt component.
const (
StackKind Kind = "stack"
)
const (
UnitKind Kind = "unit"
)
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a discovered Terragrunt stack configuration.
func NewStackWithConfig ¶ added in v0.92.1
func NewStackWithConfig(path string, cfg *config.StackConfig) *Stack
NewStackWithConfig creates a new Stack component with the given path and config.
func (*Stack) AddDependency ¶ added in v0.92.1
AddDependency adds a dependency to the Stack and vice versa.
Using this method ensure that the dependency graph is properly maintained, making it easier to look up dependents and dependencies on a given component without the entire graph available.
func (*Stack) AddDependent ¶ added in v0.92.1
AddDependent adds a dependent to the Stack and vice versa.
Using this method ensure that the dependency graph is properly maintained, making it easier to look up dependents and dependencies on a given component without the entire graph available.
func (*Stack) Config ¶ added in v0.92.1
func (s *Stack) Config() *config.StackConfig
Config returns the parsed Stack configuration for this stack.
func (*Stack) Dependencies ¶ added in v0.92.1
func (s *Stack) Dependencies() Components
Dependencies returns the dependencies of the Stack.
func (*Stack) Dependents ¶ added in v0.92.1
func (s *Stack) Dependents() Components
Dependents returns the dependents of the Stack.
func (*Stack) DiscoveryContext ¶ added in v0.92.1
func (s *Stack) DiscoveryContext() *DiscoveryContext
DiscoveryContext returns the discovery context for this component.
func (*Stack) Reading ¶ added in v0.92.1
Reading returns the list of files being read by this component.
func (*Stack) SetDiscoveryContext ¶ added in v0.92.1
func (s *Stack) SetDiscoveryContext(ctx *DiscoveryContext)
SetDiscoveryContext sets the discovery context for this component.
func (*Stack) SetExternal ¶ added in v0.92.1
func (s *Stack) SetExternal()
SetExternal marks the component as external.
func (*Stack) SetReading ¶ added in v0.92.1
SetReading sets the list of files being read by this component.
func (*Stack) Sources ¶ added in v0.93.6
Sources returns the list of sources for this component.
Stacks don't support leveraging sources right now, so we just return an empty list.
func (*Stack) StoreConfig ¶ added in v0.92.1
func (s *Stack) StoreConfig(cfg *config.StackConfig)
StoreConfig stores the parsed Stack configuration for this stack.
type ThreadSafeComponents ¶ added in v0.93.4
type ThreadSafeComponents struct {
// contains filtered or unexported fields
}
ThreadSafeComponents provides thread-safe access to a Components slice. It uses an RWMutex to allow concurrent reads and serialized writes.
func NewThreadSafeComponents ¶ added in v0.93.4
func NewThreadSafeComponents(components Components) *ThreadSafeComponents
NewThreadSafeComponents creates a new ThreadSafeComponents instance with the given components.
func (*ThreadSafeComponents) EnsureComponent ¶ added in v0.93.4
func (tsc *ThreadSafeComponents) EnsureComponent(c Component) (Component, bool)
EnsureComponent adds a component to the components list if it's not already present. This method is TOCTOU-safe (Time-Of-Check-Time-Of-Use) by using a double-check pattern.
It returns the component if it was added, and a boolean indicating if it was added.
func (*ThreadSafeComponents) FindByPath ¶ added in v0.93.4
func (tsc *ThreadSafeComponents) FindByPath(path string) Component
FindByPath searches for a component by its path and returns it if found, otherwise returns nil.
func (*ThreadSafeComponents) Len ¶ added in v0.93.4
func (tsc *ThreadSafeComponents) Len() int
Len returns the number of components in the components slice.
func (*ThreadSafeComponents) ToComponents ¶ added in v0.93.4
func (tsc *ThreadSafeComponents) ToComponents() Components
ToComponents returns a copy of the components slice.
type Unit ¶
type Unit struct {
// contains filtered or unexported fields
}
Unit represents a discovered Terragrunt unit configuration.
func (*Unit) AddDependency ¶ added in v0.92.1
AddDependency adds a dependency to the Unit and vice versa.
Using this method ensure that the dependency graph is properly maintained, making it easier to look up dependents and dependencies on a given component without the entire graph available.
func (*Unit) AddDependent ¶ added in v0.92.1
AddDependent adds a dependent to the Unit and vice versa.
Using this method ensure that the dependency graph is properly maintained, making it easier to look up dependents and dependencies on a given component without the entire graph available.
func (*Unit) Config ¶ added in v0.92.1
func (u *Unit) Config() *config.TerragruntConfig
Config returns the parsed Terragrunt configuration for this unit.
func (*Unit) Dependencies ¶ added in v0.92.1
func (u *Unit) Dependencies() Components
Dependencies returns the dependencies of the Unit.
func (*Unit) Dependents ¶ added in v0.92.1
func (u *Unit) Dependents() Components
Dependents returns the dependents of the Unit.
func (*Unit) DiscoveryContext ¶ added in v0.92.1
func (u *Unit) DiscoveryContext() *DiscoveryContext
DiscoveryContext returns the discovery context for this component.
func (*Unit) Reading ¶ added in v0.92.1
Reading returns the list of files being read by this component.
func (*Unit) SetDiscoveryContext ¶ added in v0.92.1
func (u *Unit) SetDiscoveryContext(ctx *DiscoveryContext)
SetDiscoveryContext sets the discovery context for this component.
func (*Unit) SetExternal ¶ added in v0.92.1
func (u *Unit) SetExternal()
SetExternal marks the component as external.
func (*Unit) SetReading ¶ added in v0.92.1
SetReading sets the list of files being read by this component.
func (*Unit) StoreConfig ¶ added in v0.92.1
func (u *Unit) StoreConfig(cfg *config.TerragruntConfig)
StoreConfig stores the parsed Terragrunt configuration for this unit.
func (*Unit) WithConfig ¶ added in v0.92.1
func (u *Unit) WithConfig(cfg *config.TerragruntConfig) *Unit
WithConfig adds configuration to a Unit component.
func (*Unit) WithReading ¶ added in v0.92.1
WithReading appends a file to the list of files being read by this component. Useful for constructing components with all files read at once.