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
0f57370d
Commit
0f57370d
authored
May 22, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Prepare provisioners as part of Build prepare
parent
cb91ca72
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
packer/build.go
packer/build.go
+9
-0
packer/build_test.go
packer/build_test.go
+13
-1
packer/provisioner_test.go
packer/provisioner_test.go
+5
-1
packer/rpc/build_test.go
packer/rpc/build_test.go
+1
-1
No files found.
packer/build.go
View file @
0f57370d
...
...
@@ -39,12 +39,21 @@ func (b *coreBuild) Name() string {
// Prepare prepares the build by doing some initialization for the builder
// and any hooks. This _must_ be called prior to Run.
func
(
b
*
coreBuild
)
Prepare
(
ui
Ui
)
(
err
error
)
{
// TODO: lock
b
.
prepareCalled
=
true
// Prepare the builder
err
=
b
.
builder
.
Prepare
(
b
.
builderConfig
)
if
err
!=
nil
{
log
.
Printf
(
"Build '%s' prepare failure: %s
\n
"
,
b
.
name
,
err
)
}
// Prepare the provisioners
// TODO: error handling
for
_
,
coreProv
:=
range
b
.
provisioners
{
coreProv
.
provisioner
.
Prepare
(
coreProv
.
config
,
ui
)
}
return
}
...
...
packer/build_test.go
View file @
0f57370d
...
...
@@ -31,6 +31,9 @@ func testBuild() Build {
name
:
"test"
,
builder
:
&
TestBuilder
{},
builderConfig
:
42
,
provisioners
:
[]
coreBuildProvisioner
{
coreBuildProvisioner
{
&
TestProvisioner
{},
42
},
},
}
}
...
...
@@ -65,10 +68,19 @@ func TestBuild_Run(t *testing.T) {
build
.
Prepare
(
ui
)
build
.
Run
(
ui
)
builder
:=
build
.
(
*
coreBuild
)
.
builder
.
(
*
TestBuilder
)
coreB
:=
build
.
(
*
coreBuild
)
// Verify builder was prepared
builder
:=
coreB
.
builder
.
(
*
TestBuilder
)
assert
.
True
(
builder
.
runCalled
,
"run should be called"
)
assert
.
Equal
(
builder
.
runUi
,
ui
,
"run should be called with ui"
)
// Verify provisioners were prepared
coreProv
:=
coreB
.
provisioners
[
0
]
prov
:=
coreProv
.
provisioner
.
(
*
TestProvisioner
)
assert
.
True
(
prov
.
prepCalled
,
"prepare should be called"
)
assert
.
Equal
(
prov
.
prepConfig
,
42
,
"prepare should be called with proper config"
)
assert
.
Equal
(
prov
.
prepUi
,
ui
,
"prepare should be called with proper ui"
)
}
func
TestBuild_RunBeforePrepare
(
t
*
testing
.
T
)
{
...
...
packer/provisioner_test.go
View file @
0f57370d
...
...
@@ -2,11 +2,15 @@ package packer
type
TestProvisioner
struct
{
prepCalled
bool
prepConfig
interface
{}
prepUi
Ui
provCalled
bool
}
func
(
t
*
TestProvisioner
)
Prepare
(
interface
{},
Ui
)
{
func
(
t
*
TestProvisioner
)
Prepare
(
config
interface
{},
ui
Ui
)
{
t
.
prepCalled
=
true
t
.
prepConfig
=
config
t
.
prepUi
=
ui
}
func
(
t
*
TestProvisioner
)
Provision
(
Ui
,
Communicator
)
{
...
...
packer/rpc/build_test.go
View file @
0f57370d
...
...
@@ -12,7 +12,7 @@ var testBuildArtifact = &testArtifact{}
type
testBuild
struct
{
nameCalled
bool
prepareCalled
bool
prepareUi
packer
.
Ui
prepareUi
packer
.
Ui
runCalled
bool
runUi
packer
.
Ui
}
...
...
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