Fix image pull logic

This commit is contained in:
2020-11-09 11:03:01 +01:00
parent 20aec7d527
commit e8afa72dfb
2 changed files with 7 additions and 5 deletions

View File

@ -98,19 +98,21 @@ func (lc LabeledContainer) UpdateTo(cli *client.Client, tag Tag) error {
fmt.Printf("Pulling image \"%s\"\n", canonicalImage)
//containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
rc, err := cli.ImagePull(ctx, canonicalImage, types.ImagePullOptions{})
imageReader, err := cli.ImagePull(ctx, canonicalImage, types.ImagePullOptions{})
if err != nil {
return err
}
// TODO: does it still pull the image if i just close the reader?
err = rc.Close()
defer imageReader.Close()
loadResponse, err := cli.ImageLoad(ctx, imageReader, false)
if err != nil {
return err
}
defer loadResponse.Body.Close()
fmt.Printf("Stopping container %s\n", lc.Container.ID)
// TODO: hopefully this is blocking
err = cli.ContainerStop(ctx, lc.Container.ID, nil)
if err != nil {
return err