diff options
author | Urvashi Mohnani <umohnani@redhat.com> | 2018-11-20 20:07:17 +0000 |
---|---|---|
committer | Urvashi Mohnani <umohnani@redhat.com> | 2018-11-21 12:38:14 +0000 |
commit | bd61c779caa6eed613d7e8595f0a6892bc8fa306 (patch) | |
tree | 81430b6b933c80a1d530a898115758c19cfc33fb /vendor/github.com/openshift/imagebuilder/builder.go | |
parent | fe4f09493f41f675d24c969d1b60d1a6a45ddb9e (diff) | |
download | podman-bd61c779caa6eed613d7e8595f0a6892bc8fa306.tar.gz podman-bd61c779caa6eed613d7e8595f0a6892bc8fa306.tar.bz2 podman-bd61c779caa6eed613d7e8595f0a6892bc8fa306.zip |
Vendor in latest containers/buildah
Pulls in fix for COPY --from when using --layers
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'vendor/github.com/openshift/imagebuilder/builder.go')
-rw-r--r-- | vendor/github.com/openshift/imagebuilder/builder.go | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go index 1c1afb119..d37965df6 100644 --- a/vendor/github.com/openshift/imagebuilder/builder.go +++ b/vendor/github.com/openshift/imagebuilder/builder.go @@ -172,8 +172,11 @@ type Stage struct { Node *parser.Node } -func NewStages(node *parser.Node, b *Builder) Stages { +func NewStages(node *parser.Node, b *Builder) (Stages, error) { var stages Stages + if err := b.extractHeadingArgsFromNode(node); err != nil { + return stages, err + } for i, root := range SplitBy(node, command.From) { name, _ := extractNameFromNode(root.Children[0]) if len(name) == 0 { @@ -189,7 +192,36 @@ func NewStages(node *parser.Node, b *Builder) Stages { Node: root, }) } - return stages + return stages, nil +} + +func (b *Builder) extractHeadingArgsFromNode(node *parser.Node) error { + var args []*parser.Node + var children []*parser.Node + extract := true + for _, child := range node.Children { + if extract && child.Value == command.Arg { + args = append(args, child) + } else { + if child.Value == command.From { + extract = false + } + children = append(children, child) + } + } + + for _, c := range args { + step := b.Step() + if err := step.Resolve(c); err != nil { + return err + } + if err := b.Run(step, NoopExecutor, false); err != nil { + return err + } + } + + node.Children = children + return nil } func extractNameFromNode(node *parser.Node) (string, bool) { @@ -345,6 +377,9 @@ var ErrNoFROM = fmt.Errorf("no FROM statement found") // is set to the first From found, or left unchanged if already // set. func (b *Builder) From(node *parser.Node) (string, error) { + if err := b.extractHeadingArgsFromNode(node); err != nil { + return "", err + } children := SplitChildren(node, command.From) switch { case len(children) == 0: |