diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-17 16:43:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-17 16:43:06 -0400 |
commit | 7b5073b46e4ba3914ce526fa60ef91346f50f577 (patch) | |
tree | b731cc3ed3b7c407a23ea2235e65eb429925d9c7 /vendor/github.com/openshift/imagebuilder | |
parent | a76bf114d1a408cb3bbcd3c642805d1bf13b07c0 (diff) | |
parent | fde8040faabbaf6eac24a28a60631cd4b3337e91 (diff) | |
download | podman-7b5073b46e4ba3914ce526fa60ef91346f50f577.tar.gz podman-7b5073b46e4ba3914ce526fa60ef91346f50f577.tar.bz2 podman-7b5073b46e4ba3914ce526fa60ef91346f50f577.zip |
Merge pull request #6655 from TomSweeneyRedHat/dev/tsweeney/b1_15_0
Bump Buildah to v1.15.0
Diffstat (limited to 'vendor/github.com/openshift/imagebuilder')
4 files changed, 42 insertions, 6 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go index 7f2f6e482..ffc3b257f 100644 --- a/vendor/github.com/openshift/imagebuilder/builder.go +++ b/vendor/github.com/openshift/imagebuilder/builder.go @@ -332,10 +332,19 @@ func ParseFile(path string) (*parser.Node, error) { // Step creates a new step from the current state. func (b *Builder) Step() *Step { - dst := make([]string, len(b.Env)+len(b.RunConfig.Env)) - copy(dst, b.Env) + argsMap := make(map[string]string) + for _, argsVal := range b.Arguments() { + val := strings.Split(argsVal, "=") + if len(val) > 1 { + argsMap[val[0]] = val[1] + } + } + + userArgs := makeUserArgs(b.Env, argsMap) + dst := make([]string, len(userArgs)+len(b.RunConfig.Env)) + copy(dst, userArgs) dst = append(dst, b.RunConfig.Env...) - dst = append(dst, b.Arguments()...) + return &Step{Env: dst} } diff --git a/vendor/github.com/openshift/imagebuilder/dispatchers.go b/vendor/github.com/openshift/imagebuilder/dispatchers.go index 1d77a193b..3a350fbee 100644 --- a/vendor/github.com/openshift/imagebuilder/dispatchers.go +++ b/vendor/github.com/openshift/imagebuilder/dispatchers.go @@ -153,8 +153,9 @@ func add(b *Builder, args []string, attributes map[string]bool, flagArgs []strin var chown string last := len(args) - 1 dest := makeAbsolute(args[last], b.RunConfig.WorkingDir) + userArgs := makeUserArgs(b.Env, b.Args) for _, a := range flagArgs { - arg, err := ProcessWord(a, b.Env) + arg, err := ProcessWord(a, userArgs) if err != nil { return err } @@ -181,8 +182,9 @@ func dispatchCopy(b *Builder, args []string, attributes map[string]bool, flagArg dest := makeAbsolute(args[last], b.RunConfig.WorkingDir) var chown string var from string + userArgs := makeUserArgs(b.Env, b.Args) for _, a := range flagArgs { - arg, err := ProcessWord(a, b.Env) + arg, err := ProcessWord(a, userArgs) if err != nil { return err } diff --git a/vendor/github.com/openshift/imagebuilder/imagebuilder.spec b/vendor/github.com/openshift/imagebuilder/imagebuilder.spec index 07c880166..3b32403a7 100644 --- a/vendor/github.com/openshift/imagebuilder/imagebuilder.spec +++ b/vendor/github.com/openshift/imagebuilder/imagebuilder.spec @@ -12,7 +12,7 @@ # %global golang_version 1.8.1 -%{!?version: %global version 1.1-dev} +%{!?version: %global version 1.1.5} %{!?release: %global release 1} %global package_name imagebuilder %global product_name Container Image Builder diff --git a/vendor/github.com/openshift/imagebuilder/internals.go b/vendor/github.com/openshift/imagebuilder/internals.go index 3c60c7983..b652dc1c7 100644 --- a/vendor/github.com/openshift/imagebuilder/internals.go +++ b/vendor/github.com/openshift/imagebuilder/internals.go @@ -92,3 +92,28 @@ func parseOptInterval(f *flag.Flag) (time.Duration, error) { } return d, nil } + +// makeUserArgs - Package the variables from the Dockerfile defined by +// the ENV aand the ARG statements into one slice so the values +// defined by both can later be evaluated when resolving variables +// such as ${MY_USER}. If the variable is defined by both ARG and ENV +// don't include the definition of the ARG variable. +func makeUserArgs(bEnv []string, bArgs map[string]string) (userArgs []string) { + + userArgs = bEnv + envMap := make(map[string]string) + for _, envVal := range bEnv { + val := strings.Split(envVal, "=") + if len(val) > 1 { + envMap[val[0]] = val[1] + } + } + + for key, value := range bArgs { + if _, ok := envMap[key]; ok { + continue + } + userArgs = append(userArgs, key+"="+value) + } + return userArgs +} |