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
30a061a8
Commit
30a061a8
authored
Jun 03, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Build.Cancel
parent
0ba80c88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
packer/build.go
packer/build.go
+5
-0
packer/rpc/build.go
packer/rpc/build.go
+11
-0
packer/rpc/build_test.go
packer/rpc/build_test.go
+9
-0
No files found.
packer/build.go
View file @
30a061a8
...
@@ -8,6 +8,7 @@ type Build interface {
...
@@ -8,6 +8,7 @@ type Build interface {
Name
()
string
Name
()
string
Prepare
(
Ui
)
error
Prepare
(
Ui
)
error
Run
(
Ui
)
Artifact
Run
(
Ui
)
Artifact
Cancel
()
}
}
// A build struct represents a single build job, the result of which should
// A build struct represents a single build job, the result of which should
...
@@ -87,3 +88,7 @@ func (b *coreBuild) Run(ui Ui) Artifact {
...
@@ -87,3 +88,7 @@ func (b *coreBuild) Run(ui Ui) Artifact {
hook
:=
&
DispatchHook
{
hooks
}
hook
:=
&
DispatchHook
{
hooks
}
return
b
.
builder
.
Run
(
ui
,
hook
)
return
b
.
builder
.
Run
(
ui
,
hook
)
}
}
// Cancels the build if it is running.
func
(
b
*
coreBuild
)
Cancel
()
{
}
packer/rpc/build.go
View file @
30a061a8
...
@@ -68,6 +68,12 @@ func (b *build) Run(ui packer.Ui) packer.Artifact {
...
@@ -68,6 +68,12 @@ func (b *build) Run(ui packer.Ui) packer.Artifact {
return
Artifact
(
client
)
return
Artifact
(
client
)
}
}
func
(
b
*
build
)
Cancel
()
{
if
err
:=
b
.
client
.
Call
(
"Build.Cancel"
,
new
(
interface
{}),
new
(
interface
{}));
err
!=
nil
{
panic
(
err
)
}
}
func
(
b
*
BuildServer
)
Name
(
args
*
interface
{},
reply
*
string
)
error
{
func
(
b
*
BuildServer
)
Name
(
args
*
interface
{},
reply
*
string
)
error
{
*
reply
=
b
.
build
.
Name
()
*
reply
=
b
.
build
.
Name
()
return
nil
return
nil
...
@@ -98,3 +104,8 @@ func (b *BuildServer) Run(args *BuildRunArgs, reply *string) error {
...
@@ -98,3 +104,8 @@ func (b *BuildServer) Run(args *BuildRunArgs, reply *string) error {
*
reply
=
serveSingleConn
(
server
)
*
reply
=
serveSingleConn
(
server
)
return
nil
return
nil
}
}
func
(
b
*
BuildServer
)
Cancel
(
args
*
interface
{},
reply
*
interface
{})
error
{
b
.
build
.
Cancel
()
return
nil
}
packer/rpc/build_test.go
View file @
30a061a8
...
@@ -15,6 +15,7 @@ type testBuild struct {
...
@@ -15,6 +15,7 @@ type testBuild struct {
prepareUi
packer
.
Ui
prepareUi
packer
.
Ui
runCalled
bool
runCalled
bool
runUi
packer
.
Ui
runUi
packer
.
Ui
cancelCalled
bool
}
}
func
(
b
*
testBuild
)
Name
()
string
{
func
(
b
*
testBuild
)
Name
()
string
{
...
@@ -34,6 +35,10 @@ func (b *testBuild) Run(ui packer.Ui) packer.Artifact {
...
@@ -34,6 +35,10 @@ func (b *testBuild) Run(ui packer.Ui) packer.Artifact {
return
testBuildArtifact
return
testBuildArtifact
}
}
func
(
b
*
testBuild
)
Cancel
()
{
b
.
cancelCalled
=
true
}
func
TestBuildRPC
(
t
*
testing
.
T
)
{
func
TestBuildRPC
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
...
@@ -70,6 +75,10 @@ func TestBuildRPC(t *testing.T) {
...
@@ -70,6 +75,10 @@ func TestBuildRPC(t *testing.T) {
assert
.
True
(
ui
.
sayCalled
,
"say should be called"
)
assert
.
True
(
ui
.
sayCalled
,
"say should be called"
)
assert
.
Equal
(
ui
.
sayMessage
,
"format"
,
"message should be correct"
)
assert
.
Equal
(
ui
.
sayMessage
,
"format"
,
"message should be correct"
)
}
}
// Test Cancel
bClient
.
Cancel
()
assert
.
True
(
b
.
cancelCalled
,
"cancel should be called"
)
}
}
func
TestBuild_ImplementsBuild
(
t
*
testing
.
T
)
{
func
TestBuild_ImplementsBuild
(
t
*
testing
.
T
)
{
...
...
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