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 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) WithParseBuildArgs(args []string, pncvf ProcessNonConstantVariableFunc) (*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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
ParseKeyValue parses a key-value type into its parts.
Types ¶
type Collection ¶ added in v0.2.0
type Collection struct {
// contains filtered or unexported fields
}
Collection is a collection of variables.
func NewCollection ¶ added in v0.2.0
func NewCollection() *Collection
NewCollection returns a new collection.
func ParseCommandLineBuildArgs ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (c *Collection) AddActive(name string, variable Variable, override 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 ¶ added in v0.3.0
func (c *Collection) AsMap() map[string]string
AsMap returns the constant variables (active and inactive) as a map.
func (*Collection) Expand ¶ added in v0.2.0
func (c *Collection) Expand(word string) string
Expand expands constant build args within the given word.
func (*Collection) Get ¶ added in v0.2.0
func (c *Collection) Get(name string) (Variable, bool, bool)
Get returns a variable by name.
func (*Collection) SortedActiveVariables ¶ added in v0.2.0
func (c *Collection) SortedActiveVariables() []string
SortedActiveVariables returns the active variable names in a sorted slice.
func (*Collection) SortedOverridingVariables ¶ added in v0.3.3
func (c *Collection) SortedOverridingVariables() []string
SortedOverridingVariables returns the overriding variable names in a sorted slice.
func (*Collection) WithBuiltinBuildArgs ¶ added in v0.2.0
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) WithParseBuildArgs ¶ added in v0.2.0
func (c *Collection) WithParseBuildArgs(args []string, pncvf ProcessNonConstantVariableFunc) (*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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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.