github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/packer/plugin/provisioner.go (about) 1 package plugin 2 3 import ( 4 "github.com/mitchellh/packer/packer" 5 "log" 6 ) 7 8 type cmdProvisioner struct { 9 p packer.Provisioner 10 client *Client 11 } 12 13 func (c *cmdProvisioner) Prepare(configs ...interface{}) error { 14 defer func() { 15 r := recover() 16 c.checkExit(r, nil) 17 }() 18 19 return c.p.Prepare(configs...) 20 } 21 22 func (c *cmdProvisioner) Provision(ui packer.Ui, comm packer.Communicator) error { 23 defer func() { 24 r := recover() 25 c.checkExit(r, nil) 26 }() 27 28 return c.p.Provision(ui, comm) 29 } 30 31 func (c *cmdProvisioner) Cancel() { 32 defer func() { 33 r := recover() 34 c.checkExit(r, nil) 35 }() 36 37 c.p.Cancel() 38 } 39 40 func (c *cmdProvisioner) checkExit(p interface{}, cb func()) { 41 if c.client.Exited() && cb != nil { 42 cb() 43 } else if p != nil && !Killed { 44 log.Panic(p) 45 } 46 }