moby: Add informational output to build

This adds log.Info() to the main steps of the "moby build"
process. By default the Info() output is shown to the user
so it provides some idea of progress and what is happening.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-03-29 10:53:18 +01:00
parent 37545913a6
commit e39b1ddffc
3 changed files with 18 additions and 3 deletions

View File

@ -92,6 +92,7 @@ func build(name string, pull bool, args []string) {
containers := []*bytes.Buffer{}
if pull {
log.Infof("Pull kernel image: %s", m.Kernel.Image)
err := dockerPull(m.Kernel.Image)
if err != nil {
log.Fatalf("Could not pull image %s: %v", m.Kernel.Image, err)
@ -99,6 +100,7 @@ func build(name string, pull bool, args []string) {
}
// get kernel bzImage and initrd tarball from container
// TODO examine contents to see what names they might have
log.Infof("Extract kernel image: %s", m.Kernel.Image)
const (
bzimageName = "bzImage"
ktarName = "kernel.tar"
@ -116,11 +118,13 @@ func build(name string, pull bool, args []string) {
// convert init image to tarball
if pull {
log.Infof("Pull init: %s", m.Init)
err := dockerPull(m.Init)
if err != nil {
log.Fatalf("Could not pull image %s: %v", m.Init, err)
}
}
log.Infof("Process init: %s", m.Init)
init, err := ImageExtract(m.Init, "")
if err != nil {
log.Fatalf("Failed to build init tarball: %v", err)
@ -128,13 +132,16 @@ func build(name string, pull bool, args []string) {
buffer := bytes.NewBuffer(init)
containers = append(containers, buffer)
log.Infof("Add system containers:")
for i, image := range m.System {
if pull {
log.Infof(" Pull: %s", image.Image)
err := dockerPull(image.Image)
if err != nil {
log.Fatalf("Could not pull image %s: %v", image.Image, err)
}
}
log.Infof(" Create OCI config for %s", image.Image)
config, err := ConfigToOCI(&image)
if err != nil {
log.Fatalf("Failed to run riddler to get config.json for %s: %v", image.Image, err)
@ -149,13 +156,16 @@ func build(name string, pull bool, args []string) {
containers = append(containers, buffer)
}
log.Infof("Add daemon containers:")
for _, image := range m.Daemon {
if pull {
log.Infof(" Pull: %s", image.Image)
err := dockerPull(image.Image)
if err != nil {
log.Fatalf("Could not pull image %s: %v", image.Image, err)
}
}
log.Infof(" Create OCI config for %s", image.Image)
config, err := ConfigToOCI(&image)
if err != nil {
log.Fatalf("Failed to run riddler to get config.json for %s: %v", image.Image, err)
@ -176,11 +186,13 @@ func build(name string, pull bool, args []string) {
}
containers = append(containers, buffer)
log.Infof("Create initial ram disk")
initrd, err := containersInitrd(containers)
if err != nil {
log.Fatalf("Failed to make initrd %v", err)
}
log.Infof("Create outputs:")
err = outputs(m, name, bzimage.Bytes(), initrd.Bytes())
if err != nil {
log.Fatalf("Error writing outputs: %v", err)

View File

@ -9,6 +9,7 @@ import (
"strconv"
"strings"
log "github.com/Sirupsen/logrus"
"gopkg.in/yaml.v2"
)
@ -119,7 +120,9 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
tw := tar.NewWriter(buf)
defer tw.Close()
log.Infof("Add files:")
for _, f := range m.Files {
log.Infof(" %s", f.Path)
if f.Path == "" {
return buf, errors.New("Did not specify path for file")
}

View File

@ -133,6 +133,7 @@ func tarInitrdKernel(bzimage, initrd []byte) (*bytes.Buffer, error) {
func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...string) error {
log.Debugf("output img: %s %s", image, filename)
log.Infof(" %s", filename)
buf, err := tarInitrdKernel(bzimage, initrd)
if err != nil {
return err
@ -145,12 +146,12 @@ func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...st
if err != nil {
return err
}
fmt.Println(filename)
return nil
}
func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...string) error {
log.Debugf("output iso: %s %s", image, filename)
log.Infof(" %s", filename)
buf, err := tarInitrdKernel(bzimage, initrd)
if err != nil {
return err
@ -163,12 +164,12 @@ func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...st
if err != nil {
return err
}
fmt.Println(filename)
return nil
}
func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline string) error {
log.Debugf("output kernel/initrd: %s %s", base, cmdline)
log.Infof(" %s %s %s", base+"-bzImage", base+"-initrd.img", base+"-cmdline")
err := ioutil.WriteFile(base+"-initrd.img", initrd, os.FileMode(0644))
if err != nil {
return err
@ -181,6 +182,5 @@ func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline stri
if err != nil {
return err
}
fmt.Println(base + "-bzImage " + base + "-initrd.img " + base + "-cmdline")
return nil
}