Documentation ¶
Index ¶
- func AddEnv(envVars []string, key, value string) []string
- func ParseKeyValue(env string) (string, string)
- type Collection
- func (c *Collection) AddActive(name string, variable Variable, override, global bool) Variable
- func (c *Collection) AsMap() map[string]string
- func (c *Collection) Expand(word string) string
- func (c *Collection) Get(name string) (Variable, bool, bool)
- func (c *Collection) SortedActiveVariables() []string
- func (c *Collection) SortedOverridingVariables() []string
- func (c *Collection) WithBuiltinBuildArgs(target domain.Target, gitMeta *buildcontext.GitMetadata) *Collection
- func (c *Collection) WithOnlyGlobals() *Collection
- func (c *Collection) WithParseBuildArgs(args []string, pncvf ProcessNonConstantVariableFunc, propagate bool) (*Collection, map[string]bool, error)
- func (c *Collection) WithResetEnvVars() *Collection
- type ProcessNonConstantVariableFunc
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEnv ¶
AddEnv takes in a slice of env vars in key-value format and a new key-value string to it, taking care of possible overrides.
func ParseKeyValue ¶
ParseKeyValue parses a key-value type into its parts.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection is a collection of variables.
func ParseCommandLineBuildArgs ¶
func ParseCommandLineBuildArgs(args []string, dotEnvMap map[string]string) (*Collection, error)
ParseCommandLineBuildArgs parses a slice of constant build args and returns a new collection.
func (*Collection) AddActive ¶
func (c *Collection) AddActive(name string, variable Variable, override, global bool) Variable
AddActive adds and activates a variable in the collection. It returns the effective variable. The effective variable may be different from the one being added, when override is false.
func (*Collection) AsMap ¶
func (c *Collection) AsMap() map[string]string
AsMap returns the constant variables (active and inactive) as a map.
func (*Collection) Expand ¶
func (c *Collection) Expand(word string) string
Expand expands constant build args within the given word.
func (*Collection) Get ¶
func (c *Collection) Get(name string) (Variable, bool, bool)
Get returns a variable by name.
func (*Collection) SortedActiveVariables ¶
func (c *Collection) SortedActiveVariables() []string
SortedActiveVariables returns the active variable names in a sorted slice.
func (*Collection) SortedOverridingVariables ¶
func (c *Collection) SortedOverridingVariables() []string
SortedOverridingVariables returns the overriding variable names in a sorted slice.
func (*Collection) WithBuiltinBuildArgs ¶
func (c *Collection) WithBuiltinBuildArgs(target domain.Target, gitMeta *buildcontext.GitMetadata) *Collection
WithBuiltinBuildArgs returns a new collection containing the current variables together with builtin args. This operation does not modify the current collection.
func (*Collection) WithOnlyGlobals ¶
func (c *Collection) WithOnlyGlobals() *Collection
WithOnlyGlobals returns a copy of the current collection, keeping only the global variables.
func (*Collection) WithParseBuildArgs ¶
func (c *Collection) WithParseBuildArgs(args []string, pncvf ProcessNonConstantVariableFunc, propagate bool) (*Collection, map[string]bool, error)
WithParseBuildArgs takes in a slice of build args to be parsed and returns another collection containing the current build args, together with the newly parsed build args. This operation does not modify the current collection.
func (*Collection) WithResetEnvVars ¶
func (c *Collection) WithResetEnvVars() *Collection
WithResetEnvVars returns a copy of the current collection with all env vars removed. This operation does not modify the current collection.
type ProcessNonConstantVariableFunc ¶
type ProcessNonConstantVariableFunc func(name string, expression string) (argState llb.State, ti dedup.TargetInput, argIndex int, err error)
ProcessNonConstantVariableFunc is a function which takes in an expression and turns it into a state, target intput and arg index.
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable is an object representing a build arg or an env var.
func NewConstant ¶
NewConstant creates a new constant build arg.
func NewConstantEnvVar ¶
NewConstantEnvVar cretes a new constant env var.
func NewVariable ¶
NewVariable creates a new variable build arg.
func (Variable) BuildArgInput ¶
func (v Variable) BuildArgInput(name string, defaultValue string) dedup.BuildArgInput
BuildArgInput returns the BuildArgInput for this variable.
func (Variable) ConstantValue ¶
ConstantValue returns the value of the constant build arg.
func (Variable) IsConstant ¶
IsConstant returns whether this build arg is constant.
func (Variable) VariableState ¶
VariableState returns the state that holds a file containing the expression result of the build arg.