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
9600bf5b
Commit
9600bf5b
authored
May 09, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Build.Name
parent
587d3598
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
2 deletions
+45
-2
command/build/command.go
command/build/command.go
+6
-0
config.go
config.go
+3
-0
packer/build.go
packer/build.go
+6
-0
packer/build_test.go
packer/build_test.go
+7
-0
packer/rpc/build.go
packer/rpc/build.go
+10
-0
packer/rpc/build_test.go
packer/rpc/build_test.go
+12
-1
packer/rpc/builder_test.go
packer/rpc/builder_test.go
+1
-1
No files found.
command/build/command.go
View file @
9600bf5b
...
@@ -44,6 +44,12 @@ func (Command) Run(env packer.Environment, args []string) int {
...
@@ -44,6 +44,12 @@ func (Command) Run(env packer.Environment, args []string) int {
builds
=
append
(
builds
,
build
)
builds
=
append
(
builds
,
build
)
}
}
// Prepare all the builds
for
_
,
b
:=
range
builds
{
log
.
Printf
(
"Preparing build: %s
\n
"
,
b
.
Name
())
b
.
Prepare
()
}
env
.
Ui
()
.
Say
(
"YAY!
\n
"
)
env
.
Ui
()
.
Say
(
"YAY!
\n
"
)
return
0
return
0
}
}
...
...
config.go
View file @
9600bf5b
...
@@ -11,6 +11,9 @@ import (
...
@@ -11,6 +11,9 @@ import (
// This is the default, built-in configuration that ships with
// This is the default, built-in configuration that ships with
// Packer.
// Packer.
const
defaultConfig
=
`
const
defaultConfig
=
`
[builders]
amazon-ebs = "packer-builder-amazon-ebs"
[commands]
[commands]
build = "packer-command-build"
build = "packer-command-build"
`
`
...
...
packer/build.go
View file @
9600bf5b
...
@@ -3,6 +3,7 @@ package packer
...
@@ -3,6 +3,7 @@ package packer
// A Build represents a single job within Packer that is responsible for
// A Build represents a single job within Packer that is responsible for
// building some machine image artifact. Builds are meant to be parallelized.
// building some machine image artifact. Builds are meant to be parallelized.
type
Build
interface
{
type
Build
interface
{
Name
()
string
Prepare
()
error
Prepare
()
error
Run
(
ui
Ui
)
Run
(
ui
Ui
)
}
}
...
@@ -33,6 +34,11 @@ type Builder interface {
...
@@ -33,6 +34,11 @@ type Builder interface {
Run
(
build
Build
,
ui
Ui
)
Run
(
build
Build
,
ui
Ui
)
}
}
// Returns the name of the build.
func
(
b
*
coreBuild
)
Name
()
string
{
return
b
.
name
}
// Prepare prepares the build by doing some initialization for the builder
// Prepare prepares the build by doing some initialization for the builder
// and any hooks. This _must_ be called prior to Run.
// and any hooks. This _must_ be called prior to Run.
func
(
b
*
coreBuild
)
Prepare
()
error
{
func
(
b
*
coreBuild
)
Prepare
()
error
{
...
...
packer/build_test.go
View file @
9600bf5b
...
@@ -37,6 +37,13 @@ func testBuilder() *TestBuilder {
...
@@ -37,6 +37,13 @@ func testBuilder() *TestBuilder {
return
&
TestBuilder
{}
return
&
TestBuilder
{}
}
}
func
TestBuild_Name
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
build
:=
testBuild
()
assert
.
Equal
(
build
.
Name
(),
"test"
,
"should have a name"
)
}
func
TestBuild_Prepare
(
t
*
testing
.
T
)
{
func
TestBuild_Prepare
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
...
...
packer/rpc/build.go
View file @
9600bf5b
...
@@ -23,6 +23,11 @@ type BuildRunArgs struct {
...
@@ -23,6 +23,11 @@ type BuildRunArgs struct {
UiRPCAddress
string
UiRPCAddress
string
}
}
func
(
b
*
Build
)
Name
()
(
result
string
)
{
b
.
client
.
Call
(
"Build.Name"
,
new
(
interface
{}),
&
result
)
return
}
func
(
b
*
Build
)
Prepare
()
(
err
error
)
{
func
(
b
*
Build
)
Prepare
()
(
err
error
)
{
b
.
client
.
Call
(
"Build.Prepare"
,
new
(
interface
{}),
&
err
)
b
.
client
.
Call
(
"Build.Prepare"
,
new
(
interface
{}),
&
err
)
return
return
...
@@ -37,6 +42,11 @@ func (b *Build) Run(ui packer.Ui) {
...
@@ -37,6 +42,11 @@ func (b *Build) Run(ui packer.Ui) {
b
.
client
.
Call
(
"Build.Run"
,
args
,
new
(
interface
{}))
b
.
client
.
Call
(
"Build.Run"
,
args
,
new
(
interface
{}))
}
}
func
(
b
*
BuildServer
)
Name
(
args
*
interface
{},
reply
*
string
)
error
{
*
reply
=
b
.
build
.
Name
()
return
nil
}
func
(
b
*
BuildServer
)
Prepare
(
args
*
BuildPrepareArgs
,
reply
*
error
)
error
{
func
(
b
*
BuildServer
)
Prepare
(
args
*
BuildPrepareArgs
,
reply
*
error
)
error
{
*
reply
=
b
.
build
.
Prepare
()
*
reply
=
b
.
build
.
Prepare
()
return
nil
return
nil
...
...
packer/rpc/build_test.go
View file @
9600bf5b
...
@@ -8,11 +8,17 @@ import (
...
@@ -8,11 +8,17 @@ import (
)
)
type
testBuild
struct
{
type
testBuild
struct
{
nameCalled
bool
prepareCalled
bool
prepareCalled
bool
runCalled
bool
runCalled
bool
runUi
packer
.
Ui
runUi
packer
.
Ui
}
}
func
(
b
*
testBuild
)
Name
()
string
{
b
.
nameCalled
=
true
return
"name"
}
func
(
b
*
testBuild
)
Prepare
()
error
{
func
(
b
*
testBuild
)
Prepare
()
error
{
b
.
prepareCalled
=
true
b
.
prepareCalled
=
true
return
nil
return
nil
...
@@ -43,8 +49,13 @@ func TestBuildRPC(t *testing.T) {
...
@@ -43,8 +49,13 @@ func TestBuildRPC(t *testing.T) {
panic
(
err
)
panic
(
err
)
}
}
// Test Prepare
bClient
:=
&
Build
{
client
}
bClient
:=
&
Build
{
client
}
// Test Name
bClient
.
Name
()
assert
.
True
(
b
.
nameCalled
,
"name should be called"
)
// Test Prepare
bClient
.
Prepare
()
bClient
.
Prepare
()
assert
.
True
(
b
.
prepareCalled
,
"prepare should be called"
)
assert
.
True
(
b
.
prepareCalled
,
"prepare should be called"
)
...
...
packer/rpc/builder_test.go
View file @
9600bf5b
...
@@ -65,7 +65,7 @@ func TestBuilderRPC(t *testing.T) {
...
@@ -65,7 +65,7 @@ func TestBuilderRPC(t *testing.T) {
}
}
}
}
func
TestBuilder_ImplementsBuild
(
t
*
testing
.
T
)
{
func
TestBuilder_ImplementsBuild
er
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
var
realBuilder
packer
.
Builder
var
realBuilder
packer
.
Builder
...
...
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