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
8d4ba1fc
Commit
8d4ba1fc
authored
Dec 10, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: complete command
parent
a8b056e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
21 deletions
+15
-21
packer/rpc/command.go
packer/rpc/command.go
+14
-11
packer/rpc/command_test.go
packer/rpc/command_test.go
+0
-5
packer/rpc/post_processor.go
packer/rpc/post_processor.go
+0
-4
packer/rpc/post_processor_test.go
packer/rpc/post_processor_test.go
+1
-1
No files found.
packer/rpc/command.go
View file @
8d4ba1fc
...
...
@@ -20,8 +20,8 @@ type CommandServer struct {
}
type
CommandRunArgs
struct
{
RPCAddress
string
Args
[]
string
StreamId
uint32
}
type
CommandSynopsisArgs
byte
...
...
@@ -40,11 +40,15 @@ func (c *command) Help() (result string) {
}
func
(
c
*
command
)
Run
(
env
packer
.
Environment
,
args
[]
string
)
(
result
int
)
{
// Create and start the server for the Environment
server
:=
rpc
.
NewServer
()
RegisterEnvironment
(
server
,
env
)
rpcArgs
:=
&
CommandRunArgs
{
serveSingleConn
(
server
),
args
}
nextId
:=
c
.
mux
.
NextId
()
server
:=
NewServerWithMux
(
c
.
mux
,
nextId
)
server
.
RegisterEnvironment
(
env
)
go
server
.
Serve
()
rpcArgs
:=
&
CommandRunArgs
{
Args
:
args
,
StreamId
:
nextId
,
}
err
:=
c
.
client
.
Call
(
"Command.Run"
,
rpcArgs
,
&
result
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -68,14 +72,13 @@ func (c *CommandServer) Help(args *interface{}, reply *string) error {
}
func
(
c
*
CommandServer
)
Run
(
args
*
CommandRunArgs
,
reply
*
int
)
error
{
client
,
err
:=
rpcDial
(
args
.
RPCAddress
)
client
,
err
:=
NewClientWithMux
(
c
.
mux
,
args
.
StreamId
)
if
err
!=
nil
{
return
err
return
NewBasicError
(
err
)
}
defer
client
.
Close
()
env
:=
&
Environment
{
client
:
client
}
*
reply
=
c
.
command
.
Run
(
env
,
args
.
Args
)
*
reply
=
c
.
command
.
Run
(
client
.
Environment
(),
args
.
Args
)
return
nil
}
...
...
packer/rpc/command_test.go
View file @
8d4ba1fc
...
...
@@ -59,11 +59,6 @@ func TestRPCCommand(t *testing.T) {
t
.
Fatal
(
"runEnv should not be nil"
)
}
command
.
runEnv
.
Ui
()
if
!
testEnv
.
uiCalled
{
t
.
Fatal
(
"ui should be called"
)
}
// Test Synopsis
synopsis
:=
commClient
.
Synopsis
()
if
synopsis
!=
"foo"
{
...
...
packer/rpc/post_processor.go
View file @
8d4ba1fc
...
...
@@ -30,10 +30,6 @@ type PostProcessorProcessResponse struct {
StreamId
uint32
}
func
PostProcessor
(
client
*
rpc
.
Client
)
*
postProcessor
{
return
&
postProcessor
{
client
:
client
}
}
func
(
p
*
postProcessor
)
Configure
(
raw
...
interface
{})
(
err
error
)
{
args
:=
&
PostProcessorConfigureArgs
{
Configs
:
raw
}
if
cerr
:=
p
.
client
.
Call
(
"PostProcessor.Configure"
,
args
,
&
err
);
cerr
!=
nil
{
...
...
packer/rpc/post_processor_test.go
View file @
8d4ba1fc
...
...
@@ -83,7 +83,7 @@ func TestPostProcessorRPC(t *testing.T) {
func
TestPostProcessor_Implements
(
t
*
testing
.
T
)
{
var
raw
interface
{}
raw
=
PostProcessor
(
nil
)
raw
=
new
(
postProcessor
)
if
_
,
ok
:=
raw
.
(
packer
.
PostProcessor
);
!
ok
{
t
.
Fatal
(
"not a postprocessor"
)
}
...
...
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