Documentation ¶
Overview ¶
Package config provides high level Terramate configuration facilities.
Index ¶
- Constants
- func IsStack(root *Root, dir string) bool
- func ReverseStacks(stacks List[*SortableStack])
- func Skip(name string) bool
- func ValidateWatchPaths(rootdir string, stackpath string, paths []string) (project.Paths, error)
- type Assert
- type DirElem
- type Input
- type Inputs
- type List
- type Output
- type Outputs
- type Root
- func (root *Root) ChangeDetectionGitConfig() (*hcl.GitChangeDetectionConfig, bool)
- func (root *Root) HasExperiment(name string) bool
- func (root *Root) HasTerragruntStacks() bool
- func (root *Root) HostDir() string
- func (root *Root) IsTargetsEnabled() bool
- func (root *Root) IsTerragruntChangeDetectionEnabled() (ret bool)
- func (root *Root) LoadSubTree(cfgdir project.Path) error
- func (root *Root) Lookup(path project.Path) (node *Tree, found bool)
- func (root *Root) Lookup2(path project.Path) (node *Tree, skipped bool, found bool)
- func (root *Root) Runtime() project.Runtime
- func (root *Root) Stacks() project.Paths
- func (root *Root) StacksByPaths(base project.Path, relpaths ...string) List[*Tree]
- func (root *Root) StacksByTagsFilters(filters []string) (project.Paths, error)
- func (root *Root) TerragruntEnabledOption() hcl.TerragruntChangeDetectionEnabledOption
- func (root *Root) Tree() *Tree
- type Script
- type ScriptCmd
- type ScriptCmdOptions
- type ScriptJob
- type SortableStack
- type Stack
- func (s *Stack) AppendBefore(path string)
- func (s *Stack) HostDir(root *Root) string
- func (s *Stack) PathBase() string
- func (s *Stack) RelPath() string
- func (s *Stack) RelPathToRoot(root *Root) string
- func (s *Stack) RuntimeValues(root *Root) map[string]cty.Value
- func (s *Stack) Sortable() *SortableStack
- func (s *Stack) String() string
- func (s Stack) Validate() error
- func (s Stack) ValidateSets() error
- func (s Stack) ValidateTags() error
- type Tree
- func (tree *Tree) AsList() List[*Tree]
- func (tree *Tree) Dir() project.Path
- func (tree *Tree) HostDir() string
- func (tree *Tree) IsEmptyConfig() bool
- func (tree *Tree) IsInsideStack() bool
- func (tree *Tree) IsStack() bool
- func (tree *Tree) NonEmptyGlobalsParent() *Tree
- func (tree *Tree) Root() *Root
- func (tree *Tree) RootDir() string
- func (tree *Tree) RootTree() *Tree
- func (tree *Tree) SharingBackend(name string) (hcl.SharingBackend, bool)
- func (tree *Tree) Stack() (*Stack, error)
- func (tree *Tree) Stacks() List[*Tree]
Constants ¶
const ( ErrScriptSchema errors.Kind = "script config has an invalid schema" ErrScriptInvalidType errors.Kind = "invalid type for script field" ErrScriptInvalidTypeCommand errors.Kind = "invalid type for script.job.command" ErrScriptInvalidTypeCommands errors.Kind = "invalid type for script.job.commands" ErrScriptEmptyCmds errors.Kind = "job command or commands evaluated to empty list" ErrScriptInvalidCmdOptions errors.Kind = "invalid options for script command" )
Errors for indicating invalid script schema
const ( // ErrStackValidation indicates an error when validating the stack fields. ErrStackValidation errors.Kind = "validating stack fields" // ErrStackDuplicatedID indicates that two or more stacks have the same ID. ErrStackDuplicatedID errors.Kind = "duplicated ID found on stacks" // ErrStackInvalidWatch indicates the stack.watch attribute contains invalid values. ErrStackInvalidWatch errors.Kind = "invalid stack.watch attribute" // ErrStackInvalidTag indicates the stack.tags is invalid. ErrStackInvalidTag errors.Kind = "invalid stack.tags entry" // ErrStackInvalidWants indicates the stack.wants is invalid. ErrStackInvalidWants errors.Kind = "invalid stack.wants entry" // ErrStackInvalidWantedBy indicates the stack.wanted_by is invalid. ErrStackInvalidWantedBy errors.Kind = "invalid stack.wanted_by entry" )
const ( // ErrSchema indicates that the configuration has an invalid schema. ErrSchema errors.Kind = "config has an invalid schema" )
const MaxScriptDescRunes = 1000
MaxScriptDescRunes defines the maximum number of runes allowed for a script description.
const MaxScriptNameRunes = 128
MaxScriptNameRunes defines the maximum number of runes allowed for a script name.
Variables ¶
This section is empty.
Functions ¶
func ReverseStacks ¶
func ReverseStacks(stacks List[*SortableStack])
ReverseStacks reverses the given stacks slice.
Types ¶
type Assert ¶
Assert represents evaluated assert block configuration.
func EvalAssert ¶
EvalAssert evaluates a given assert configuration and returns its evaluated form.
type DirElem ¶
DirElem represents a node which is represented by a directory. Eg.: stack, config, etc.
type Input ¶ added in v0.10.1
type Input struct { info.Range Name string Backend string FromStackID string Sensitive *bool // contains filtered or unexported fields }
Input represents an evaluated input block
func EvalInput ¶ added in v0.10.1
EvalInput evaluates an input block using the provided evaluation context.
type List ¶
type List[T DirElem] []T
List of directory based elements which implements the sorting interface by the directory path.
func LoadAllStacks ¶
func LoadAllStacks(root *Root, cfg *Tree) (List[*SortableStack], error)
LoadAllStacks loads all stacks inside the given rootdir.
func StacksFromTrees ¶
func StacksFromTrees(trees List[*Tree]) (List[*SortableStack], error)
StacksFromTrees converts a List[*Tree] into a List[*Stack].
type Output ¶ added in v0.10.1
type Output struct { info.Range Name string Description string Backend string Value hhcl.Expression Sensitive *bool }
Output represents an evaluated output block
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root is the root configuration tree. This type is just for ensure better type checking for the cases where a configuration for the root directory is expected and not from anywhere else.
func TryLoadConfig ¶
TryLoadConfig try to load the Terramate configuration tree. It looks for the the config in fromdir and all parent directories until / is reached. If the configuration is found, it returns the whole configuration tree, configpath != "" and found as true.
func (*Root) ChangeDetectionGitConfig ¶ added in v0.11.0
func (root *Root) ChangeDetectionGitConfig() (*hcl.GitChangeDetectionConfig, bool)
ChangeDetectionGitConfig returns the `terramate.config.change_detection.git` object config.
func (*Root) HasExperiment ¶ added in v0.4.4
HasExperiment returns true if the given experiment name is set.
func (*Root) HasTerragruntStacks ¶ added in v0.6.5
HasTerragruntStacks returns true if the stack loading has detected Terragrunt files.
func (*Root) IsTargetsEnabled ¶ added in v0.9.0
IsTargetsEnabled returns the configured `terramate.config.cloud.targets.enabled` option.
func (*Root) IsTerragruntChangeDetectionEnabled ¶ added in v0.6.5
IsTerragruntChangeDetectionEnabled returns true if Terragrunt change detection integration must be executed.
func (*Root) LoadSubTree ¶
LoadSubTree loads a subtree located at cfgdir into the current tree.
func (*Root) Lookup2 ¶ added in v0.10.7
Lookup2 is like Lookup but returns skipped as true if the path is not found because a parent directory was skipped.
func (*Root) Runtime ¶
Runtime returns a copy the runtime for the root terramate namespace as a cty.Value map.
func (*Root) StacksByPaths ¶
StacksByPaths returns the stacks from the provided relative paths.
func (*Root) StacksByTagsFilters ¶
StacksByTagsFilters returns the paths of all stacks matching the filters.
func (*Root) TerragruntEnabledOption ¶ added in v0.6.5
func (root *Root) TerragruntEnabledOption() hcl.TerragruntChangeDetectionEnabledOption
TerragruntEnabledOption returns the configured `terramate.config.change_detection.terragrunt.enabled` option.
type Script ¶ added in v0.4.4
type Script struct { Range info.Range Labels []string Name string Description string Jobs []ScriptJob }
Script represents an evaluated script block
type ScriptCmd ¶ added in v0.4.4
type ScriptCmd struct { Args []string Options *ScriptCmdOptions }
ScriptCmd represents an evaluated script command
type ScriptCmdOptions ¶ added in v0.4.4
type ScriptCmdOptions struct { CloudSyncDeployment bool CloudSyncDriftStatus bool CloudSyncPreview bool CloudSyncLayer preview.Layer CloudTerraformPlanFile string CloudTofuPlanFile string UseTerragrunt bool EnableSharing bool MockOnFail bool }
ScriptCmdOptions represents optional parameters for a script command
type ScriptJob ¶ added in v0.4.4
ScriptJob represents an evaluated job block
type SortableStack ¶
type SortableStack struct {
*Stack
}
SortableStack is a wrapper for the Stack which implements the DirElem type.
type Stack ¶
type Stack struct { // Dir is project's stack directory. Dir project.Path // ID of the stack. ID string // Name of the stack. Name string // Description is the description of the stack. Description string // Tags is the list of tags of the stack. // A tag Tags []string // After is a list of stack paths that must run before this stack. After []string // Before is a list of stack paths that must run after this stack. Before []string // Wants is the list of stacks that must be selected whenever this stack // is selected. Wants []string // wantedBy is the list of stacks that must select this stack // whenever they are selected. WantedBy []string // Watch is the list of files to be watched for changes. Watch project.Paths // IsChanged tells if this is a changed stack. IsChanged bool }
Stack represents an evaluated stack.
func NewStackFromHCL ¶
NewStackFromHCL creates a new stack from raw configuration cfg.
func TryLoadStack ¶
TryLoadStack tries to load a single stack from dir. It sets found as true in case the stack was successfully loaded.
func (*Stack) AppendBefore ¶
AppendBefore appends the path to the list of stacks that must run after this stack.
func (*Stack) RelPathToRoot ¶
RelPathToRoot returns the relative path from the stack to root.
func (*Stack) RuntimeValues ¶
RuntimeValues returns the runtime "terramate" namespace for the stack.
func (*Stack) Sortable ¶
func (s *Stack) Sortable() *SortableStack
Sortable returns an implementation of stack which can be sorted by config.List.
func (Stack) ValidateSets ¶
ValidateSets validate all stack set fields.
func (Stack) ValidateTags ¶
ValidateTags validates if tags are correctly used in all stack fields.
type Tree ¶
type Tree struct { // Node is the configuration of this tree node. Node hcl.Config Skipped bool // tells if this node subdirs were skipped TerramateFiles []string OtherFiles []string TmGenFiles []string // Children is a map of configuration dir names to tree nodes. Children map[string]*Tree // Parent is the parent node or nil if none. Parent *Tree // contains filtered or unexported fields }
Tree is the configuration tree. The tree maps the filesystem directories, which means each directory in the project has a tree instance even if it's empty (ie no .tm files in it).
func (*Tree) IsEmptyConfig ¶
IsEmptyConfig tells if the configuration is empty.
func (*Tree) IsInsideStack ¶ added in v0.10.6
IsInsideStack tells if current tree node is inside a parent stack.
func (*Tree) NonEmptyGlobalsParent ¶
NonEmptyGlobalsParent returns a parent configuration which has globals defined, if any.
func (*Tree) SharingBackend ¶ added in v0.10.1
func (tree *Tree) SharingBackend(name string) (hcl.SharingBackend, bool)
SharingBackend returns the backend with given name.