Skip to content

Commit

Permalink
Print commitID with --layers
Browse files Browse the repository at this point in the history
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

When the --layers option is used, the final imageID was
not being printed in the final line.  It was printed two
lines prior.  We still have to print the one two lines up
(at least without major modifications), but now we print
it in the last line as it does for all other circumstances
so it can be grabbed by scripts.

Fixes: containers#1237

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
  • Loading branch information
TomSweeneyRedHat committed Mar 8, 2019
1 parent 984ea9b commit 559fc6c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions imagebuildah/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ func (b *Executor) Execute(ctx context.Context, stage imagebuilder.Stage) error
b.containerIDs = nil

var leftoverArgs []string
var layerCacheID string
for arg := range b.builder.Args {
if !builtinAllowedBuildArgs[arg] {
leftoverArgs = append(leftoverArgs, arg)
Expand Down Expand Up @@ -892,6 +893,7 @@ func (b *Executor) Execute(ctx context.Context, stage imagebuilder.Stage) error
return err
}
b.containerIDs = append(b.containerIDs, b.builder.ContainerID)
layerCacheID = cacheID
break
}

Expand All @@ -910,6 +912,7 @@ func (b *Executor) Execute(ctx context.Context, stage imagebuilder.Stage) error
return errors.Wrapf(err, "error committing container for step %+v", *step)
}
if i == len(children)-1 {
layerCacheID = imgID
b.log("COMMIT %s", b.output)
}
} else {
Expand All @@ -929,6 +932,10 @@ func (b *Executor) Execute(ctx context.Context, stage imagebuilder.Stage) error
if len(leftoverArgs) > 0 {
fmt.Fprintf(b.out, "[Warning] One or more build-args %v were not consumed\n", leftoverArgs)
}

if b.layers { // print out the final imageID if we're using layers flag
fmt.Fprintf(b.out, "--> %s\n", layerCacheID)
}
return nil
}

Expand Down

0 comments on commit 559fc6c

Please sign in to comment.