variables

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEnv

func AddEnv(envVars []string, key, value string) []string

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

func ParseKeyValue(env string) (string, string)

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 NewCollection

func NewCollection() *Collection

NewCollection returns a new collection.

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

func NewConstant(value string) Variable

NewConstant creates a new constant build arg.

func NewConstantEnvVar

func NewConstantEnvVar(value string) Variable

NewConstantEnvVar cretes a new constant env var.

func NewVariable

func NewVariable(state llb.State, targetInput dedup.TargetInput, argIndex int) Variable

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

func (v Variable) ConstantValue() string

ConstantValue returns the value of the constant build arg.

func (Variable) IsConstant

func (v Variable) IsConstant() bool

IsConstant returns whether this build arg is constant.

func (Variable) IsEnvVar

func (v Variable) IsEnvVar() bool

IsEnvVar returns whether the variable is an env var.

func (Variable) VariableState

func (v Variable) VariableState() llb.State

VariableState returns the state that holds a file containing the expression result of the build arg.

Jump to

Keyboard shortcuts

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