env

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: MPL-2.0 Imports: 7 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"

	// 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"

	// AddrPrefix is the prefix for passing both dynamic and static port
	// allocations to tasks.
	// E.g$NOMAD_ADDR_http=127.0.0.1:80
	AddrPrefix = "NOMAD_ADDR_"

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

	// PortPrefix is the prefix for passing the port allocation to a task.
	PortPrefix = "NOMAD_PORT_"

	// HostPortPrefix is the prefix for passing the host port when a portmap 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 TaskEnvironment

type TaskEnvironment struct {
	Env              map[string]string
	TaskMeta         map[string]string
	TaskGroupMeta    map[string]string
	JobMeta          map[string]string
	AllocDir         string
	TaskDir          string
	SecretsDir       string
	CpuLimit         int
	MemLimit         int
	TaskName         string
	AllocIndex       int
	AllocId          string
	AllocName        string
	Node             *structs.Node
	Networks         []*structs.NetworkResource
	PortMap          map[string]int
	VaultToken       string
	InjectVaultToken bool
	JobName          string

	// taskEnv is the variables that will be set in the tasks environment
	TaskEnv map[string]string

	// nodeValues is the values that are allowed for interprolation from the
	// node.
	NodeValues map[string]string
}

TaskEnvironment is used to expose information to a task via environment variables and provide interpolation of Nomad variables.

func NewTaskEnvironment

func NewTaskEnvironment(node *structs.Node) *TaskEnvironment

func (*TaskEnvironment) AppendEnvvars

func (t *TaskEnvironment) AppendEnvvars(m map[string]string) *TaskEnvironment

Appends the given environment variables.

func (*TaskEnvironment) AppendHostEnvvars added in v0.3.2

func (t *TaskEnvironment) AppendHostEnvvars(filter []string) *TaskEnvironment

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

func (*TaskEnvironment) Build

func (t *TaskEnvironment) Build() *TaskEnvironment

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

func (*TaskEnvironment) ClearAlloc added in v0.3.1

func (t *TaskEnvironment) ClearAlloc(alloc *structs.Allocation) *TaskEnvironment

Helper method for clearing all fields from an allocation.

func (*TaskEnvironment) ClearAllocDir

func (t *TaskEnvironment) ClearAllocDir() *TaskEnvironment

func (*TaskEnvironment) ClearAllocId added in v0.3.1

func (t *TaskEnvironment) ClearAllocId() *TaskEnvironment

func (*TaskEnvironment) ClearAllocIndex added in v0.3.1

func (t *TaskEnvironment) ClearAllocIndex() *TaskEnvironment

func (*TaskEnvironment) ClearAllocName added in v0.3.1

func (t *TaskEnvironment) ClearAllocName() *TaskEnvironment

func (*TaskEnvironment) ClearCpuLimit

func (t *TaskEnvironment) ClearCpuLimit() *TaskEnvironment

func (*TaskEnvironment) ClearEnvvars

func (t *TaskEnvironment) ClearEnvvars() *TaskEnvironment

func (*TaskEnvironment) ClearJobMeta added in v0.3.2

func (t *TaskEnvironment) ClearJobMeta() *TaskEnvironment

func (*TaskEnvironment) ClearJobName added in v0.5.0

func (t *TaskEnvironment) ClearJobName() *TaskEnvironment

func (*TaskEnvironment) ClearMemLimit

func (t *TaskEnvironment) ClearMemLimit() *TaskEnvironment

func (*TaskEnvironment) ClearSecretsDir added in v0.5.0

func (t *TaskEnvironment) ClearSecretsDir() *TaskEnvironment

func (*TaskEnvironment) ClearTaskGroupMeta added in v0.3.2

func (t *TaskEnvironment) ClearTaskGroupMeta() *TaskEnvironment

func (*TaskEnvironment) ClearTaskLocalDir

func (t *TaskEnvironment) ClearTaskLocalDir() *TaskEnvironment

