component

package
v0.93.13 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 5 Imported by: 0

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

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.

func (Components) Sort

func (c Components) Sort() Components

Sort sorts the Components by path.

type DiscoveryContext

type DiscoveryContext struct {
	Cmd  string
	Args []string
}

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 NewStack added in v0.92.1

func NewStack(path string) *Stack

NewStack creates a new Stack component with the given path.

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

func (s *Stack) AddDependency(dependency Component)

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

func (s *Stack) AddDependent(dependent Component)

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) External added in v0.92.1

func (s *Stack) External() bool

External returns whether the component is external.

func (*Stack) Kind added in v0.92.1

func (s *Stack) Kind() Kind

Kind returns the kind of component (always Stack for Stack).

func (*Stack) Path added in v0.92.1

func (s *Stack) Path() string

Path returns the path to the component.

func (*Stack) Reading added in v0.92.1

func (s *Stack) Reading() []string

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) SetPath added in v0.92.1

func (s *Stack) SetPath(path string)

SetPath sets the path to the component.

func (*Stack) SetReading added in v0.92.1

func (s *Stack) SetReading(files ...string)

SetReading sets the list of files being read by this component.

func (*Stack) Sources added in v0.93.6

func (s *Stack) Sources() []string

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 NewUnit added in v0.92.1

func NewUnit(path string) *Unit

NewUnit creates a new Unit component with the given path.

func (*Unit) AddDependency added in v0.92.1

func (u *Unit) AddDependency(dependency Component)

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

func (u *Unit) AddDependent(dependent Component)

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) External added in v0.92.1

func (u *Unit) External() bool

External returns whether the component is external.

func (*Unit) Kind added in v0.92.1

func (u *Unit) Kind() Kind

Kind returns the kind of component (always Unit for Unit).

func (*Unit) Path added in v0.92.1

func (u *Unit) Path() string

Path returns the path to the component.

func (*Unit) Reading added in v0.92.1

func (u *Unit) Reading() []string

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) SetPath added in v0.92.1

func (u *Unit) SetPath(path string)

SetPath sets the path to the component.

func (*Unit) SetReading added in v0.92.1

func (u *Unit) SetReading(files ...string)

SetReading sets the list of files being read by this component.

func (*Unit) Sources added in v0.93.6

func (u *Unit) Sources() []string

Sources returns the list of sources for 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

func (u *Unit) WithReading(files ...string) *Unit

WithReading appends a file to the list of files being read by this component. Useful for constructing components with all files read at once.

Jump to

Keyboard shortcuts

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