Update all packer/rpc, packer/plugin, builders for new builder API
This commit is contained in:
parent
441edd25d2
commit
d926b98708
|
@ -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)
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue