run

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MPL-2.0 Imports: 18 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 (
	// ErrFailed represents the error when the execution fails, whatever the reason.
	ErrFailed errors.Kind = "execution failed"
	// ErrCanceled represents the error when the execution was canceled.
	ErrCanceled errors.Kind = "execution canceled"
)

Variables

This section is empty.

Functions

func BuildDAG

func BuildDAG(
	d *dag.DAG,
	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 Exec

func Exec(
	root *config.Root,
	stacks config.List[*config.SortableStack],
	cmd []string,
	stdin io.Reader,
	stdout io.Writer,
	stderr io.Writer,
	continueOnError bool,
	before func(s *config.Stack, cmd string),
	after func(s *config.Stack, err error),
) error

Exec will execute the given command on the given stack list During the execution of this function the default behavior for signal handling will be changed so we can wait for the child process to exit before exiting Terramate.

If continue on error is true this function will continue to execute commands on stacks even in face of failures, returning an error.L with all errors. If continue on error is false it will return as soon as it finds an error, returning a list with a single error inside.

func Sort

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.

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