From ce275969e464145e674bd64e478c8c23fe398a62 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 29 May 2015 09:37:27 -0700 Subject: [PATCH] builder/docker: don't attempt to read artifact if cancelled --- builder/docker/builder.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builder/docker/builder.go b/builder/docker/builder.go index 18ff73357..96a79b02d 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -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 }