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
9bb24e6d
Commit
9bb24e6d
authored
Jun 05, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: Return proper nil artifact if nil is returned
parent
cd3523fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
packer/rpc/builder.go
packer/rpc/builder.go
+14
-5
packer/rpc/builder_test.go
packer/rpc/builder_test.go
+13
-1
No files found.
packer/rpc/builder.go
View file @
9bb24e6d
...
...
@@ -84,7 +84,12 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
panic
(
err
)
}
client
,
err
:=
rpc
.
Dial
(
"tcp"
,
<-
artifactAddress
)
address
:=
<-
artifactAddress
if
address
==
""
{
return
nil
}
client
,
err
:=
rpc
.
Dial
(
"tcp"
,
address
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -127,12 +132,16 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error {
hook
:=
Hook
(
client
)
ui
:=
&
Ui
{
client
}
artifact
:=
b
.
builder
.
Run
(
ui
,
hook
)
responseAddress
:=
""
// Wrap the artifact
server
:=
rpc
.
NewServer
()
RegisterArtifact
(
server
,
artifact
)
if
artifact
!=
nil
{
// Wrap the artifact
server
:=
rpc
.
NewServer
()
RegisterArtifact
(
server
,
artifact
)
responseAddress
=
serveSingleConn
(
server
)
}
responseWriter
.
Encode
(
&
BuilderRunResponse
{
serveSingleConn
(
server
)
})
responseWriter
.
Encode
(
&
BuilderRunResponse
{
responseAddress
})
}()
return
nil
...
...
packer/rpc/builder_test.go
View file @
9bb24e6d
...
...
@@ -16,6 +16,8 @@ type testBuilder struct {
runHook
packer
.
Hook
runUi
packer
.
Ui
cancelCalled
bool
nilRunResult
bool
}
func
(
b
*
testBuilder
)
Prepare
(
config
interface
{})
error
{
...
...
@@ -28,7 +30,12 @@ func (b *testBuilder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
b
.
runCalled
=
true
b
.
runHook
=
hook
b
.
runUi
=
ui
return
testBuilderArtifact
if
!
b
.
nilRunResult
{
return
testBuilderArtifact
}
else
{
return
nil
}
}
func
(
b
*
testBuilder
)
Cancel
()
{
...
...
@@ -74,6 +81,11 @@ func TestBuilderRPC(t *testing.T) {
assert
.
Equal
(
artifact
.
Id
(),
testBuilderArtifact
.
Id
(),
"should have artifact Id"
)
}
// Test run with nil result
b
.
nilRunResult
=
true
artifact
=
bClient
.
Run
(
ui
,
hook
)
assert
.
Nil
(
artifact
,
"should be nil"
)
// Test Cancel
bClient
.
Cancel
()
assert
.
True
(
b
.
cancelCalled
,
"cancel should be called"
)
...
...
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