Documentation ¶
Index ¶
- Variables
- type ActionType
- type Env
- func (p *Env) AddEnvDir(envDir string, defaultAction ActionType) error
- func (p *Env) AddRootDir(dir string) error
- func (p *Env) Get(k string) string
- func (p *Env) List() []string
- func (p *Env) Set(name, v string)
- func (p *Env) WithOverrides(platformDir string, baseConfigDir string) (output []string, err error)
- type Vars
Constants ¶
This section is empty.
Variables ¶
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
var LaunchEnvExcludelist = []string{
"CNB_LAYERS_DIR",
"CNB_APP_DIR",
"CNB_PROCESS_TYPE",
"CNB_PLATFORM_API",
"CNB_DEPRECATION_MODE",
}
var POSIXBuildEnv = map[string][]string{
"bin": {
"PATH",
},
"lib": {
"LD_LIBRARY_PATH",
"LIBRARY_PATH",
},
"include": {
"CPATH",
},
"pkgconfig": {
"PKG_CONFIG_PATH",
},
}
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 ¶
NewBuildEnv returns a build-time Env from the given environment.
Keys in the BuildEnvIncludelist will be added to the Environment.
func NewLaunchEnv ¶
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 ¶
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) Set ¶ added in v0.10.0
Set sets the environment variable with the given name to the given value.
func (*Env) WithOverrides ¶ added in v0.16.0
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.