Bump github.com/containers/buildah from 1.16.4 to 1.16.5

Bumps [github.com/containers/buildah](https://github.com/containers/buildah) from 1.16.4 to 1.16.5.
- [Release notes](https://github.com/containers/buildah/releases)
- [Changelog](https://github.com/containers/buildah/blob/master/CHANGELOG.md)
- [Commits](https://github.com/containers/buildah/compare/v1.16.4...v1.16.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
dependabot-preview[bot]
2020-10-23 08:18:13 +00:00
committed by Daniel J Walsh
parent 2adc1b284d
commit 22b1d10d31
19 changed files with 152 additions and 107 deletions

View File

@ -102,5 +102,6 @@ Example of usage from OpenShift's experimental `dockerbuild` [command with mount
## Run conformance tests (very slow):
```
go test ./dockerclient/conformance_test.go -tags conformance
chmod -R go-w ./dockerclient/testdata
go test ./dockerclient/conformance_test.go -tags conformance -timeout 30m
```

View File

@ -332,20 +332,10 @@ func ParseFile(path string) (*parser.Node, error) {
// Step creates a new step from the current state.
func (b *Builder) Step() *Step {
argsMap := make(map[string]string)
for _, argsVal := range b.Arguments() {
val := strings.SplitN(argsVal, "=", 2)
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...)
return &Step{Env: dst}
// Include build arguments in the table of variables that we'll use in
// Resolve(), but override them with values from the actual
// environment in case there's any conflict.
return &Step{Env: mergeEnv(b.Arguments(), mergeEnv(b.Env, b.RunConfig.Env))}
}
// Run executes a step, transforming the current builder and
@ -473,7 +463,7 @@ func (b *Builder) FromImage(image *docker.Image, node *parser.Node) error {
SplitChildren(node, command.From)
b.RunConfig = *image.Config
b.Env = append(b.Env, b.RunConfig.Env...)
b.Env = mergeEnv(b.Env, b.RunConfig.Env)
b.RunConfig.Env = nil
// Check to see if we have a default PATH, note that windows won't
@ -573,14 +563,21 @@ var builtinAllowedBuildArgs = map[string]bool{
}
// ParseDockerIgnore returns a list of the excludes in the .dockerignore file.
// extracted from fsouza/go-dockerclient.
// extracted from fsouza/go-dockerclient and modified to drop comments and
// empty lines.
func ParseDockerignore(root string) ([]string, error) {
var excludes []string
ignore, err := ioutil.ReadFile(filepath.Join(root, ".dockerignore"))
if err != nil && !os.IsNotExist(err) {
return excludes, fmt.Errorf("error reading .dockerignore: '%s'", err)
}
return strings.Split(string(ignore), "\n"), nil
for _, e := range strings.Split(string(ignore), "\n") {
if len(e) == 0 || e[0] == '#' {
continue
}
excludes = append(excludes, e)
}
return excludes, nil
}
// ExportEnv creates an export statement for a shell that contains all of the

View File

@ -83,21 +83,9 @@ func env(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
for j := 0; j < len(args); j++ {
// name ==> args[j]
// value ==> args[j+1]
newVar := args[j] + "=" + args[j+1] + ""
gotOne := false
for i, envVar := range b.RunConfig.Env {
envParts := strings.SplitN(envVar, "=", 2)
if envParts[0] == args[j] {
b.RunConfig.Env[i] = newVar
b.Env = append([]string{newVar}, b.Env...)
gotOne = true
break
}
}
if !gotOne {
b.RunConfig.Env = append(b.RunConfig.Env, newVar)
b.Env = append([]string{newVar}, b.Env...)
}
newVar := []string{args[j] + "=" + args[j+1]}
b.RunConfig.Env = mergeEnv(b.RunConfig.Env, newVar)
b.Env = mergeEnv(b.Env, newVar)
j++
}
@ -153,7 +141,7 @@ 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)
userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env)
for _, a := range flagArgs {
arg, err := ProcessWord(a, userArgs)
if err != nil {
@ -182,7 +170,7 @@ 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)
userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env)
for _, a := range flagArgs {
arg, err := ProcessWord(a, userArgs)
if err != nil {

View File

@ -12,8 +12,8 @@ import (
"strings"
"unicode"
"github.com/openshift/imagebuilder/dockerfile/command"
"github.com/docker/docker/pkg/system"
"github.com/openshift/imagebuilder/dockerfile/command"
"github.com/pkg/errors"
)
@ -37,7 +37,7 @@ type Node struct {
Original string // original line used before parsing
Flags []string // only top Node should have this set
StartLine int // the line in the original dockerfile where the node begins
endLine int // the line in the original dockerfile where the node ends
EndLine int // the line in the original dockerfile where the node ends
}
// Dump dumps the AST defined by `node` as a list of sexps.
@ -67,7 +67,7 @@ func (node *Node) Dump() string {
func (node *Node) lines(start, end int) {
node.StartLine = start
node.endLine = end
node.EndLine = end
}
// AddChild adds a new child node, and updates line information
@ -76,7 +76,7 @@ func (node *Node) AddChild(child *Node, startLine, endLine int) {
if node.StartLine < 0 {
node.StartLine = startLine
}
node.endLine = endLine
node.EndLine = endLine
node.Children = append(node.Children, child)
}

View File

@ -12,7 +12,7 @@
#
%global golang_version 1.8.1
%{!?version: %global version 1.1.6}
%{!?version: %global version 1.1.8}
%{!?release: %global release 1}
%global package_name imagebuilder
%global product_name Container Image Builder

View File

@ -93,27 +93,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.SplitN(envVal, "=", 2)
if len(val) > 1 {
envMap[val[0]] = val[1]
}
}
for key, value := range bArgs {
if _, ok := envMap[key]; ok {
// mergeEnv merges two lists of environment variables, avoiding duplicates.
func mergeEnv(defaults, overrides []string) []string {
s := make([]string, 0, len(defaults)+len(overrides))
index := make(map[string]int)
for _, envSpec := range append(defaults, overrides...) {
envVar := strings.SplitN(envSpec, "=", 2)
if i, ok := index[envVar[0]]; ok {
s[i] = envSpec
continue
}
userArgs = append(userArgs, key+"="+value)
s = append(s, envSpec)
index[envVar[0]] = len(s) - 1
}
return userArgs
return s
}
// envMapAsSlice returns the contents of a map[string]string as a slice of keys
// and values joined with "=".
func envMapAsSlice(m map[string]string) []string {
s := make([]string, 0, len(m))
for k, v := range m {
s = append(s, k+"="+v)
}
return s
}

View File

@ -7,6 +7,7 @@ package imagebuilder
// be added by adding code to the "special ${} format processing" section
import (
"errors"
"fmt"
"strings"
"text/scanner"
@ -119,7 +120,7 @@ func (sw *shellWord) processStopOn(stopChar rune) (string, []string, error) {
if stopChar != scanner.EOF && ch == stopChar {
sw.scanner.Next()
break
return result, words.getWords(), nil
}
if fn, ok := charFuncMapping[ch]; ok {
// Call special processing func for certain chars
@ -156,6 +157,10 @@ func (sw *shellWord) processStopOn(stopChar rune) (string, []string, error) {
}
}
if stopChar != scanner.EOF {
return "", []string{}, fmt.Errorf("unexpected end of statement while looking for matching %s", string(stopChar))
}
return result, words.getWords(), nil
}
@ -168,9 +173,12 @@ func (sw *shellWord) processSingleQuote() (string, error) {
for {
ch := sw.scanner.Next()
if ch == '\'' || ch == scanner.EOF {
if ch == '\'' {
break
}
if ch == scanner.EOF {
return "", errors.New("unexpected end of statement while looking for matching single-quote")
}
result += string(ch)
}
@ -184,12 +192,15 @@ func (sw *shellWord) processDoubleQuote() (string, error) {
sw.scanner.Next()
for sw.scanner.Peek() != scanner.EOF {
for {
ch := sw.scanner.Peek()
if ch == '"' {
sw.scanner.Next()
break
}
if ch == scanner.EOF {
return "", errors.New("unexpected end of statement while looking for matching double-quote")
}
if ch == '$' {
tmp, err := sw.processDollar()
if err != nil {
@ -206,8 +217,8 @@ func (sw *shellWord) processDoubleQuote() (string, error) {
continue
}
if chNext == '"' || chNext == '$' {
// \" and \$ can be escaped, all other \'s are left as-is
if chNext == '"' || chNext == '$' || chNext == '\\' {
// \" and \$ and \\ can be escaped, all other \'s are left as-is
ch = sw.scanner.Next()
}
}