summaryrefslogtreecommitdiff
path: root/vendor/github.com/openshift
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-04-02 08:37:42 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-04-03 06:35:42 -0400
commiteb86bfc3441cbd3e0e1932cf5ed983002fc30b73 (patch)
treeb419c0c2a7b1bc2080f5ead562f51fbfc0820a07 /vendor/github.com/openshift
parentccb9e579c48141f70d016adfa9a9d4934bbdf976 (diff)
downloadpodman-eb86bfc3441cbd3e0e1932cf5ed983002fc30b73.tar.gz
podman-eb86bfc3441cbd3e0e1932cf5ed983002fc30b73.tar.bz2
podman-eb86bfc3441cbd3e0e1932cf5ed983002fc30b73.zip
Bump github.com/containers/common from 0.6.1 to 0.8.0
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.6.1 to 0.8.0. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.6.1...v0.8.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/openshift')
-rw-r--r--vendor/github.com/openshift/imagebuilder/builder.go55
-rw-r--r--vendor/github.com/openshift/imagebuilder/dispatchers.go14
2 files changed, 49 insertions, 20 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go
index 81d7b8421..7f2f6e482 100644
--- a/vendor/github.com/openshift/imagebuilder/builder.go
+++ b/vendor/github.com/openshift/imagebuilder/builder.go
@@ -209,12 +209,8 @@ func NewStages(node *parser.Node, b *Builder) (Stages, error) {
stages = append(stages, Stage{
Position: i,
Name: name,
- Builder: &Builder{
- Args: b.Args,
- AllowedArgs: b.AllowedArgs,
- Env: b.Env,
- },
- Node: root,
+ Builder: b.builderForStage(),
+ Node: root,
})
}
return stages, nil
@@ -235,17 +231,30 @@ func (b *Builder) extractHeadingArgsFromNode(node *parser.Node) error {
}
}
+ // Set children equal to everything except the leading ARG nodes
+ node.Children = children
+
+ // Use a separate builder to evaluate the heading args
+ tempBuilder := NewBuilder(b.UserArgs)
+
+ // Evaluate all the heading arg commands
for _, c := range args {
- step := b.Step()
+ step := tempBuilder.Step()
if err := step.Resolve(c); err != nil {
return err
}
- if err := b.Run(step, NoopExecutor, false); err != nil {
+ if err := tempBuilder.Run(step, NoopExecutor, false); err != nil {
return err
}
}
- node.Children = children
+ // Add all of the defined heading args to the original builder's HeadingArgs map
+ for k, v := range tempBuilder.Args {
+ if _, ok := tempBuilder.AllowedArgs[k]; ok {
+ b.HeadingArgs[k] = v
+ }
+ }
+
return nil
}
@@ -264,13 +273,23 @@ func extractNameFromNode(node *parser.Node) (string, bool) {
return n.Next.Value, true
}
+func (b *Builder) builderForStage() *Builder {
+ stageBuilder := NewBuilder(b.UserArgs)
+ for k, v := range b.HeadingArgs {
+ stageBuilder.HeadingArgs[k] = v
+ }
+ return stageBuilder
+}
+
type Builder struct {
RunConfig docker.Config
- Env []string
- Args map[string]string
- CmdSet bool
- Author string
+ Env []string
+ Args map[string]string
+ HeadingArgs map[string]string
+ UserArgs map[string]string
+ CmdSet bool
+ Author string
AllowedArgs map[string]bool
Volumes VolumeSet
@@ -288,12 +307,16 @@ func NewBuilder(args map[string]string) *Builder {
for k, v := range builtinAllowedBuildArgs {
allowed[k] = v
}
- provided := make(map[string]string)
+ userArgs := make(map[string]string)
+ initialArgs := make(map[string]string)
for k, v := range args {
- provided[k] = v
+ userArgs[k] = v
+ initialArgs[k] = v
}
return &Builder{
- Args: provided,
+ Args: initialArgs,
+ UserArgs: userArgs,
+ HeadingArgs: make(map[string]string),
AllowedArgs: allowed,
}
}
diff --git a/vendor/github.com/openshift/imagebuilder/dispatchers.go b/vendor/github.com/openshift/imagebuilder/dispatchers.go
index e7f2f97bf..1d77a193b 100644
--- a/vendor/github.com/openshift/imagebuilder/dispatchers.go
+++ b/vendor/github.com/openshift/imagebuilder/dispatchers.go
@@ -216,7 +216,7 @@ func from(b *Builder, args []string, attributes map[string]bool, flagArgs []stri
// Support ARG before from
argStrs := []string{}
- for n, v := range b.Args {
+ for n, v := range b.HeadingArgs {
argStrs = append(argStrs, n+"="+v)
}
var err error
@@ -598,10 +598,16 @@ func arg(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
// add the arg to allowed list of build-time args from this step on.
b.AllowedArgs[name] = true
+ // If there is still no default value, a value can be assigned from the heading args
+ if val, ok := b.HeadingArgs[name]; ok && !hasDefault {
+ b.Args[name] = val
+ }
+
// If there is a default value associated with this arg then add it to the
- // b.buildArgs if one is not already passed to the builder. The args passed
- // to builder override the default value of 'arg'.
- if _, ok := b.Args[name]; !ok && hasDefault {
+ // b.buildArgs, later default values for the same arg override earlier ones.
+ // The args passed to builder (UserArgs) override the default value of 'arg'
+ // Don't add them here as they were already set in NewBuilder.
+ if _, ok := b.UserArgs[name]; !ok && hasDefault {
b.Args[name] = value
}