Commit 82cbf13f authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/plugin: new Builder interface

parent b2b125d8
...@@ -10,7 +10,7 @@ type cmdBuilder struct { ...@@ -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)
......
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()
......
...@@ -54,7 +54,7 @@ func TestHelperProcess(*testing.T) { ...@@ -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":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment