packer/plugin: new Builder interface

This commit is contained in:
Mitchell Hashimoto 2013-11-02 22:51:26 -05:00
parent af7b8d1e15
commit 58e8d9ac56
3 changed files with 2 additions and 15 deletions

View File

@ -10,7 +10,7 @@ type cmdBuilder struct {
client *Client client *Client
} }
func (b *cmdBuilder) Prepare(config ...interface{}) error { func (b *cmdBuilder) Prepare(config ...interface{}) ([]string, error) {
defer func() { defer func() {
r := recover() r := recover()
b.checkExit(r, nil) b.checkExit(r, nil)

View File

@ -1,23 +1,10 @@
package plugin package plugin
import ( import (
"github.com/mitchellh/packer/packer"
"os/exec" "os/exec"
"testing" "testing"
) )
type helperBuilder byte
func (helperBuilder) Prepare(...interface{}) error {
return nil
}
func (helperBuilder) Run(packer.Ui, packer.Hook, packer.Cache) (packer.Artifact, error) {
return nil, nil
}
func (helperBuilder) Cancel() {}
func TestBuilder_NoExist(t *testing.T) { func TestBuilder_NoExist(t *testing.T) {
c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")}) c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
defer c.Kill() defer c.Kill()

View File

@ -54,7 +54,7 @@ func TestHelperProcess(*testing.T) {
fmt.Printf("%s1|:1234\n", APIVersion) fmt.Printf("%s1|:1234\n", APIVersion)
<-make(chan int) <-make(chan int)
case "builder": case "builder":
ServeBuilder(new(helperBuilder)) ServeBuilder(new(packer.MockBuilder))
case "command": case "command":
ServeCommand(new(helperCommand)) ServeCommand(new(helperCommand))
case "hook": case "hook":