fix image not being pulled if reader is not being used

pull/12/head
iwilltry42 6 years ago
parent a26aa65782
commit 7d5964c3b9
  1. 2
      cli/commands.go
  2. 8
      cli/container.go

@ -61,7 +61,7 @@ func CreateCluster(c *cli.Context) error {
// let's go
log.Printf("Creating cluster [%s]", c.String("name"))
dockerID, err := createServer(
c.Bool("verbose"),
c.GlobalBool("verbose"),
fmt.Sprintf("docker.io/rancher/k3s:%s", c.String("version")),
c.String("port"),
k3sServerArgs,

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"time"
@ -16,12 +17,12 @@ import (
)
func createServer(verbose bool, image string, port string, args []string, env []string, name string, volumes []string) (string, error) {
log.Printf("Creating server using %s...\n", image)
ctx := context.Background()
docker, err := client.NewEnvClient()
if err != nil {
return "", fmt.Errorf("ERROR: couldn't create docker client\n%+v", err)
}
reader, err := docker.ImagePull(ctx, image, types.ImagePullOptions{})
if err != nil {
return "", fmt.Errorf("ERROR: couldn't pull image %s\n%+v", image, err)
@ -31,6 +32,11 @@ func createServer(verbose bool, image string, port string, args []string, env []
if err != nil {
log.Printf("WARNING: couldn't get docker output\n%+v", err)
}
} else {
_, err := io.Copy(ioutil.Discard, reader)
if err != nil {
log.Printf("WARNING: couldn't get docker output\n%+v", err)
}
}
containerLabels := make(map[string]string)

Loading…
Cancel
Save