From 0813c5bdb4d4814bb24785aaf29329025d9ddc13 Mon Sep 17 00:00:00 2001 From: Calle Pettersson Date: Wed, 4 Sep 2019 23:03:25 +0200 Subject: [PATCH] Check for StateCancelled --- builder/proxmox/builder.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/proxmox/builder.go b/builder/proxmox/builder.go index 089f7aab6..131dfbb48 100644 --- a/builder/proxmox/builder.go +++ b/builder/proxmox/builder.go @@ -3,6 +3,7 @@ package proxmox import ( "context" "crypto/tls" + "errors" "fmt" "github.com/Telmate/proxmox-api-go/proxmox" @@ -89,7 +90,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack if rawErr, ok := state.GetOk("error"); ok { return nil, rawErr.(error) } + // If we were interrupted or cancelled, then just exit. + if _, ok := state.GetOk(multistep.StateCancelled); ok { + return nil, errors.New("build was cancelled") + } + // Verify that the template_id was set properly, otherwise we didn't progress through the last step tplID, ok := state.Get("template_id").(int) if !ok { return nil, fmt.Errorf("template ID could not be determined")