func (*TaskEnvironment) ClearTaskMeta added in v0.3.2

func (t *TaskEnvironment) ClearTaskMeta() *TaskEnvironment

func (*TaskEnvironment) ClearTaskName added in v0.3.1

func (t *TaskEnvironment) ClearTaskName() *TaskEnvironment

func (*TaskEnvironment) ClearVaultToken added in v0.5.0

func (t *TaskEnvironment) ClearVaultToken() *TaskEnvironment

func (*TaskEnvironment) EnvList

func (t *TaskEnvironment) EnvList() []string

EnvList returns a list of strings with NAME=value pairs.

func (*TaskEnvironment) EnvMap

func (t *TaskEnvironment) EnvMap() map[string]string

EnvMap returns a copy of the tasks environment variables.

func (*TaskEnvironment) ParseAndReplace

func (t *TaskEnvironment) 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 (*TaskEnvironment) ReplaceEnv

func (t *TaskEnvironment) 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.

func (*TaskEnvironment) SetAlloc added in v0.3.1

func (t *TaskEnvironment) SetAlloc(alloc *structs.Allocation) *TaskEnvironment

Helper method for setting all fields from an allocation.

func (*TaskEnvironment) SetAllocDir

func (t *TaskEnvironment) SetAllocDir(dir string) *TaskEnvironment

Builder methods to build the TaskEnvironment

func (*TaskEnvironment) SetAllocId added in v0.3.1

func (t *TaskEnvironment) SetAllocId(id string) *TaskEnvironment

func (*TaskEnvironment) SetAllocIndex added in v0.3.1

func (t *TaskEnvironment) SetAllocIndex(index int) *TaskEnvironment

func (*TaskEnvironment) SetAllocName added in v0.3.1

func (t *TaskEnvironment) SetAllocName(name string) *TaskEnvironment

func (*TaskEnvironment) SetCpuLimit

func (t *TaskEnvironment) SetCpuLimit(limit int) *TaskEnvironment

func (*TaskEnvironment) SetEnvvars

func (t *TaskEnvironment) SetEnvvars(m map[string]string) *TaskEnvironment

func (*TaskEnvironment) SetJobMeta added in v0.3.2

func (t *TaskEnvironment) SetJobMeta(m map[string]string) *TaskEnvironment

func (*TaskEnvironment) SetJobName added in v0.5.0

func (t *TaskEnvironment) SetJobName(name string) *TaskEnvironment

func (*TaskEnvironment) SetMemLimit

func (t *TaskEnvironment) SetMemLimit(limit int) *TaskEnvironment

func (*TaskEnvironment) SetNetworks

func (t *TaskEnvironment) SetNetworks(networks []*structs.NetworkResource) *TaskEnvironment

func (*TaskEnvironment) SetPortMap

func (t *TaskEnvironment) SetPortMap(portMap map[string]int) *TaskEnvironment

func (*TaskEnvironment) SetSecretsDir added in v0.5.0

func (t *TaskEnvironment) SetSecretsDir(dir string) *TaskEnvironment

func (*TaskEnvironment) SetTaskGroupMeta added in v0.3.2

func (t *TaskEnvironment) SetTaskGroupMeta(m map[string]string) *TaskEnvironment

func (*TaskEnvironment) SetTaskLocalDir

func (t *TaskEnvironment) SetTaskLocalDir(dir string) *TaskEnvironment

func (*TaskEnvironment) SetTaskMeta added in v0.3.2

func (t *TaskEnvironment) SetTaskMeta(m map[string]string) *TaskEnvironment

Takes a map of meta values to be passed to the task. The keys are capatilized when the environent variable is set.

func (*TaskEnvironment) SetTaskName added in v0.3.1

func (t *TaskEnvironment) SetTaskName(name string) *TaskEnvironment

func (*TaskEnvironment) SetVaultToken added in v0.5.0

func (t *TaskEnvironment) SetVaultToken(token string, inject bool) *TaskEnvironment

Jump to

Keyboard shortcuts

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