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
a35feebe
Commit
a35feebe
authored
Jun 13, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Build no longer takes Ui for Prepare
parent
c8120bc2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
31 deletions
+12
-31
command/build/command.go
command/build/command.go
+1
-1
packer/build.go
packer/build.go
+2
-2
packer/build_test.go
packer/build_test.go
+2
-3
packer/rpc/build.go
packer/rpc/build.go
+4
-19
packer/rpc/build_test.go
packer/rpc/build_test.go
+3
-6
No files found.
command/build/command.go
View file @
a35feebe
...
@@ -144,7 +144,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
...
@@ -144,7 +144,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
// Prepare all the builds
// Prepare all the builds
for
_
,
b
:=
range
builds
{
for
_
,
b
:=
range
builds
{
log
.
Printf
(
"Preparing build: %s"
,
b
.
Name
())
log
.
Printf
(
"Preparing build: %s"
,
b
.
Name
())
err
:=
b
.
Prepare
(
buildUis
[
b
.
Name
()]
)
err
:=
b
.
Prepare
()
if
err
!=
nil
{
if
err
!=
nil
{
env
.
Ui
()
.
Error
(
err
.
Error
())
env
.
Ui
()
.
Error
(
err
.
Error
())
return
1
return
1
...
...
packer/build.go
View file @
a35feebe
...
@@ -6,7 +6,7 @@ import "log"
...
@@ -6,7 +6,7 @@ import "log"
// 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
Name
()
string
Prepare
(
Ui
)
error
Prepare
()
error
Run
(
Ui
,
Cache
)
(
Artifact
,
error
)
Run
(
Ui
,
Cache
)
(
Artifact
,
error
)
Cancel
()
Cancel
()
}
}
...
@@ -39,7 +39,7 @@ func (b *coreBuild) Name() string {
...
@@ -39,7 +39,7 @@ func (b *coreBuild) Name() string {
// 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
(
ui
Ui
)
(
err
error
)
{
func
(
b
*
coreBuild
)
Prepare
()
(
err
error
)
{
// TODO: lock
// TODO: lock
b
.
prepareCalled
=
true
b
.
prepareCalled
=
true
...
...
packer/build_test.go
View file @
a35feebe
...
@@ -34,12 +34,11 @@ func TestBuild_Prepare(t *testing.T) {
...
@@ -34,12 +34,11 @@ func TestBuild_Prepare(t *testing.T) {
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
build
:=
testBuild
()
build
:=
testBuild
()
ui
:=
testUi
()
coreB
:=
build
.
(
*
coreBuild
)
coreB
:=
build
.
(
*
coreBuild
)
builder
:=
coreB
.
builder
.
(
*
TestBuilder
)
builder
:=
coreB
.
builder
.
(
*
TestBuilder
)
build
.
Prepare
(
ui
)
build
.
Prepare
()
assert
.
True
(
builder
.
prepareCalled
,
"prepare should be called"
)
assert
.
True
(
builder
.
prepareCalled
,
"prepare should be called"
)
assert
.
Equal
(
builder
.
prepareConfig
,
42
,
"prepare config should be 42"
)
assert
.
Equal
(
builder
.
prepareConfig
,
42
,
"prepare config should be 42"
)
...
@@ -57,7 +56,7 @@ func TestBuild_Run(t *testing.T) {
...
@@ -57,7 +56,7 @@ func TestBuild_Run(t *testing.T) {
ui
:=
testUi
()
ui
:=
testUi
()
build
:=
testBuild
()
build
:=
testBuild
()
build
.
Prepare
(
ui
)
build
.
Prepare
()
build
.
Run
(
ui
,
cache
)
build
.
Run
(
ui
,
cache
)
coreB
:=
build
.
(
*
coreBuild
)
coreB
:=
build
.
(
*
coreBuild
)
...
...
packer/rpc/build.go
View file @
a35feebe
...
@@ -17,10 +17,6 @@ type BuildServer struct {
...
@@ -17,10 +17,6 @@ type BuildServer struct {
build
packer
.
Build
build
packer
.
Build
}
}
type
BuildPrepareArgs
struct
{
RPCAddress
string
}
type
BuildRunArgs
struct
{
type
BuildRunArgs
struct
{
UiRPCAddress
string
UiRPCAddress
string
}
}
...
@@ -34,14 +30,8 @@ func (b *build) Name() (result string) {
...
@@ -34,14 +30,8 @@ func (b *build) Name() (result string) {
return
return
}
}
func
(
b
*
build
)
Prepare
(
ui
packer
.
Ui
)
(
err
error
)
{
func
(
b
*
build
)
Prepare
()
(
err
error
)
{
// Create and start the server for the UI
if
cerr
:=
b
.
client
.
Call
(
"Build.Prepare"
,
new
(
interface
{}),
&
err
);
cerr
!=
nil
{
// TODO: Error handling
server
:=
rpc
.
NewServer
()
RegisterUi
(
server
,
ui
)
args
:=
&
BuildPrepareArgs
{
serveSingleConn
(
server
)}
if
cerr
:=
b
.
client
.
Call
(
"Build.Prepare"
,
args
,
&
err
);
cerr
!=
nil
{
return
cerr
return
cerr
}
}
...
@@ -79,13 +69,8 @@ func (b *BuildServer) Name(args *interface{}, reply *string) error {
...
@@ -79,13 +69,8 @@ func (b *BuildServer) Name(args *interface{}, reply *string) error {
return
nil
return
nil
}
}
func
(
b
*
BuildServer
)
Prepare
(
args
*
BuildPrepareArgs
,
reply
*
error
)
error
{
func
(
b
*
BuildServer
)
Prepare
(
args
interface
{},
reply
*
error
)
error
{
client
,
err
:=
rpc
.
Dial
(
"tcp"
,
args
.
RPCAddress
)
*
reply
=
b
.
build
.
Prepare
()
if
err
!=
nil
{
return
err
}
*
reply
=
b
.
build
.
Prepare
(
&
Ui
{
client
})
return
nil
return
nil
}
}
...
...
packer/rpc/build_test.go
View file @
a35feebe
...
@@ -13,7 +13,6 @@ var testBuildArtifact = &testArtifact{}
...
@@ -13,7 +13,6 @@ var testBuildArtifact = &testArtifact{}
type
testBuild
struct
{
type
testBuild
struct
{
nameCalled
bool
nameCalled
bool
prepareCalled
bool
prepareCalled
bool
prepareUi
packer
.
Ui
runCalled
bool
runCalled
bool
runCache
packer
.
Cache
runCache
packer
.
Cache
runUi
packer
.
Ui
runUi
packer
.
Ui
...
@@ -27,9 +26,8 @@ func (b *testBuild) Name() string {
...
@@ -27,9 +26,8 @@ func (b *testBuild) Name() string {
return
"name"
return
"name"
}
}
func
(
b
*
testBuild
)
Prepare
(
ui
packer
.
Ui
)
error
{
func
(
b
*
testBuild
)
Prepare
()
error
{
b
.
prepareCalled
=
true
b
.
prepareCalled
=
true
b
.
prepareUi
=
ui
return
nil
return
nil
}
}
...
@@ -70,13 +68,12 @@ func TestBuildRPC(t *testing.T) {
...
@@ -70,13 +68,12 @@ func TestBuildRPC(t *testing.T) {
assert
.
True
(
b
.
nameCalled
,
"name should be called"
)
assert
.
True
(
b
.
nameCalled
,
"name should be called"
)
// Test Prepare
// Test Prepare
ui
:=
new
(
testUi
)
bClient
.
Prepare
()
bClient
.
Prepare
(
ui
)
assert
.
True
(
b
.
prepareCalled
,
"prepare should be called"
)
assert
.
True
(
b
.
prepareCalled
,
"prepare should be called"
)
// Test Run
// Test Run
cache
:=
new
(
testCache
)
cache
:=
new
(
testCache
)
ui
=
new
(
testUi
)
ui
:
=
new
(
testUi
)
_
,
err
=
bClient
.
Run
(
ui
,
cache
)
_
,
err
=
bClient
.
Run
(
ui
,
cache
)
assert
.
True
(
b
.
runCalled
,
"run should be called"
)
assert
.
True
(
b
.
runCalled
,
"run should be called"
)
assert
.
Nil
(
err
,
"should not error"
)
assert
.
Nil
(
err
,
"should not error"
)
...
...
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