env

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

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

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

	// The tasks memory limit in MBs.
	MemLimit = "NOMAD_MEMORY_LIMIT"

	// The tasks limit in MHz.
	CpuLimit = "NOMAD_CPU_LIMIT"

	// Prefix for passing both dynamic and static port allocations to
	// tasks.
	// E.g. $NOMAD_IP_1=127.0.0.1:1 or $NOMAD_IP_http=127.0.0.1:80
	AddrPrefix = "NOMAD_ADDR_"

	// Prefix for passing the host port when a portmap is specified.
	HostPortPrefix = "NOMAD_HOST_PORT_"

	// Prefix for passing task meta data.
	MetaPrefix = "NOMAD_META_"
)

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
	Meta     map[string]string
	AllocDir string
	TaskDir  string
	CpuLimit int
	MemLimit int
	Node     *structs.Node
	Networks []*structs.NetworkResource
	PortMap  map[string]int

	// 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) Build

func (t *TaskEnvironment) Build() *TaskEnvironment

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

func (*TaskEnvironment) ClearAllocDir

func (t *TaskEnvironment) ClearAllocDir() *TaskEnvironment

func (*TaskEnvironment) ClearCpuLimit

func (t *TaskEnvironment) ClearCpuLimit() *TaskEnvironment

func (*TaskEnvironment) ClearEnvvars

func (t *TaskEnvironment) ClearEnvvars() *TaskEnvironment

func (*TaskEnvironment) ClearMemLimit

func (t *TaskEnvironment) ClearMemLimit() *TaskEnvironment

func (*TaskEnvironment) ClearMeta

func (t *TaskEnvironment) ClearMeta() *TaskEnvironment

func (*TaskEnvironment) ClearTaskLocalDir

func (t *TaskEnvironment) ClearTaskLocalDir() *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 occurences 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) SetAllocDir

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

Builder methods to build the 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) SetMemLimit

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

func (*TaskEnvironment) SetMeta

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

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

func (*TaskEnvironment) SetPortMap

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

func (*TaskEnvironment) SetTaskLocalDir

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

Jump to

Keyboard shortcuts

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