Skip to content

Commit

Permalink
Output logs whilst pulling Docker Images (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
revett authored Sep 24, 2018
1 parent 8e784da commit 0dd9f11
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0
0.8.0
22 changes: 11 additions & 11 deletions cli/commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ func (s Start) action() func(c *cli.Context) error {
log.Println("Verbose logging is enabled")
}

saveState := c.Bool("ss")
if saveState {
log.Println("Save state is enabled, existing environment will not be destroyed")
} else {
log.Printf(
"Save state is %s, existing environment will be %s",
color.RedString("disabled"),
color.RedString("destroyed"),
)
}

ctx := context.Background()
cli, err := client.NewEnvClient()
if err != nil {
Expand All @@ -66,17 +77,6 @@ func (s Start) action() func(c *cli.Context) error {
return err
}

saveState := c.Bool("ss")
if saveState {
log.Println("Save state is enabled, existing environment will not be destroyed")
} else {
log.Printf(
"Save state is %s, existing environment will be %s",
color.RedString("disabled"),
color.RedString("destroyed"),
)
}

// TODO

return nil
Expand Down
16 changes: 11 additions & 5 deletions cli/services/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package services

import (
"fmt"
"io"
"os"
"log"

"github.com/CityOfZion/neo-local/cli/logger"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"golang.org/x/net/context"
Expand All @@ -23,25 +23,31 @@ func CheckDockerRunning(ctx context.Context, cli *client.Client) bool {
// PullDockerImages pulls each Docker image required for the stack
// sequentially.
func PullDockerImages(ctx context.Context, cli *client.Client) error {
log.Println("Pulling Docker images")

for _, imageName := range dockerImageNames() {
prefix := fmt.Sprintf("↪ %s", imageName)
s := logger.NewSpinner(prefix)
s.Start()

reader, err := cli.ImagePull(ctx, imageName, types.ImagePullOptions{})
if err != nil {
return fmt.Errorf("Error when pulling Docker image '%s': %s", imageName, err)
}

defer reader.Close()
io.Copy(os.Stdout, reader)
s.Stop()
}

return nil
}

func dockerImageNames() []string {
return []string{
"cityofzion/neo-local-faucet",
"cityofzion/neo-local-faucet:latest",
"cityofzion/neo-privatenet:2.7.6",
"cityofzion/neo-python:v0.7.8",
"postgres:10.1",
"registry.gitlab.com/cityofzion/neo-scan",
"registry.gitlab.com/cityofzion/neo-scan:latest",
}
}

0 comments on commit 0dd9f11

Please sign in to comment.