packer/rpc: Implement Builder.Cancel
This commit is contained in:
parent
1b557d7710
commit
e06c26c55c
|
@ -93,7 +93,9 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *builder) Cancel() {
|
func (b *builder) Cancel() {
|
||||||
|
if err := b.client.Call("Builder.Cancel", new(interface{}), new(interface{})); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BuilderServer) Prepare(args *BuilderPrepareArgs, reply *error) error {
|
func (b *BuilderServer) Prepare(args *BuilderPrepareArgs, reply *error) error {
|
||||||
|
@ -135,3 +137,8 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *BuilderServer) Cancel(args *interface{}, reply*interface{}) error {
|
||||||
|
b.builder.Cancel()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -73,6 +73,10 @@ func TestBuilderRPC(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(artifact.Id(), testBuilderArtifact.Id(), "should have artifact Id")
|
assert.Equal(artifact.Id(), testBuilderArtifact.Id(), "should have artifact Id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test Cancel
|
||||||
|
bClient.Cancel()
|
||||||
|
assert.True(b.cancelCalled, "cancel should be called")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuilder_ImplementsBuilder(t *testing.T) {
|
func TestBuilder_ImplementsBuilder(t *testing.T) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ func serveSingleConn(s *rpc.Server) string {
|
||||||
defer l.Close()
|
defer l.Close()
|
||||||
conn, err := l.Accept()
|
conn, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.ServeConn(conn)
|
s.ServeConn(conn)
|
||||||
|
|
Loading…
Reference in New Issue