builder/docker: don't attempt to read artifact if cancelled

This commit is contained in:
Mitchell Hashimoto 2015-05-29 09:37:27 -07:00
parent 6570b53c4a
commit ce275969e4
1 changed files with 7 additions and 1 deletions

View File

@ -77,8 +77,13 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
return nil, rawErr.(error)
}
var artifact packer.Artifact
// If it was cancelled, then just return
if _, ok := state.GetOk(multistep.StateCancelled); ok {
return nil, nil
}
// No errors, must've worked
var artifact packer.Artifact
if b.config.Commit {
artifact = &ImportArtifact{
IdValue: state.Get("image_id").(string),
@ -88,6 +93,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
} else {
artifact = &ExportArtifact{path: b.config.ExportPath}
}
return artifact, nil
}