Skip to content

Commit

Permalink
LibpodAPI.BuildImage: don't require a name for the new image
Browse files Browse the repository at this point in the history
When we finish building an image, we try to look up its ID by looking up
the image using the name that we were asked to assign to the image.  If
we weren't asked to assign a name to the image, that would produce an
error.  The BuildImage() API we're using returns the image's ID anyway,
so we can skip the lookup and just return the ID directly.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
  • Loading branch information
nalind committed Feb 6, 2020
1 parent 0d006f7 commit e6c7ccc
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/varlinkapi/images.go
Expand Up @@ -143,6 +143,7 @@ func (i *LibpodAPI) GetImage(call iopodman.VarlinkCall, id string) error {
func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildInfo) error {
var (
namespace []buildah.NamespaceOption
imageID string
err error
)

Expand Down Expand Up @@ -249,7 +250,8 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI

c := make(chan error)
go func() {
_, _, err := i.Runtime.Build(getContext(), options, newPathDockerFiles...)
iid, _, err := i.Runtime.Build(getContext(), options, newPathDockerFiles...)
imageID = iid
c <- err
close(c)
}()
Expand Down Expand Up @@ -291,13 +293,9 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
}
call.Continues = false

newImage, err := i.Runtime.ImageRuntime().NewFromLocal(config.Output)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
br := iopodman.MoreResponse{
Logs: log,
Id: newImage.ID(),
Id: imageID,
}
return call.ReplyBuildImage(br)
}
Expand Down

0 comments on commit e6c7ccc

Please sign in to comment.