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
9f5a2475
Commit
9f5a2475
authored
Jun 14, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Builders can take multiple configs
parent
a45c7fb0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
17 deletions
+24
-17
packer/build_test.go
packer/build_test.go
+1
-1
packer/builder.go
packer/builder.go
+12
-5
packer/builder_test.go
packer/builder_test.go
+2
-2
packer/plugin/builder.go
packer/plugin/builder.go
+2
-2
packer/plugin/builder_test.go
packer/plugin/builder_test.go
+1
-1
packer/rpc/builder.go
packer/rpc/builder.go
+3
-3
packer/rpc/builder_test.go
packer/rpc/builder_test.go
+3
-3
No files found.
packer/build_test.go
View file @
9f5a2475
...
...
@@ -40,7 +40,7 @@ func TestBuild_Prepare(t *testing.T) {
build
.
Prepare
()
assert
.
True
(
builder
.
prepareCalled
,
"prepare should be called"
)
assert
.
Equal
(
builder
.
prepareConfig
,
42
,
"prepare config should be 42"
)
assert
.
Equal
(
builder
.
prepareConfig
,
[]
interface
{}{
42
}
,
"prepare config should be 42"
)
// Verify provisioners were prepared
coreProv
:=
coreB
.
provisioners
[
0
]
...
...
packer/builder.go
View file @
9f5a2475
...
...
@@ -3,11 +3,18 @@ package packer
// Implementers of Builder are responsible for actually building images
// on some platform given some configuration.
type
Builder
interface
{
// Prepare is responsible for reading in some configuration, in the raw form
// of map[string]interface{}, and storing that state for use later. Any setup
// should be done in this method. Note that NO side effects should really take
// place in prepare. It is meant as a state setup step only.
Prepare
(
config
interface
{})
error
// Prepare is responsible for configuring the builder and validating
// that configuration. Any setup should be done in this method. Note that
// NO side effects should take place in prepare, it is meant as a state
// setup only. Calling Prepare is not necessarilly followed by a Run.
//
// The parameters to Prepare are a set of interface{} values of the
// configuration. These are almost always `map[string]interface{}`
// parsed from a template, but no guarantee is made.
//
// Each of the configuration values should merge into the final
// configuration.
Prepare
(
...
interface
{})
error
// Run is where the actual build should take place. It takes a Build and a Ui.
Run
(
ui
Ui
,
hook
Hook
,
cache
Cache
)
(
Artifact
,
error
)
...
...
packer/builder_test.go
View file @
9f5a2475
...
...
@@ -2,7 +2,7 @@ package packer
type
TestBuilder
struct
{
prepareCalled
bool
prepareConfig
interface
{}
prepareConfig
[]
interface
{}
runCalled
bool
runCache
Cache
runHook
Hook
...
...
@@ -10,7 +10,7 @@ type TestBuilder struct {
cancelCalled
bool
}
func
(
tb
*
TestBuilder
)
Prepare
(
config
interface
{})
error
{
func
(
tb
*
TestBuilder
)
Prepare
(
config
...
interface
{})
error
{
tb
.
prepareCalled
=
true
tb
.
prepareConfig
=
config
return
nil
...
...
packer/plugin/builder.go
View file @
9f5a2475
...
...
@@ -10,13 +10,13 @@ type cmdBuilder struct {
client
*
Client
}
func
(
b
*
cmdBuilder
)
Prepare
(
config
interface
{})
error
{
func
(
b
*
cmdBuilder
)
Prepare
(
config
...
interface
{})
error
{
defer
func
()
{
r
:=
recover
()
b
.
checkExit
(
r
,
nil
)
}()
return
b
.
builder
.
Prepare
(
config
)
return
b
.
builder
.
Prepare
(
config
...
)
}
func
(
b
*
cmdBuilder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
packer/plugin/builder_test.go
View file @
9f5a2475
...
...
@@ -8,7 +8,7 @@ import (
type
helperBuilder
byte
func
(
helperBuilder
)
Prepare
(
interface
{})
error
{
func
(
helperBuilder
)
Prepare
(
...
interface
{})
error
{
return
nil
}
...
...
packer/rpc/builder.go
View file @
9f5a2475
...
...
@@ -21,7 +21,7 @@ type BuilderServer struct {
}
type
BuilderPrepareArgs
struct
{
Config
interface
{}
Config
s
[]
interface
{}
}
type
BuilderRunArgs
struct
{
...
...
@@ -38,7 +38,7 @@ func Builder(client *rpc.Client) *builder {
return
&
builder
{
client
}
}
func
(
b
*
builder
)
Prepare
(
config
interface
{})
(
err
error
)
{
func
(
b
*
builder
)
Prepare
(
config
...
interface
{})
(
err
error
)
{
cerr
:=
b
.
client
.
Call
(
"Builder.Prepare"
,
&
BuilderPrepareArgs
{
config
},
&
err
)
if
cerr
!=
nil
{
err
=
cerr
...
...
@@ -109,7 +109,7 @@ func (b *builder) Cancel() {
}
func
(
b
*
BuilderServer
)
Prepare
(
args
*
BuilderPrepareArgs
,
reply
*
error
)
error
{
err
:=
b
.
builder
.
Prepare
(
args
.
Config
)
err
:=
b
.
builder
.
Prepare
(
args
.
Config
s
...
)
if
err
!=
nil
{
*
reply
=
NewBasicError
(
err
)
}
...
...
packer/rpc/builder_test.go
View file @
9f5a2475
...
...
@@ -12,7 +12,7 @@ var testBuilderArtifact = &testArtifact{}
type
testBuilder
struct
{
prepareCalled
bool
prepareConfig
interface
{}
prepareConfig
[]
interface
{}
runCalled
bool
runCache
packer
.
Cache
runHook
packer
.
Hook
...
...
@@ -23,7 +23,7 @@ type testBuilder struct {
nilRunResult
bool
}
func
(
b
*
testBuilder
)
Prepare
(
config
interface
{})
error
{
func
(
b
*
testBuilder
)
Prepare
(
config
...
interface
{})
error
{
b
.
prepareCalled
=
true
b
.
prepareConfig
=
config
return
nil
...
...
@@ -68,7 +68,7 @@ func TestBuilderRPC(t *testing.T) {
bClient
:=
Builder
(
client
)
bClient
.
Prepare
(
config
)
assert
.
True
(
b
.
prepareCalled
,
"prepare should be called"
)
assert
.
Equal
(
b
.
prepareConfig
,
42
,
"prepare should be called with right arg"
)
assert
.
Equal
(
b
.
prepareConfig
,
[]
interface
{}{
42
}
,
"prepare should be called with right arg"
)
// Test Run
cache
:=
new
(
testCache
)
...
...
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