improved error messaging for failed build due to Docker errors

This commit is contained in:
Brad Rydzewski 2014-12-30 13:09:05 -08:00
parent baaaa4069e
commit c3e00e2608

View file

@ -238,7 +238,7 @@ func (b *Builder) setup() error {
if _, err := b.dockerClient.Images.Inspect(b.Build.Image); err == docker.ErrNotFound {
// download the image if it doesn't exist
if err := b.dockerClient.Images.Pull(b.Build.Image); err != nil {
return err
return fmt.Errorf("Error: Unable to pull image %s. %s", b.Build.Image, err)
}
} else if err != nil {
log.Errf("failed to inspect image %s", b.Build.Image)
@ -392,7 +392,7 @@ func (b *Builder) run() error {
// create the container from the image
run, err := b.dockerClient.Containers.Create(&conf)
if err != nil {
return err
return fmt.Errorf("Error: Failed to create build container. %s", err)
}
// cache instance of docker.Run
@ -407,7 +407,7 @@ func (b *Builder) run() error {
if err := b.dockerClient.Containers.Start(run.ID, &host); err != nil {
b.BuildState.ExitCode = 1
b.BuildState.Finished = time.Now().UTC().Unix()
return err
return fmt.Errorf("Error: Failed to start build container. %s", err)
}
// wait for the container to stop
@ -415,7 +415,7 @@ func (b *Builder) run() error {
if err != nil {
b.BuildState.ExitCode = 1
b.BuildState.Finished = time.Now().UTC().Unix()
return err
return fmt.Errorf("Error: Failed to wait for build container. %s", err)
}
// set completion time
@ -503,7 +503,9 @@ func (b *Builder) writeBuildScript(dir string) error {
f.WriteHost(mapping)
}
if len(b.Key) != 0 {
f.WriteFile("$HOME/.ssh/id_rsa", b.Key, 600)
}
// if the repository is remote then we should
// add the commands to the build script to