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
a45c7fb0
Commit
a45c7fb0
authored
Jun 14, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Add SetDebug to Build objects
parent
e00a30e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
6 deletions
+41
-6
packer/build.go
packer/build.go
+15
-0
packer/rpc/build.go
packer/rpc/build.go
+11
-0
packer/rpc/build_test.go
packer/rpc/build_test.go
+15
-6
No files found.
packer/build.go
View file @
a45c7fb0
...
...
@@ -21,6 +21,12 @@ type Build interface {
// Cancel will cancel a running build. This will block until the build
// is actually completely cancelled.
Cancel
()
// SetDebug will enable/disable debug mode. Debug mode is always
// enabled by adding the additional key "packer_debug" to boolean
// true in the configuration of the various components. This must
// be called prior to Prepare.
SetDebug
(
bool
)
}
// A build struct represents a single build job, the result of which should
...
...
@@ -34,6 +40,7 @@ type coreBuild struct {
hooks
map
[
string
][]
Hook
provisioners
[]
coreBuildProvisioner
debug
bool
prepareCalled
bool
}
...
...
@@ -103,6 +110,14 @@ func (b *coreBuild) Run(ui Ui, cache Cache) (Artifact, error) {
return
b
.
builder
.
Run
(
ui
,
hook
,
cache
)
}
func
(
b
*
coreBuild
)
SetDebug
(
val
bool
)
{
if
b
.
prepareCalled
{
panic
(
"prepare has already been called"
)
}
b
.
debug
=
val
}
// Cancels the build if it is running.
func
(
b
*
coreBuild
)
Cancel
()
{
b
.
builder
.
Cancel
()
...
...
packer/rpc/build.go
View file @
a45c7fb0
...
...
@@ -58,6 +58,12 @@ func (b *build) Run(ui packer.Ui, cache packer.Cache) (packer.Artifact, error) {
return
Artifact
(
client
),
nil
}
func
(
b
*
build
)
SetDebug
(
val
bool
)
{
if
err
:=
b
.
client
.
Call
(
"Build.SetDebug"
,
val
,
new
(
interface
{}));
err
!=
nil
{
panic
(
err
)
}
}
func
(
b
*
build
)
Cancel
()
{
if
err
:=
b
.
client
.
Call
(
"Build.Cancel"
,
new
(
interface
{}),
new
(
interface
{}));
err
!=
nil
{
panic
(
err
)
...
...
@@ -93,6 +99,11 @@ func (b *BuildServer) Run(args *BuildRunArgs, reply *string) error {
return
nil
}
func
(
b
*
BuildServer
)
SetDebug
(
val
*
bool
,
reply
*
interface
{})
error
{
b
.
build
.
SetDebug
(
*
val
)
return
nil
}
func
(
b
*
BuildServer
)
Cancel
(
args
*
interface
{},
reply
*
interface
{})
error
{
b
.
build
.
Cancel
()
return
nil
...
...
packer/rpc/build_test.go
View file @
a45c7fb0
...
...
@@ -11,12 +11,13 @@ import (
var
testBuildArtifact
=
&
testArtifact
{}
type
testBuild
struct
{
nameCalled
bool
prepareCalled
bool
runCalled
bool
runCache
packer
.
Cache
runUi
packer
.
Ui
cancelCalled
bool
nameCalled
bool
prepareCalled
bool
runCalled
bool
runCache
packer
.
Cache
runUi
packer
.
Ui
setDebugCalled
bool
cancelCalled
bool
errRunResult
bool
}
...
...
@@ -43,6 +44,10 @@ func (b *testBuild) Run(ui packer.Ui, cache packer.Cache) (packer.Artifact, erro
}
}
func
(
b
*
testBuild
)
SetDebug
(
bool
)
{
b
.
setDebugCalled
=
true
}
func
(
b
*
testBuild
)
Cancel
()
{
b
.
cancelCalled
=
true
}
...
...
@@ -93,6 +98,10 @@ func TestBuildRPC(t *testing.T) {
_
,
err
=
bClient
.
Run
(
ui
,
cache
)
assert
.
NotNil
(
err
,
"should not nil"
)
// Test SetDebug
bClient
.
SetDebug
(
true
)
assert
.
True
(
b
.
setDebugCalled
,
"should be called"
)
// 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