packer-cn/packer/plugin/post_processor.go

38 lines
643 B
Go
Raw Normal View History

2013-06-18 16:49:07 -04:00
package plugin
import (
"github.com/mitchellh/packer/packer"
"log"
)
type cmdPostProcessor struct {
p packer.PostProcessor
client *Client
}
func (c *cmdPostProcessor) Configure(config interface{}) error {
defer func() {
r := recover()
c.checkExit(r, nil)
}()
return c.p.Configure(config)
}
func (c *cmdPostProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Artifact, error) {
2013-06-18 16:49:07 -04:00
defer func() {
r := recover()
c.checkExit(r, nil)
}()
return c.p.PostProcess(ui, a)
2013-06-18 16:49:07 -04:00
}
func (c *cmdPostProcessor) checkExit(p interface{}, cb func()) {
if c.client.Exited() {
cb()
} else if p != nil {
log.Panic(p)
}
}