env

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AllocDir is the environment variable with the path to the alloc directory
	// that is shared across tasks within a task group.
	AllocDir = "NOMAD_ALLOC_DIR"

	// TaskLocalDir is the environment variable with the path to the tasks local
	// directory where it can store data that is persisted to the alloc is
	// removed.
	TaskLocalDir = "NOMAD_TASK_DIR"

	// SecretsDir is the environment variable with the path to the tasks secret
	// directory where it can store sensitive data.
	SecretsDir = "NOMAD_SECRETS_DIR"

	// MemLimit is the environment variable with the tasks memory limit in MBs.
	MemLimit = "NOMAD_MEMORY_LIMIT"

	// CpuLimit is the environment variable with the tasks CPU limit in MHz.
	CpuLimit = "NOMAD_CPU_LIMIT"

	// AllocID is the environment variable for passing the allocation ID.
	AllocID = "NOMAD_ALLOC_ID"

	// AllocName is the environment variable for passing the allocation name.
	AllocName = "NOMAD_ALLOC_NAME"

	// TaskName is the environment variable for passing the task name.
	TaskName = "NOMAD_TASK_NAME"

	// GroupName is the environment variable for passing the task group name.
	GroupName = "NOMAD_GROUP_NAME"

	// JobName is the environment variable for passing the job name.
	JobName = "NOMAD_JOB_NAME"

	// AllocIndex is the environment variable for passing the allocation index.
	AllocIndex = "NOMAD_ALLOC_INDEX"

	// Datacenter is the environment variable for passing the datacenter in which the alloc is running.
	Datacenter = "NOMAD_DC"

	// Region is the environment variable for passing the region in which the alloc is running.
	Region = "NOMAD_REGION"

	// AddrPrefix is the prefix for passing both dynamic and static port
	// allocations to tasks.
	// E.g $NOMAD_ADDR_http=127.0.0.1:80
	//
	// The ip:port are always the host's.
	AddrPrefix = "NOMAD_ADDR_"

	// IpPrefix is the prefix for passing the host IP of a port allocation
	// to a task.
	IpPrefix = "NOMAD_IP_"

	// PortPrefix is the prefix for passing the port allocation to a task.
	// It will be the task's port if a port map is specified. Task's should
	// bind to this port.
	PortPrefix = "NOMAD_PORT_"

	// HostPortPrefix is the prefix for passing the host port when a port
	// map is specified.
	HostPortPrefix = "NOMAD_HOST_PORT_"

	// MetaPrefix is the prefix for passing task meta data.
	MetaPrefix = "NOMAD_META_"

	// VaultToken is the environment variable for passing the Vault token
	VaultToken = "VAULT_TOKEN"
)

A set of environment variables that are exported by each driver.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder added in v0.6.0

type Builder struct {
	// contains filtered or unexported fields
}

Builder is used to build task environment's and is safe for concurrent use.

func NewBuilder added in v0.6.0

func NewBuilder(node *structs.Node, alloc *structs.Allocation, task *structs.Task, region string) *Builder

NewBuilder creates a new task environment builder.

func NewEmptyBuilder added in v0.6.0

func NewEmptyBuilder() *Builder

NewEmptyBuilder creates a new environment builder.

func (*Builder) Build added in v0.6.0

func (b *Builder) Build() *TaskEnv

Build must be called after all the tasks environment values have been set.

func (*Builder) SetAllocDir added in v0.6.0

func (b *Builder) SetAllocDir(dir string) *Builder

func (*Builder) SetDriverNetwork added in v0.6.0

func (b *Builder) SetDriverNetwork(n *cstructs.DriverNetwork) *Builder

SetDriverNetwork defined by the driver.

func (*Builder) SetHostEnvvars added in v0.6.0

func (b *Builder) SetHostEnvvars(filter []string) *Builder

SetHostEnvvars adds the host environment variables to the tasks. The filter parameter can be use to filter host environment from entering the tasks.

func (*Builder) SetSecretsDir added in v0.6.0

func (b *Builder) SetSecretsDir(dir string) *Builder

func (*Builder) SetTaskLocalDir added in v0.6.0

func (b *Builder) SetTaskLocalDir(dir string) *Builder

func (*Builder) SetTemplateEnv added in v0.6.0

func (b *Builder) SetTemplateEnv(m map[string]string) *Builder

func (*Builder) SetVaultToken added in v0.6.0

func (b *Builder) SetVaultToken(token string, inject bool) *Builder

func (*Builder) UpdateTask added in v0.6.0

func (b *Builder) UpdateTask(alloc *structs.Allocation, task *structs.Task) *Builder

Update task updates the environment based on a new alloc and task.

type TaskEnv added in v0.6.0

type TaskEnv struct {
	// NodeAttrs is the map of node attributes for interpolation
	NodeAttrs map[string]string

	// EnvMap is the map of environment variables
	EnvMap map[string]string
	// contains filtered or unexported fields
}

TaskEnv is a task's environment as well as node attribute's for interpolation.

func NewTaskEnv added in v0.6.0

func NewTaskEnv(env, node map[string]string) *TaskEnv

NewTaskEnv creates a new task environment with the given environment and node attribute maps.

func (*TaskEnv) All added in v0.6.0

func (t *TaskEnv) All() map[string]string

All of the task's environment variables and the node's attributes in a single map.

func (*TaskEnv) List added in v0.6.0

func (t *TaskEnv) List() []string

List returns the task's environment as a slice of NAME=value pair strings.

func (*TaskEnv) Map added in v0.6.0

func (t *TaskEnv) Map() map[string]string

Map of the task's environment variables.

func (*TaskEnv) ParseAndReplace added in v0.6.0

func (t *TaskEnv) ParseAndReplace(args []string) []string

ParseAndReplace takes the user supplied args replaces any instance of an environment variable or Nomad variable in the args with the actual value.

func (*TaskEnv) ReplaceEnv added in v0.6.0

func (t *TaskEnv) ReplaceEnv(arg string) string

ReplaceEnv takes an arg and replaces all occurrences of environment variables and Nomad variables. If the variable is found in the passed map it is replaced, otherwise the original string is returned.

Jump to

Keyboard shortcuts

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