From 9c89e33b5bf086f65d96ba9c8725ef5cf8cabde3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 18 Jun 2013 10:05:45 -0700 Subject: [PATCH] packer/rpc: Get RPC compliant with Environment again --- packer/rpc/environment.go | 28 ++++++++++++++++++++++++++++ packer/rpc/environment_test.go | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/packer/rpc/environment.go b/packer/rpc/environment.go index aeb468059..f873e434c 100644 --- a/packer/rpc/environment.go +++ b/packer/rpc/environment.go @@ -73,6 +73,22 @@ func (e *Environment) Hook(name string) (h packer.Hook, err error) { return } +func (e *Environment) PostProcessor(name string) (p packer.PostProcessor, err error) { + var reply string + err = e.client.Call("Environment.PostProcessor", name, &reply) + if err != nil { + return + } + + _, err = rpc.Dial("tcp", reply) + if err != nil { + return + } + + p = nil + return +} + func (e *Environment) Provisioner(name string) (p packer.Provisioner, err error) { var reply string err = e.client.Call("Environment.Provisioner", name, &reply) @@ -143,6 +159,18 @@ func (e *EnvironmentServer) Hook(name *string, reply *string) error { return nil } +func (e *EnvironmentServer) PostProcessor(name *string, reply *string) error { + _, err := e.env.PostProcessor(*name) + if err != nil { + return err + } + + server := rpc.NewServer() + + *reply = serveSingleConn(server) + return nil +} + func (e *EnvironmentServer) Provisioner(name *string, reply *string) error { prov, err := e.env.Provisioner(*name) if err != nil { diff --git a/packer/rpc/environment_test.go b/packer/rpc/environment_test.go index ed2302579..18a755a65 100644 --- a/packer/rpc/environment_test.go +++ b/packer/rpc/environment_test.go @@ -18,6 +18,8 @@ type testEnvironment struct { cliArgs []string hookCalled bool hookName string + ppCalled bool + ppName string provCalled bool provName string uiCalled bool @@ -45,6 +47,12 @@ func (e *testEnvironment) Hook(name string) (packer.Hook, error) { return nil, nil } +func (e *testEnvironment) PostProcessor(name string) (packer.PostProcessor, error) { + e.ppCalled = true + e.ppName = name + return nil, nil +} + func (e *testEnvironment) Provisioner(name string) (packer.Provisioner, error) { e.provCalled = true e.provName = name