github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/packer/plugin/post_processor.go (about)

     1  package plugin
     2  
     3  import (
     4  	"github.com/mitchellh/packer/packer"
     5  	"log"
     6  )
     7  
     8  type cmdPostProcessor struct {
     9  	p      packer.PostProcessor
    10  	client *Client
    11  }
    12  
    13  func (c *cmdPostProcessor) Configure(config ...interface{}) error {
    14  	defer func() {
    15  		r := recover()
    16  		c.checkExit(r, nil)
    17  	}()
    18  
    19  	return c.p.Configure(config...)
    20  }
    21  
    22  func (c *cmdPostProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Artifact, bool, error) {
    23  	defer func() {
    24  		r := recover()
    25  		c.checkExit(r, nil)
    26  	}()
    27  
    28  	return c.p.PostProcess(ui, a)
    29  }
    30  
    31  func (c *cmdPostProcessor) checkExit(p interface{}, cb func()) {
    32  	if c.client.Exited() {
    33  		cb()
    34  	} else if p != nil && !Killed {
    35  		log.Panic(p)
    36  	}
    37  }