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