From 8a7ec456f146ef5b88d984701c6000bca98b3687 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 30 Nov 2018 10:46:40 -0800 Subject: [PATCH] use error groups so we can return errors --- provisioner/breakpoint/provisioner.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index c1a270381..b64f97759 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -2,9 +2,10 @@ package breakpoint import ( "fmt" - "log" "os" + "golang.org/x/sync/errgroup" + "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -60,20 +61,22 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { message := fmt.Sprintf( "Press enter to continue.") + var g errgroup.Group result := make(chan string, 1) - go func() { + g.Go(func() error { line, err := ui.Ask(message) if err != nil { - log.Printf("Error asking for input: %s", err) + return fmt.Errorf("Error asking for input: %s", err) } result <- line - }() - - select { - case <-result: return nil + }) + + if err := g.Wait(); err != nil { + return err } + return nil } func (p *Provisioner) Cancel() {