Commit 32536b25 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/rpc: fix interface returns for msgpack [GH-1076]

parent 7a8372db
......@@ -21,7 +21,7 @@ type BuildServer struct {
type BuildPrepareResponse struct {
Warnings []string
Error error
Error *BasicError
}
func (b *build) Name() (result string) {
......@@ -34,8 +34,12 @@ func (b *build) Prepare() ([]string, error) {
if cerr := b.client.Call("Build.Prepare", new(interface{}), &resp); cerr != nil {
return nil, cerr
}
var err error = nil
if resp.Error != nil {
err = resp.Error
}
return resp.Warnings, resp.Error
return resp.Warnings, err
}
func (b *build) Run(ui packer.Ui, cache packer.Cache) ([]packer.Artifact, error) {
......@@ -90,7 +94,7 @@ func (b *BuildServer) Prepare(args *interface{}, resp *BuildPrepareResponse) err
warnings, err := b.build.Prepare()
*resp = BuildPrepareResponse{
Warnings: warnings,
Error: err,
Error: NewBasicError(err),
}
return nil
}
......
......@@ -25,14 +25,14 @@ type PostProcessorConfigureArgs struct {
}
type PostProcessorProcessResponse struct {
Err error
Err *BasicError
Keep bool
StreamId uint32
}
func (p *postProcessor) Configure(raw ...interface{}) (err error) {
args := &PostProcessorConfigureArgs{Configs: raw}
if cerr := p.client.Call("PostProcessor.Configure", args, &err); cerr != nil {
if cerr := p.client.Call("PostProcessor.Configure", args, new(interface{})); cerr != nil {
err = cerr
}
......@@ -67,13 +67,9 @@ func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Art
return client.Artifact(), response.Keep, nil
}
func (p *PostProcessorServer) Configure(args *PostProcessorConfigureArgs, reply *error) error {
*reply = p.p.Configure(args.Configs...)
if *reply != nil {
*reply = NewBasicError(*reply)
}
return nil
func (p *PostProcessorServer) Configure(args *PostProcessorConfigureArgs, reply *interface{}) error {
err := p.p.Configure(args.Configs...)
return err
}
func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorProcessResponse) error {
......@@ -92,12 +88,8 @@ func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorP
go server.Serve()
}
if err != nil {
err = NewBasicError(err)
}
*reply = PostProcessorProcessResponse{
Err: err,
Err: NewBasicError(err),
Keep: keep,
StreamId: streamId,
}
......
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