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) fmt.Printf("Pulling image \"%s\"\n", canonicalImage)
//containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) //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 { if err != nil {
return err return err
} }
// TODO: does it still pull the image if i just close the reader? defer imageReader.Close()
err = rc.Close()
loadResponse, err := cli.ImageLoad(ctx, imageReader, false)
if err != nil { if err != nil {
return err return err
} }
defer loadResponse.Body.Close()
fmt.Printf("Stopping container %s\n", lc.Container.ID) fmt.Printf("Stopping container %s\n", lc.Container.ID)
// TODO: hopefully this is blocking
err = cli.ContainerStop(ctx, lc.Container.ID, nil) err = cli.ContainerStop(ctx, lc.Container.ID, nil)
if err != nil { if err != nil {
return err return err

View File

@ -60,7 +60,7 @@ func checkForUpdates() {
fmt.Println(" no update available") fmt.Println(" no update available")
} }
} }
fmt.Println("all done") fmt.Println("All done")
} }
func main() { func main() {