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
8217e64a
Commit
8217e64a
authored
Jun 14, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Set DebugConfigKey to true if debug is on
parent
fd044982
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
packer/build.go
packer/build.go
+14
-2
packer/build_test.go
packer/build_test.go
+23
-3
No files found.
packer/build.go
View file @
8217e64a
...
...
@@ -2,6 +2,10 @@ package packer
import
"log"
// This is the key in configurations that is set to "true" when Packer
// debugging is enabled.
const
DebugConfigKey
=
"packer_config"
// A Build represents a single job within Packer that is responsible for
// building some machine image artifact. Builds are meant to be parallelized.
type
Build
interface
{
...
...
@@ -65,8 +69,12 @@ func (b *coreBuild) Prepare() (err error) {
// TODO: lock
b
.
prepareCalled
=
true
debugConfig
:=
map
[
string
]
interface
{}{
DebugConfigKey
:
b
.
debug
,
}
// Prepare the builder
err
=
b
.
builder
.
Prepare
(
b
.
builderConfig
)
err
=
b
.
builder
.
Prepare
(
b
.
builderConfig
,
debugConfig
)
if
err
!=
nil
{
log
.
Printf
(
"Build '%s' prepare failure: %s
\n
"
,
b
.
name
,
err
)
return
...
...
@@ -74,7 +82,11 @@ func (b *coreBuild) Prepare() (err error) {
// Prepare the provisioners
for
_
,
coreProv
:=
range
b
.
provisioners
{
if
err
=
coreProv
.
provisioner
.
Prepare
(
coreProv
.
config
...
);
err
!=
nil
{
configs
:=
make
([]
interface
{},
len
(
coreProv
.
config
),
len
(
coreProv
.
config
)
+
1
)
copy
(
configs
,
coreProv
.
config
)
configs
=
append
(
configs
,
debugConfig
)
if
err
=
coreProv
.
provisioner
.
Prepare
(
configs
...
);
err
!=
nil
{
return
}
}
...
...
packer/build_test.go
View file @
8217e64a
...
...
@@ -33,20 +33,40 @@ func TestBuild_Name(t *testing.T) {
func
TestBuild_Prepare
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
debugFalseConfig
:=
map
[
string
]
interface
{}{
DebugConfigKey
:
false
}
build
:=
testBuild
()
coreB
:=
build
.
(
*
coreBuild
)
builder
:=
coreB
.
builder
.
(
*
TestBuilder
)
build
.
Prepare
()
assert
.
True
(
builder
.
prepareCalled
,
"prepare should be called"
)
assert
.
Equal
(
builder
.
prepareConfig
,
[]
interface
{}{
42
,
debugFalseConfig
},
"prepare config should be 42"
)
coreProv
:=
coreB
.
provisioners
[
0
]
prov
:=
coreProv
.
provisioner
.
(
*
TestProvisioner
)
assert
.
True
(
prov
.
prepCalled
,
"prepare should be called"
)
assert
.
Equal
(
prov
.
prepConfigs
,
[]
interface
{}{
42
,
debugFalseConfig
},
"prepare should be called with proper config"
)
}
func
TestBuild_Prepare_Debug
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
debugConfig
:=
map
[
string
]
interface
{}{
DebugConfigKey
:
true
}
build
:=
testBuild
()
coreB
:=
build
.
(
*
coreBuild
)
builder
:=
coreB
.
builder
.
(
*
TestBuilder
)
build
.
SetDebug
(
true
)
build
.
Prepare
()
assert
.
True
(
builder
.
prepareCalled
,
"prepare should be called"
)
assert
.
Equal
(
builder
.
prepareConfig
,
[]
interface
{}{
42
},
"prepare config should be 42"
)
assert
.
Equal
(
builder
.
prepareConfig
,
[]
interface
{}{
42
,
debugConfig
},
"prepare config should be 42"
)
// Verify provisioners were prepared
coreProv
:=
coreB
.
provisioners
[
0
]
prov
:=
coreProv
.
provisioner
.
(
*
TestProvisioner
)
assert
.
True
(
prov
.
prepCalled
,
"prepare should be called"
)
assert
.
Equal
(
prov
.
prepConfigs
,
[]
interface
{}{
42
},
"prepare should be called with proper config"
)
assert
.
Equal
(
prov
.
prepConfigs
,
[]
interface
{}{
42
,
debugConfig
},
"prepare should be called with proper config"
)
}
func
TestBuild_Run
(
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