diff --git a/builder/amazonebs/builder.go b/builder/amazonebs/builder.go index 95fc55805..7305dfe84 100644 --- a/builder/amazonebs/builder.go +++ b/builder/amazonebs/builder.go @@ -48,7 +48,7 @@ func (b *Builder) Prepare(raw interface{}) (err error) { return } -func (b *Builder) Run(build packer.Build, ui packer.Ui) { +func (b *Builder) Run(ui packer.Ui, hook packer.Hook) { auth := aws.Auth{b.config.AccessKey, b.config.SecretKey} region := aws.Regions[b.config.Region] ec2conn := ec2.New(auth, region) diff --git a/packer/plugin/builder.go b/packer/plugin/builder.go index ababcdc92..783e67d48 100644 --- a/packer/plugin/builder.go +++ b/packer/plugin/builder.go @@ -22,13 +22,13 @@ func (b *cmdBuilder) Prepare(config interface{}) error { return b.builder.Prepare(config) } -func (b *cmdBuilder) Run(build packer.Build, ui packer.Ui) { +func (b *cmdBuilder) Run(ui packer.Ui, hook packer.Hook) { defer func() { r := recover() b.checkExit(r, nil) }() - b.builder.Run(build, ui) + b.builder.Run(ui, hook) } func (c *cmdBuilder) checkExit(p interface{}, cb func()) { diff --git a/packer/plugin/builder_test.go b/packer/plugin/builder_test.go index e883bd02d..4fe2ccf52 100644 --- a/packer/plugin/builder_test.go +++ b/packer/plugin/builder_test.go @@ -13,7 +13,7 @@ func (helperBuilder) Prepare(interface{}) error { return nil } -func (helperBuilder) Run(packer.Build, packer.Ui) {} +func (helperBuilder) Run(packer.Ui, packer.Hook) {} func TestBuilder_NoExist(t *testing.T) { assert := asserts.NewTestingAsserts(t, true) diff --git a/packer/rpc/builder.go b/packer/rpc/builder.go index b2450af8a..c4d79704b 100644 --- a/packer/rpc/builder.go +++ b/packer/rpc/builder.go @@ -38,12 +38,12 @@ func (b *builder) Prepare(config interface{}) (err error) { return } -func (b *builder) Run(build packer.Build, ui packer.Ui) { +func (b *builder) Run(ui packer.Ui, hook packer.Hook) { // Create and start the server for the Build and UI // TODO: Error handling server := rpc.NewServer() - RegisterBuild(server, build) RegisterUi(server, ui) + RegisterHook(server, hook) args := &BuilderRunArgs{serveSingleConn(server)} b.client.Call("Builder.Run", args, new(interface{})) @@ -64,9 +64,9 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error { return err } - build := &Build{client} + hook := Hook(client) ui := &Ui{client} - b.builder.Run(build, ui) + b.builder.Run(ui, hook) *reply = nil return nil diff --git a/packer/rpc/builder_test.go b/packer/rpc/builder_test.go index 82980961d..0584ac0af 100644 --- a/packer/rpc/builder_test.go +++ b/packer/rpc/builder_test.go @@ -11,7 +11,7 @@ type testBuilder struct { prepareCalled bool prepareConfig interface{} runCalled bool - runBuild packer.Build + runHook packer.Hook runUi packer.Ui } @@ -21,9 +21,9 @@ func (b *testBuilder) Prepare(config interface{}) error { return nil } -func (b *testBuilder) Run(build packer.Build, ui packer.Ui) { +func (b *testBuilder) Run(ui packer.Ui, hook packer.Hook) { b.runCalled = true - b.runBuild = build + b.runHook = hook b.runUi = ui } @@ -50,14 +50,14 @@ func TestBuilderRPC(t *testing.T) { assert.Equal(b.prepareConfig, 42, "prepare should be called with right arg") // Test Run - build := &testBuild{} + hook := &testHook{} ui := &testUi{} - bClient.Run(build, ui) + bClient.Run(ui, hook) assert.True(b.runCalled, "runs hould be called") if b.runCalled { - b.runBuild.Prepare() - assert.True(build.prepareCalled, "prepare should be called") + b.runHook.Run("foo", nil, nil) + assert.True(hook.runCalled, "run should be called") b.runUi.Say("format") assert.True(ui.sayCalled, "say should be called")