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
- type Assert
- type DirElem
- type List
- type Root
- func (root *Root) HostDir() string
- func (root *Root) LoadSubTree(cfgdir project.Path) error
- func (root *Root) Lookup(path project.Path) (*Tree, 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) Tree() *Tree
- 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) IsStack() bool
- func (tree *Tree) NonEmptyGlobalsParent() *Tree
- func (tree *Tree) Root() *Root
- func (tree *Tree) RootDir() string
- func (tree *Tree) Stacks() List[*Tree]
Constants ¶
const ( // DefaultFilename is the name of the default Terramate configuration file. DefaultFilename = "terramate.tm.hcl" // SkipFilename is the name of Terramate skip file. SkipFilename = ".tmskip" )
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" )
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 List ¶
type List[T DirElem] []T
List of directory based elements which implements the sorting interface by the directory path.
func LoadAllStacks ¶
func LoadAllStacks(cfg *Tree) (List[*SortableStack], error)
LoadAllStacks loads all stacks inside the given rootdir.
func StacksFromTrees ¶
StacksFromTrees converts a List[*Tree] into a List[*Stack].
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) LoadSubTree ¶
LoadSubTree loads a subtree located at cfgdir into the current tree.
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.
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.Path // 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 // 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 LoadTree ¶
LoadTree loads the whole hierarchical configuration from cfgdir downwards using rootdir as project root.
func (*Tree) IsEmptyConfig ¶
IsEmptyConfig tells if the configuration is empty.
func (*Tree) NonEmptyGlobalsParent ¶
NonEmptyGlobalsParent returns a parent configuration which has globals defined, if any.