use error groups so we can return errors
This commit is contained in:
parent
e6477d13fb
commit
8a7ec456f1
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue