packer/rpc: implement hook Cancel
This commit is contained in:
parent
017d27d7eb
commit
cd12c3e030
|
@ -2,6 +2,7 @@ package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
|
"log"
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,7 +39,10 @@ func (h *hook) Run(name string, ui packer.Ui, comm packer.Communicator, data int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hook) Cancel() {
|
func (h *hook) Cancel() {
|
||||||
// TODO(mitchellh): implement
|
err := h.client.Call("Hook.Cancel", new(interface{}), new(interface{}))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Hook.Cancel error: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HookServer) Run(args *HookRunArgs, reply *interface{}) error {
|
func (h *HookServer) Run(args *HookRunArgs, reply *interface{}) error {
|
||||||
|
@ -54,3 +58,8 @@ func (h *HookServer) Run(args *HookRunArgs, reply *interface{}) error {
|
||||||
*reply = nil
|
*reply = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *HookServer) Cancel(args *interface{}, reply *interface{}) error {
|
||||||
|
h.hook.Cancel()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,10 @@ func TestHookRPC(t *testing.T) {
|
||||||
ui := &testUi{}
|
ui := &testUi{}
|
||||||
hClient.Run("foo", ui, nil, 42)
|
hClient.Run("foo", ui, nil, 42)
|
||||||
assert.True(h.RunCalled, "run should be called")
|
assert.True(h.RunCalled, "run should be called")
|
||||||
|
|
||||||
|
// Test Cancel
|
||||||
|
hClient.Cancel()
|
||||||
|
assert.True(h.CancelCalled, "cancel should be called")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHook_Implements(t *testing.T) {
|
func TestHook_Implements(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue