env

package
v0.19.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildEnvIncludelist = []string{
	"CNB_STACK_ID",
	"HOSTNAME",
	"HOME",
	"HTTPS_PROXY",
	"https_proxy",
	"HTTP_PROXY",
	"http_proxy",
	"NO_PROXY",
	"no_proxy",
}

BuildEnvIncludelist are env vars that, if set in the lifecycle's execution environment - either in a builder or by the platform, are passed-through to buildpack executables

View Source
var LaunchEnvExcludelist = []string{
	"CNB_LAYERS_DIR",
	"CNB_APP_DIR",
	"CNB_PROCESS_TYPE",
	"CNB_PLATFORM_API",
	"CNB_DEPRECATION_MODE",
}
View Source
var POSIXBuildEnv = map[string][]string{
	"bin": {
		"PATH",
	},
	"lib": {
		"LD_LIBRARY_PATH",
		"LIBRARY_PATH",
	},
	"include": {
		"CPATH",
	},
	"pkgconfig": {
		"PKG_CONFIG_PATH",
	},
}
View Source
var POSIXLaunchEnv = map[string][]string{
	"bin": {"PATH"},
	"lib": {"LD_LIBRARY_PATH"},
}

Functions

This section is empty.

Types

type ActionType added in v0.10.0

type ActionType string
const (
	ActionTypePrepend     ActionType = "prepend"
	ActionTypeAppend      ActionType = "append"
	ActionTypeOverride    ActionType = "override"
	ActionTypeDefault     ActionType = "default"
	ActionTypePrependPath ActionType = ""
)

func DefaultActionType added in v0.10.0

func DefaultActionType(_ *api.Version) ActionType

DefaultActionType returns the default action to perform for an unsuffixed env file as specified for the given buildpack API

type Env

type Env struct {
	// RootDirMap maps directories in a posix root filesystem to a slice of environment variables that
	RootDirMap map[string][]string
	Vars       *Vars
}

Env is used to modify and return environment variables

func NewBuildEnv

func NewBuildEnv(environ []string) *Env

NewBuildEnv returns a build-time Env from the given environment.

Keys in the BuildEnvIncludelist will be added to the Environment.

func NewLaunchEnv

func NewLaunchEnv(environ []string, processDir string, lifecycleDir string) *Env

NewLaunchEnv returns an Env for process launch from the given environ.

Keys in the LaunchEnvExcludelist shall be removed. processDir will be removed from the beginning of PATH if present.

func (*Env) AddEnvDir

func (p *Env) AddEnvDir(envDir string, defaultAction ActionType) error

AddEnvDir modified the Env given a directory containing env files. For each file in the envDir, if the file has a period delimited suffix, the action matching the given suffix will be performed. If the file has no suffix, the default action will be performed. If the suffix does not match a known type, AddEnvDir will ignore the file.

func (*Env) AddRootDir

func (p *Env) AddRootDir(dir string) error

AddRootDir modifies the environment given a root dir. If the root dir contains a directory that matches a key in the Env RooDirMap, the absolute path to the keyed directory will be prepended to all the associated environment variables using the OS path list separator as a delimiter.

func (*Env) Get added in v0.7.1

func (p *Env) Get(k string) string

Get returns the value for the given key

func (*Env) List

func (p *Env) List() []string

List returns the environment

func (*Env) Set added in v0.10.0

func (p *Env) Set(name, v string)

Set sets the environment variable with the given name to the given value.

func (*Env) WithOverrides added in v0.16.0

func (p *Env) WithOverrides(platformDir string, baseConfigDir string) (output []string, err error)

WithOverrides returns the environment after applying modifications from the given platform dir and build config If platformDir is non-empty, for each file in the platformDir, if the name of the file does not match an environment variable name in the RootDirMap, the given variable will be set to the contents of the file. If the name does match an environment variable name in the RootDirMap, the contents of the file will be prepended to the environment variable value using the OS path list separator as a delimiter. If baseConfigDir is non-empty, for each file in the envDir, if the file has a period delimited suffix, the action matching the given suffix will be performed. If the file has no suffix, the default action will be performed. If the suffix does not match a known type, AddEnvDir will ignore the file.

type Vars added in v0.9.0

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

func NewVars added in v0.9.0

func NewVars(vars map[string]string, ignoreCase bool) *Vars

func (*Vars) Get added in v0.9.0

func (s *Vars) Get(key string) string

func (*Vars) List added in v0.9.0

func (s *Vars) List() []string

func (*Vars) Set added in v0.9.0

func (s *Vars) Set(key, value string)

Jump to

Keyboard shortcuts

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