From a5b8b7a1c017614623f19cae350ee4c835cc4b6d Mon Sep 17 00:00:00 2001 From: TomSweeneyRedHat Date: Sat, 23 May 2020 14:46:19 -0400 Subject: [PATCH] Bump imagebuilder for ARG fix Bump imagebuilder to the latest upstream to get the ARG fix from https://github.com/openshift/imagebuilder/pull/159 Also touched up the install.md with vendoring from a commitId so I won't have to run all around looking for it next time. Fixes: https://github.com/containers/buildah/issues/2192 and probably https://github.com/containers/buildah/issues/2345 Signed-off-by: TomSweeneyRedHat --- go.mod | 2 +- go.sum | 4 +-- install.md | 4 ++- .../openshift/imagebuilder/dispatchers.go | 31 +++++++++++++++++-- vendor/modules.txt | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 2d50e1e488d..e2cbb868f6c 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/opencontainers/runtime-spec v1.0.3-0.20200520003142-237cc4f519e2 github.com/opencontainers/runtime-tools v0.9.0 github.com/opencontainers/selinux v1.5.1 - github.com/openshift/imagebuilder v1.1.4 + github.com/openshift/imagebuilder v1.1.5-0.20200523124444-e30756856853 github.com/pkg/errors v0.9.1 github.com/seccomp/containers-golang v0.4.1 github.com/seccomp/libseccomp-golang v0.9.1 diff --git a/go.sum b/go.sum index c66b8256bd1..ade834bbf30 100644 --- a/go.sum +++ b/go.sum @@ -233,8 +233,8 @@ github.com/opencontainers/selinux v1.3.0/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOl github.com/opencontainers/selinux v1.4.0/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g= github.com/opencontainers/selinux v1.5.1 h1:jskKwSMFYqyTrHEuJgQoUlTcId0av64S6EWObrIfn5Y= github.com/opencontainers/selinux v1.5.1/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g= -github.com/openshift/imagebuilder v1.1.4 h1:LUg8aTjyXMtlDx6IbtvaqofFGZ6aYqe+VIeATE735LM= -github.com/openshift/imagebuilder v1.1.4/go.mod h1:9aJRczxCH0mvT6XQ+5STAQaPWz7OsWcU5/mRkt8IWeo= +github.com/openshift/imagebuilder v1.1.5-0.20200523124444-e30756856853 h1:1mIltsV4UiP7Bv2E5B7IL1HlhWRzCHUUFIhb9NsqPv0= +github.com/openshift/imagebuilder v1.1.5-0.20200523124444-e30756856853/go.mod h1:9aJRczxCH0mvT6XQ+5STAQaPWz7OsWcU5/mRkt8IWeo= github.com/ostreedev/ostree-go v0.0.0-20190702140239-759a8c1ac913 h1:TnbXhKzrTOyuvWrjI8W6pcoI9XPbLHFXCdN2dtUw7Rw= github.com/ostreedev/ostree-go v0.0.0-20190702140239-759a8c1ac913/go.mod h1:J6OG6YJVEWopen4avK3VNQSnALmmjvniMmni/YFYAwc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= diff --git a/install.md b/install.md index 8dd429bc842..c29ff1eb817 100644 --- a/install.md +++ b/install.md @@ -470,7 +470,9 @@ cat /etc/containers/policy.json Buildah uses Go Modules for vendoring purposes. If you need to update or add a vendored package into Buildah, please follow this procedure: * Enter into your sandbox `src/github.com/containers/buildah` and ensure that the GOPATH variable is set to the directory prior as noted above. * `export GO111MODULE=on` - * Assuming you want to 'bump' the `github.com/containers/storage` package to version 1.12.13, use this command: `go get github.com/containers/storage@v1.12.13` + * `go get` the needed version: + * Assuming you want to 'bump' the `github.com/containers/storage` package to version 1.12.13, use this command: `go get github.com/containers/storage@v1.12.13` + * Assumming that you want to 'bump' the `github.com/containers/storage` package to a particular commit, use this command: `go get github.com/containers/storage@e307568568533c4afccdf7b56df7b4493e4e9a7b` * `make vendor-in-container` * `make` * `make install` diff --git a/vendor/github.com/openshift/imagebuilder/dispatchers.go b/vendor/github.com/openshift/imagebuilder/dispatchers.go index 1d77a193b06..2c62cf96a32 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) 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) for _, a := range flagArgs { - arg, err := ProcessWord(a, b.Env) + arg, err := ProcessWord(a, userArgs) if err != nil { return err } @@ -649,3 +651,28 @@ func errTooManyArguments(command string) error { func errNotJSON(command string) error { return fmt.Errorf("%s requires the arguments to be in JSON form", command) } + +// 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(b *Builder) (userArgs []string) { + + userArgs = b.Env + envMap := make(map[string]string) + for _, envVal := range b.Env { + val := strings.Split(envVal, "=") + if len(val) > 1 { + envMap[val[0]] = val[1] + } + } + + for key, value := range b.Args { + if _, ok := envMap[key]; ok { + continue + } + userArgs = append(userArgs, key+"="+value) + } + return userArgs +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d61d62ab080..a73f8c7c7d2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -342,7 +342,7 @@ github.com/opencontainers/runtime-tools/validate github.com/opencontainers/selinux/go-selinux github.com/opencontainers/selinux/go-selinux/label github.com/opencontainers/selinux/pkg/pwalk -# github.com/openshift/imagebuilder v1.1.4 +# github.com/openshift/imagebuilder v1.1.5-0.20200523124444-e30756856853 github.com/openshift/imagebuilder github.com/openshift/imagebuilder/dockerfile/command github.com/openshift/imagebuilder/dockerfile/parser