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
74f018df
Commit
74f018df
authored
Dec 19, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: make newXWithMuxConn private
parent
f06cd56e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
34 additions
and
34 deletions
+34
-34
packer/rpc/build.go
packer/rpc/build.go
+4
-4
packer/rpc/builder.go
packer/rpc/builder.go
+4
-4
packer/rpc/client.go
packer/rpc/client.go
+2
-2
packer/rpc/command.go
packer/rpc/command.go
+2
-2
packer/rpc/environment.go
packer/rpc/environment.go
+12
-12
packer/rpc/hook.go
packer/rpc/hook.go
+2
-2
packer/rpc/post_processor.go
packer/rpc/post_processor.go
+4
-4
packer/rpc/provisioner.go
packer/rpc/provisioner.go
+2
-2
packer/rpc/server.go
packer/rpc/server.go
+2
-2
No files found.
packer/rpc/build.go
View file @
74f018df
...
...
@@ -40,7 +40,7 @@ func (b *build) Prepare(v map[string]string) ([]string, error) {
func
(
b
*
build
)
Run
(
ui
packer
.
Ui
,
cache
packer
.
Cache
)
([]
packer
.
Artifact
,
error
)
{
nextId
:=
b
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
b
.
mux
,
nextId
)
server
:=
n
ewServerWithMux
(
b
.
mux
,
nextId
)
server
.
RegisterCache
(
cache
)
server
.
RegisterUi
(
ui
)
go
server
.
Serve
()
...
...
@@ -52,7 +52,7 @@ func (b *build) Run(ui packer.Ui, cache packer.Cache) ([]packer.Artifact, error)
artifacts
:=
make
([]
packer
.
Artifact
,
len
(
result
))
for
i
,
streamId
:=
range
result
{
client
,
err
:=
N
ewClientWithMux
(
b
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
b
.
mux
,
streamId
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -96,7 +96,7 @@ func (b *BuildServer) Prepare(v map[string]string, resp *BuildPrepareResponse) e
}
func
(
b
*
BuildServer
)
Run
(
streamId
uint32
,
reply
*
[]
uint32
)
error
{
client
,
err
:=
N
ewClientWithMux
(
b
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
b
.
mux
,
streamId
)
if
err
!=
nil
{
return
NewBasicError
(
err
)
}
...
...
@@ -110,7 +110,7 @@ func (b *BuildServer) Run(streamId uint32, reply *[]uint32) error {
*
reply
=
make
([]
uint32
,
len
(
artifacts
))
for
i
,
artifact
:=
range
artifacts
{
streamId
:=
b
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
b
.
mux
,
streamId
)
server
:=
n
ewServerWithMux
(
b
.
mux
,
streamId
)
server
.
RegisterArtifact
(
artifact
)
go
server
.
Serve
()
...
...
packer/rpc/builder.go
View file @
74f018df
...
...
@@ -41,7 +41,7 @@ func (b *builder) Prepare(config ...interface{}) ([]string, error) {
func
(
b
*
builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
nextId
:=
b
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
b
.
mux
,
nextId
)
server
:=
n
ewServerWithMux
(
b
.
mux
,
nextId
)
server
.
RegisterCache
(
cache
)
server
.
RegisterHook
(
hook
)
server
.
RegisterUi
(
ui
)
...
...
@@ -56,7 +56,7 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
return
nil
,
nil
}
client
,
err
:=
N
ewClientWithMux
(
b
.
mux
,
responseId
)
client
,
err
:=
n
ewClientWithMux
(
b
.
mux
,
responseId
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -84,7 +84,7 @@ func (b *BuilderServer) Prepare(args *BuilderPrepareArgs, reply *BuilderPrepareR
}
func
(
b
*
BuilderServer
)
Run
(
streamId
uint32
,
reply
*
uint32
)
error
{
client
,
err
:=
N
ewClientWithMux
(
b
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
b
.
mux
,
streamId
)
if
err
!=
nil
{
return
NewBasicError
(
err
)
}
...
...
@@ -98,7 +98,7 @@ func (b *BuilderServer) Run(streamId uint32, reply *uint32) error {
*
reply
=
0
if
artifact
!=
nil
{
streamId
=
b
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
b
.
mux
,
streamId
)
server
:=
n
ewServerWithMux
(
b
.
mux
,
streamId
)
server
.
RegisterArtifact
(
artifact
)
go
server
.
Serve
()
*
reply
=
streamId
...
...
packer/rpc/client.go
View file @
74f018df
...
...
@@ -17,7 +17,7 @@ type Client struct {
}
func
NewClient
(
rwc
io
.
ReadWriteCloser
)
(
*
Client
,
error
)
{
result
,
err
:=
N
ewClientWithMux
(
NewMuxConn
(
rwc
,
0
),
0
)
result
,
err
:=
n
ewClientWithMux
(
NewMuxConn
(
rwc
,
0
),
0
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -26,7 +26,7 @@ func NewClient(rwc io.ReadWriteCloser) (*Client, error) {
return
result
,
err
}
func
N
ewClientWithMux
(
mux
*
MuxConn
,
streamId
uint32
)
(
*
Client
,
error
)
{
func
n
ewClientWithMux
(
mux
*
MuxConn
,
streamId
uint32
)
(
*
Client
,
error
)
{
clientConn
,
err
:=
mux
.
Dial
(
streamId
)
if
err
!=
nil
{
return
nil
,
err
...
...
packer/rpc/command.go
View file @
74f018df
...
...
@@ -37,7 +37,7 @@ func (c *command) Help() (result string) {
func
(
c
*
command
)
Run
(
env
packer
.
Environment
,
args
[]
string
)
(
result
int
)
{
nextId
:=
c
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
c
.
mux
,
nextId
)
server
:=
n
ewServerWithMux
(
c
.
mux
,
nextId
)
server
.
RegisterEnvironment
(
env
)
go
server
.
Serve
()
...
...
@@ -68,7 +68,7 @@ func (c *CommandServer) Help(args *interface{}, reply *string) error {
}
func
(
c
*
CommandServer
)
Run
(
args
*
CommandRunArgs
,
reply
*
int
)
error
{
client
,
err
:=
N
ewClientWithMux
(
c
.
mux
,
args
.
StreamId
)
client
,
err
:=
n
ewClientWithMux
(
c
.
mux
,
args
.
StreamId
)
if
err
!=
nil
{
return
NewBasicError
(
err
)
}
...
...
packer/rpc/environment.go
View file @
74f018df
...
...
@@ -31,7 +31,7 @@ func (e *Environment) Builder(name string) (b packer.Builder, err error) {
return
}
client
,
err
:=
N
ewClientWithMux
(
e
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
e
.
mux
,
streamId
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -45,7 +45,7 @@ func (e *Environment) Cache() packer.Cache {
panic
(
err
)
}
client
,
err
:=
N
ewClientWithMux
(
e
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
e
.
mux
,
streamId
)
if
err
!=
nil
{
log
.
Printf
(
"[ERR] Error getting cache client: %s"
,
err
)
return
nil
...
...
@@ -66,7 +66,7 @@ func (e *Environment) Hook(name string) (h packer.Hook, err error) {
return
}
client
,
err
:=
N
ewClientWithMux
(
e
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
e
.
mux
,
streamId
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -80,7 +80,7 @@ func (e *Environment) PostProcessor(name string) (p packer.PostProcessor, err er
return
}
client
,
err
:=
N
ewClientWithMux
(
e
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
e
.
mux
,
streamId
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -95,7 +95,7 @@ func (e *Environment) Provisioner(name string) (p packer.Provisioner, err error)
return
}
client
,
err
:=
N
ewClientWithMux
(
e
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
e
.
mux
,
streamId
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -107,7 +107,7 @@ func (e *Environment) Ui() packer.Ui {
var
streamId
uint32
e
.
client
.
Call
(
"Environment.Ui"
,
new
(
interface
{}),
&
streamId
)
client
,
err
:=
N
ewClientWithMux
(
e
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
e
.
mux
,
streamId
)
if
err
!=
nil
{
log
.
Printf
(
"[ERR] Error connecting to Ui: %s"
,
err
)
return
nil
...
...
@@ -122,7 +122,7 @@ func (e *EnvironmentServer) Builder(name string, reply *uint32) error {
}
*
reply
=
e
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
:=
n
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
.
RegisterBuilder
(
builder
)
go
server
.
Serve
()
return
nil
...
...
@@ -132,7 +132,7 @@ func (e *EnvironmentServer) Cache(args *interface{}, reply *uint32) error {
cache
:=
e
.
env
.
Cache
()
*
reply
=
e
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
:=
n
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
.
RegisterCache
(
cache
)
go
server
.
Serve
()
return
nil
...
...
@@ -150,7 +150,7 @@ func (e *EnvironmentServer) Hook(name string, reply *uint32) error {
}
*
reply
=
e
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
:=
n
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
.
RegisterHook
(
hook
)
go
server
.
Serve
()
return
nil
...
...
@@ -163,7 +163,7 @@ func (e *EnvironmentServer) PostProcessor(name string, reply *uint32) error {
}
*
reply
=
e
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
:=
n
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
.
RegisterPostProcessor
(
pp
)
go
server
.
Serve
()
return
nil
...
...
@@ -176,7 +176,7 @@ func (e *EnvironmentServer) Provisioner(name string, reply *uint32) error {
}
*
reply
=
e
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
:=
n
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
.
RegisterProvisioner
(
prov
)
go
server
.
Serve
()
return
nil
...
...
@@ -186,7 +186,7 @@ func (e *EnvironmentServer) Ui(args *interface{}, reply *uint32) error {
ui
:=
e
.
env
.
Ui
()
*
reply
=
e
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
:=
n
ewServerWithMux
(
e
.
mux
,
*
reply
)
server
.
RegisterUi
(
ui
)
go
server
.
Serve
()
return
nil
...
...
packer/rpc/hook.go
View file @
74f018df
...
...
@@ -28,7 +28,7 @@ type HookRunArgs struct {
func
(
h
*
hook
)
Run
(
name
string
,
ui
packer
.
Ui
,
comm
packer
.
Communicator
,
data
interface
{})
error
{
nextId
:=
h
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
h
.
mux
,
nextId
)
server
:=
n
ewServerWithMux
(
h
.
mux
,
nextId
)
server
.
RegisterCommunicator
(
comm
)
server
.
RegisterUi
(
ui
)
go
server
.
Serve
()
...
...
@@ -50,7 +50,7 @@ func (h *hook) Cancel() {
}
func
(
h
*
HookServer
)
Run
(
args
*
HookRunArgs
,
reply
*
interface
{})
error
{
client
,
err
:=
N
ewClientWithMux
(
h
.
mux
,
args
.
StreamId
)
client
,
err
:=
n
ewClientWithMux
(
h
.
mux
,
args
.
StreamId
)
if
err
!=
nil
{
return
NewBasicError
(
err
)
}
...
...
packer/rpc/post_processor.go
View file @
74f018df
...
...
@@ -41,7 +41,7 @@ func (p *postProcessor) Configure(raw ...interface{}) (err error) {
func
(
p
*
postProcessor
)
PostProcess
(
ui
packer
.
Ui
,
a
packer
.
Artifact
)
(
packer
.
Artifact
,
bool
,
error
)
{
nextId
:=
p
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
p
.
mux
,
nextId
)
server
:=
n
ewServerWithMux
(
p
.
mux
,
nextId
)
server
.
RegisterArtifact
(
a
)
server
.
RegisterUi
(
ui
)
go
server
.
Serve
()
...
...
@@ -59,7 +59,7 @@ func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Art
return
nil
,
false
,
nil
}
client
,
err
:=
N
ewClientWithMux
(
p
.
mux
,
response
.
StreamId
)
client
,
err
:=
n
ewClientWithMux
(
p
.
mux
,
response
.
StreamId
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
...
...
@@ -77,7 +77,7 @@ func (p *PostProcessorServer) Configure(args *PostProcessorConfigureArgs, reply
}
func
(
p
*
PostProcessorServer
)
PostProcess
(
streamId
uint32
,
reply
*
PostProcessorProcessResponse
)
error
{
client
,
err
:=
N
ewClientWithMux
(
p
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
p
.
mux
,
streamId
)
if
err
!=
nil
{
return
NewBasicError
(
err
)
}
...
...
@@ -87,7 +87,7 @@ func (p *PostProcessorServer) PostProcess(streamId uint32, reply *PostProcessorP
artifactResult
,
keep
,
err
:=
p
.
p
.
PostProcess
(
client
.
Ui
(),
client
.
Artifact
())
if
err
==
nil
&&
artifactResult
!=
nil
{
streamId
=
p
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
p
.
mux
,
streamId
)
server
:=
n
ewServerWithMux
(
p
.
mux
,
streamId
)
server
.
RegisterArtifact
(
artifactResult
)
go
server
.
Serve
()
}
...
...
packer/rpc/provisioner.go
View file @
74f018df
...
...
@@ -35,7 +35,7 @@ func (p *provisioner) Prepare(configs ...interface{}) (err error) {
func
(
p
*
provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
error
{
nextId
:=
p
.
mux
.
NextId
()
server
:=
N
ewServerWithMux
(
p
.
mux
,
nextId
)
server
:=
n
ewServerWithMux
(
p
.
mux
,
nextId
)
server
.
RegisterCommunicator
(
comm
)
server
.
RegisterUi
(
ui
)
go
server
.
Serve
()
...
...
@@ -60,7 +60,7 @@ func (p *ProvisionerServer) Prepare(args *ProvisionerPrepareArgs, reply *error)
}
func
(
p
*
ProvisionerServer
)
Provision
(
streamId
uint32
,
reply
*
interface
{})
error
{
client
,
err
:=
N
ewClientWithMux
(
p
.
mux
,
streamId
)
client
,
err
:=
n
ewClientWithMux
(
p
.
mux
,
streamId
)
if
err
!=
nil
{
return
NewBasicError
(
err
)
}
...
...
packer/rpc/server.go
View file @
74f018df
...
...
@@ -36,12 +36,12 @@ type Server struct {
// NewServer returns a new Packer RPC server.
func
NewServer
(
conn
io
.
ReadWriteCloser
)
*
Server
{
result
:=
N
ewServerWithMux
(
NewMuxConn
(
conn
,
1
),
0
)
result
:=
n
ewServerWithMux
(
NewMuxConn
(
conn
,
1
),
0
)
result
.
closeMux
=
true
return
result
}
func
N
ewServerWithMux
(
mux
*
MuxConn
,
streamId
uint32
)
*
Server
{
func
n
ewServerWithMux
(
mux
*
MuxConn
,
streamId
uint32
)
*
Server
{
return
&
Server
{
mux
:
mux
,
streamId
:
streamId
,
...
...
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