run

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package run provides facilities to run commands inside Terramate context and ordering.

Index

Constants

View Source
const (
	// ErrLoadingGlobals indicates that an error happened while loading globals.
	ErrLoadingGlobals errors.Kind = "loading globals to evaluate terramate.config.run.env configuration"

	// ErrEval indicates that an error happened while evaluating one of the
	// terramate.config.run.env attributes.
	ErrEval errors.Kind = "evaluating terramate.config.run.env attribute"

	// ErrInvalidEnvVarType indicates the env var attribute
	// has an invalid type.
	ErrInvalidEnvVarType errors.Kind = "invalid environment variable type"
)
View Source
const ErrNotFound errors.Kind = "executable file not found in $PATH"

ErrNotFound is the error resulting if a path search failed to find an executable file.

Variables

This section is empty.

Functions

func BuildDAG

func BuildDAG(
	d *dag.DAG[*config.Stack],
	root *config.Root,
	s *config.Stack,
	descendantsName string,
	getDescendants func(config.Stack) []string,
	ancestorsName string,
	getAncestors func(config.Stack) []string,
	visited dag.Visited,
) error

BuildDAG builds a run order DAG for the given stack.

func BuildDAGFromStacks added in v0.5.0

func BuildDAGFromStacks[S ~[]E, E any](root *config.Root, items S, getStack func(E) *config.Stack) (*dag.DAG[E], string, error)

BuildDAGFromStacks computes the final, reduced dag for the given list of stacks.

func LookPath added in v0.4.2

func LookPath(file string, environ []string) (string, error)

LookPath searches for an executable named file in the directories named by the PATH environment variable. If file contains a slash, it is tried directly and the PATH is not consulted. Otherwise, on success, the result is an absolute path.

In older versions of Go, LookPath could return a path relative to the current directory. As of Go 1.19, LookPath will instead return that path along with an error satisfying errors.Is(err, ErrDot). See the package documentation for more details.

func Sort

func Sort[S ~[]E, E any](root *config.Root, items S, getStack func(E) *config.Stack) (string, error)

Sort computes the final execution order for the given list of stacks. In the case of multiple possible orders, it returns the lexicographic sorted path.

Types

type EnvVars

type EnvVars []string

EnvVars represents a set of environment variables to be used when running commands. Each string follows the same format used on os.Environ and can be used to set env on exec.Cmd.

func LoadEnv

func LoadEnv(root *config.Root, st *config.Stack) (EnvVars, error)

LoadEnv will load environment variables to be exported when running any command inside the given stack. The order of the env vars is guaranteed to be the same and is ordered lexicographically. All defined `terramate.config.run.env` definitions from the provided stack dir up to the root of the project are collected, and env definitions closer to the stack have precedence over parent definitions.

Directories

Path Synopsis
Package dag provides the Directed-Acyclic-Graph (DAG) primitives required by Terramate.
Package dag provides the Directed-Acyclic-Graph (DAG) primitives required by Terramate.

Jump to

Keyboard shortcuts

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