Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
ce7ea006
Commit
ce7ea006
authored
Apr 26, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: use the msgpack codec
parent
130c0b1c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
14 deletions
+28
-14
packer/plugin/server.go
packer/plugin/server.go
+1
-1
packer/rpc/builder.go
packer/rpc/builder.go
+7
-7
packer/rpc/builder_test.go
packer/rpc/builder_test.go
+3
-2
packer/rpc/client.go
packer/rpc/client.go
+5
-1
packer/rpc/error.go
packer/rpc/error.go
+4
-0
packer/rpc/post_processor_test.go
packer/rpc/post_processor_test.go
+2
-1
packer/rpc/provisioner_test.go
packer/rpc/provisioner_test.go
+2
-1
packer/rpc/server.go
packer/rpc/server.go
+4
-1
No files found.
packer/plugin/server.go
View file @
ce7ea006
...
...
@@ -33,7 +33,7 @@ const MagicCookieValue = "d602bf8f470bc67ca7faa0386276bbdd4330efaf76d1a219cb4d69
// The APIVersion is outputted along with the RPC address. The plugin
// client validates this API version and will show an error if it doesn't
// know how to speak it.
const
APIVersion
=
"
2
"
const
APIVersion
=
"
3
"
// Server waits for a connection to this plugin and returns a Packer
// RPC server that you can use to register components and serve them.
...
...
packer/rpc/builder.go
View file @
ce7ea006
...
...
@@ -26,7 +26,7 @@ type BuilderPrepareArgs struct {
type
BuilderPrepareResponse
struct
{
Warnings
[]
string
Error
e
rror
Error
*
BasicE
rror
}
func
(
b
*
builder
)
Prepare
(
config
...
interface
{})
([]
string
,
error
)
{
...
...
@@ -35,8 +35,12 @@ func (b *builder) Prepare(config ...interface{}) ([]string, error) {
if
cerr
!=
nil
{
return
nil
,
cerr
}
var
err
error
=
nil
if
resp
.
Error
!=
nil
{
err
=
resp
.
Error
}
return
resp
.
Warnings
,
resp
.
Erro
r
return
resp
.
Warnings
,
er
r
}
func
(
b
*
builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
@@ -72,13 +76,9 @@ func (b *builder) Cancel() {
func
(
b
*
BuilderServer
)
Prepare
(
args
*
BuilderPrepareArgs
,
reply
*
BuilderPrepareResponse
)
error
{
warnings
,
err
:=
b
.
builder
.
Prepare
(
args
.
Configs
...
)
if
err
!=
nil
{
err
=
NewBasicError
(
err
)
}
*
reply
=
BuilderPrepareResponse
{
Warnings
:
warnings
,
Error
:
err
,
Error
:
NewBasicError
(
err
)
,
}
return
nil
}
...
...
packer/rpc/builder_test.go
View file @
ce7ea006
...
...
@@ -30,8 +30,9 @@ func TestBuilderPrepare(t *testing.T) {
t
.
Fatal
(
"should be called"
)
}
if
!
reflect
.
DeepEqual
(
b
.
PrepareConfig
,
[]
interface
{}{
42
})
{
t
.
Fatalf
(
"bad: %#v"
,
b
.
PrepareConfig
)
expected
:=
[]
interface
{}{
int64
(
42
)}
if
!
reflect
.
DeepEqual
(
b
.
PrepareConfig
,
expected
)
{
t
.
Fatalf
(
"bad: %#v != %#v"
,
b
.
PrepareConfig
,
expected
)
}
}
...
...
packer/rpc/client.go
View file @
ce7ea006
...
...
@@ -2,6 +2,7 @@ package rpc
import
(
"github.com/mitchellh/packer/packer"
"github.com/ugorji/go/codec"
"io"
"log"
"net/rpc"
...
...
@@ -32,9 +33,12 @@ func newClientWithMux(mux *MuxConn, streamId uint32) (*Client, error) {
return
nil
,
err
}
var
h
codec
.
MsgpackHandle
clientCodec
:=
codec
.
GoRpc
.
ClientCodec
(
clientConn
,
&
h
)
return
&
Client
{
mux
:
mux
,
client
:
rpc
.
NewClient
(
clientConn
),
client
:
rpc
.
NewClient
WithCodec
(
clientCodec
),
closeMux
:
false
,
},
nil
}
...
...
packer/rpc/error.go
View file @
ce7ea006
...
...
@@ -9,6 +9,10 @@ type BasicError struct {
}
func
NewBasicError
(
err
error
)
*
BasicError
{
if
err
==
nil
{
return
nil
}
return
&
BasicError
{
err
.
Error
()}
}
...
...
packer/rpc/post_processor_test.go
View file @
ce7ea006
...
...
@@ -54,7 +54,8 @@ func TestPostProcessorRPC(t *testing.T) {
t
.
Fatal
(
"config should be called"
)
}
if
!
reflect
.
DeepEqual
(
p
.
configVal
,
[]
interface
{}{
42
})
{
expected
:=
[]
interface
{}{
int64
(
42
)}
if
!
reflect
.
DeepEqual
(
p
.
configVal
,
expected
)
{
t
.
Fatalf
(
"unknown config value: %#v"
,
p
.
configVal
)
}
...
...
packer/rpc/provisioner_test.go
View file @
ce7ea006
...
...
@@ -23,7 +23,8 @@ func TestProvisionerRPC(t *testing.T) {
if
!
p
.
PrepCalled
{
t
.
Fatal
(
"should be called"
)
}
if
!
reflect
.
DeepEqual
(
p
.
PrepConfigs
,
[]
interface
{}{
42
})
{
expected
:=
[]
interface
{}{
int64
(
42
)}
if
!
reflect
.
DeepEqual
(
p
.
PrepConfigs
,
expected
)
{
t
.
Fatalf
(
"bad: %#v"
,
p
.
PrepConfigs
)
}
...
...
packer/rpc/server.go
View file @
ce7ea006
...
...
@@ -3,6 +3,7 @@ package rpc
import
(
"fmt"
"github.com/mitchellh/packer/packer"
"github.com/ugorji/go/codec"
"io"
"log"
"net/rpc"
...
...
@@ -145,7 +146,9 @@ func (s *Server) Serve() {
return
}
s
.
server
.
ServeConn
(
stream
)
var
h
codec
.
MsgpackHandle
rpcCodec
:=
codec
.
GoRpc
.
ServerCodec
(
stream
,
&
h
)
s
.
server
.
ServeCodec
(
rpcCodec
)
}
// registerComponent registers a single Packer RPC component onto
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment