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
587d3598
Commit
587d3598
authored
May 09, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Builder.Prepare can return an error
parent
d6efe3c7
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
22 deletions
+28
-22
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+3
-1
packer/build.go
packer/build.go
+4
-4
packer/build_test.go
packer/build_test.go
+2
-1
packer/plugin/builder.go
packer/plugin/builder.go
+2
-2
packer/plugin/builder_test.go
packer/plugin/builder_test.go
+3
-1
packer/rpc/build.go
packer/rpc/build.go
+5
-6
packer/rpc/build_test.go
packer/rpc/build_test.go
+2
-1
packer/rpc/builder.go
packer/rpc/builder.go
+5
-5
packer/rpc/builder_test.go
packer/rpc/builder_test.go
+2
-1
No files found.
builder/amazonebs/builder.go
View file @
587d3598
...
...
@@ -15,6 +15,8 @@ type Builder struct {
config
config
}
func
(
*
Builder
)
Prepare
(
interface
{})
{}
func
(
*
Builder
)
Prepare
(
interface
{})
error
{
return
nil
}
func
(
*
Builder
)
Run
(
packer
.
Build
,
packer
.
Ui
)
{}
packer/build.go
View file @
587d3598
...
...
@@ -3,7 +3,7 @@ package packer
// 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
{
Prepare
()
Prepare
()
error
Run
(
ui
Ui
)
}
...
...
@@ -29,15 +29,15 @@ type coreBuild struct {
//
// Run is where the actual build should take place. It takes a Build and a Ui.
type
Builder
interface
{
Prepare
(
config
interface
{})
Prepare
(
config
interface
{})
error
Run
(
build
Build
,
ui
Ui
)
}
// 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
()
{
func
(
b
*
coreBuild
)
Prepare
()
error
{
b
.
prepareCalled
=
true
b
.
builder
.
Prepare
(
b
.
rawConfig
)
return
b
.
builder
.
Prepare
(
b
.
rawConfig
)
}
// Runs the actual build. Prepare must be called prior to running this.
...
...
packer/build_test.go
View file @
587d3598
...
...
@@ -13,9 +13,10 @@ type TestBuilder struct {
runUi
Ui
}
func
(
tb
*
TestBuilder
)
Prepare
(
config
interface
{})
{
func
(
tb
*
TestBuilder
)
Prepare
(
config
interface
{})
error
{
tb
.
prepareCalled
=
true
tb
.
prepareConfig
=
config
return
nil
}
func
(
tb
*
TestBuilder
)
Run
(
b
Build
,
ui
Ui
)
{
...
...
packer/plugin/builder.go
View file @
587d3598
...
...
@@ -13,13 +13,13 @@ type cmdBuilder struct {
client
*
client
}
func
(
b
*
cmdBuilder
)
Prepare
(
config
interface
{})
{
func
(
b
*
cmdBuilder
)
Prepare
(
config
interface
{})
error
{
defer
func
()
{
r
:=
recover
()
b
.
checkExit
(
r
,
nil
)
}()
b
.
builder
.
Prepare
(
config
)
return
b
.
builder
.
Prepare
(
config
)
}
func
(
b
*
cmdBuilder
)
Run
(
build
packer
.
Build
,
ui
packer
.
Ui
)
{
...
...
packer/plugin/builder_test.go
View file @
587d3598
...
...
@@ -9,7 +9,9 @@ import (
type
helperBuilder
byte
func
(
helperBuilder
)
Prepare
(
interface
{})
{}
func
(
helperBuilder
)
Prepare
(
interface
{})
error
{
return
nil
}
func
(
helperBuilder
)
Run
(
packer
.
Build
,
packer
.
Ui
)
{}
...
...
packer/rpc/build.go
View file @
587d3598
...
...
@@ -23,8 +23,9 @@ type BuildRunArgs struct {
UiRPCAddress
string
}
func
(
b
*
Build
)
Prepare
()
{
b
.
client
.
Call
(
"Build.Prepare"
,
new
(
interface
{}),
new
(
interface
{}))
func
(
b
*
Build
)
Prepare
()
(
err
error
)
{
b
.
client
.
Call
(
"Build.Prepare"
,
new
(
interface
{}),
&
err
)
return
}
func
(
b
*
Build
)
Run
(
ui
packer
.
Ui
)
{
...
...
@@ -36,10 +37,8 @@ func (b *Build) Run(ui packer.Ui) {
b
.
client
.
Call
(
"Build.Run"
,
args
,
new
(
interface
{}))
}
func
(
b
*
BuildServer
)
Prepare
(
args
*
BuildPrepareArgs
,
reply
*
interface
{})
error
{
b
.
build
.
Prepare
()
*
reply
=
nil
func
(
b
*
BuildServer
)
Prepare
(
args
*
BuildPrepareArgs
,
reply
*
error
)
error
{
*
reply
=
b
.
build
.
Prepare
()
return
nil
}
...
...
packer/rpc/build_test.go
View file @
587d3598
...
...
@@ -13,8 +13,9 @@ type testBuild struct {
runUi
packer
.
Ui
}
func
(
b
*
testBuild
)
Prepare
()
{
func
(
b
*
testBuild
)
Prepare
()
error
{
b
.
prepareCalled
=
true
return
nil
}
func
(
b
*
testBuild
)
Run
(
ui
packer
.
Ui
)
{
...
...
packer/rpc/builder.go
View file @
587d3598
...
...
@@ -29,8 +29,9 @@ func Builder(client *rpc.Client) *builder {
return
&
builder
{
client
}
}
func
(
b
*
builder
)
Prepare
(
config
interface
{})
{
b
.
client
.
Call
(
"Builder.Prepare"
,
&
BuilderPrepareArgs
{
config
},
new
(
interface
{}))
func
(
b
*
builder
)
Prepare
(
config
interface
{})
(
err
error
)
{
b
.
client
.
Call
(
"Builder.Prepare"
,
&
BuilderPrepareArgs
{
config
},
&
err
)
return
}
func
(
b
*
builder
)
Run
(
build
packer
.
Build
,
ui
packer
.
Ui
)
{
...
...
@@ -44,9 +45,8 @@ func (b *builder) Run(build packer.Build, ui packer.Ui) {
b
.
client
.
Call
(
"Builder.Run"
,
args
,
new
(
interface
{}))
}
func
(
b
*
BuilderServer
)
Prepare
(
args
*
BuilderPrepareArgs
,
reply
*
interface
{})
error
{
b
.
builder
.
Prepare
(
args
.
Config
)
*
reply
=
nil
func
(
b
*
BuilderServer
)
Prepare
(
args
*
BuilderPrepareArgs
,
reply
*
error
)
error
{
*
reply
=
b
.
builder
.
Prepare
(
args
.
Config
)
return
nil
}
...
...
packer/rpc/builder_test.go
View file @
587d3598
...
...
@@ -15,9 +15,10 @@ type testBuilder struct {
runUi
packer
.
Ui
}
func
(
b
*
testBuilder
)
Prepare
(
config
interface
{})
{
func
(
b
*
testBuilder
)
Prepare
(
config
interface
{})
error
{
b
.
prepareCalled
=
true
b
.
prepareConfig
=
config
return
nil
}
func
(
b
*
testBuilder
)
Run
(
build
packer
.
Build
,
ui
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