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
bd6f176b
Commit
bd6f176b
authored
Jun 27, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Builds use their own UI [GH-21]
parent
a7a51f1d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
53 deletions
+57
-53
command/build/command.go
command/build/command.go
+1
-9
packer/build.go
packer/build.go
+56
-43
packer/build_test.go
packer/build_test.go
+0
-1
No files found.
command/build/command.go
View file @
bd6f176b
...
...
@@ -128,19 +128,11 @@ func (c Command) Run(env packer.Environment, args []string) int {
buildUis
:=
make
(
map
[
string
]
packer
.
Ui
)
for
i
,
b
:=
range
builds
{
var
ui
packer
.
Ui
ui
=
&
packer
.
ColoredUi
{
ui
:=
&
packer
.
ColoredUi
{
Color
:
colors
[
i
%
len
(
colors
)],
Ui
:
env
.
Ui
(),
}
ui
=
&
packer
.
PrefixedUi
{
fmt
.
Sprintf
(
"==> %s"
,
b
.
Name
()),
fmt
.
Sprintf
(
" %s"
,
b
.
Name
()),
ui
,
}
buildUis
[
b
.
Name
()]
=
ui
ui
.
Say
(
fmt
.
Sprintf
(
"%s output will be in this color."
,
b
.
Name
()))
}
...
...
packer/build.go
View file @
bd6f176b
...
...
@@ -126,7 +126,7 @@ func (b *coreBuild) Prepare() (err error) {
}
// Runs the actual build. Prepare must be called prior to running this.
func
(
b
*
coreBuild
)
Run
(
u
i
Ui
,
cache
Cache
)
([]
Artifact
,
error
)
{
func
(
b
*
coreBuild
)
Run
(
originalU
i
Ui
,
cache
Cache
)
([]
Artifact
,
error
)
{
if
!
b
.
prepareCalled
{
panic
(
"Prepare must be called first"
)
}
...
...
@@ -155,8 +155,15 @@ func (b *coreBuild) Run(ui Ui, cache Cache) ([]Artifact, error) {
hook
:=
&
DispatchHook
{
hooks
}
artifacts
:=
make
([]
Artifact
,
0
,
1
)
// The builder just has a normal Ui, but prefixed
builderUi
:=
&
PrefixedUi
{
fmt
.
Sprintf
(
"==> %s"
,
b
.
Name
()),
fmt
.
Sprintf
(
" %s"
,
b
.
Name
()),
originalUi
,
}
log
.
Printf
(
"Running builder: %s"
,
b
.
builderType
)
builderArtifact
,
err
:=
b
.
builder
.
Run
(
u
i
,
hook
,
cache
)
builderArtifact
,
err
:=
b
.
builder
.
Run
(
builderU
i
,
hook
,
cache
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -171,12 +178,18 @@ func (b *coreBuild) Run(ui Ui, cache Cache) ([]Artifact, error) {
keepOriginalArtifact
:=
len
(
b
.
postProcessors
)
==
0
// Run the post-processors
PostProcessorRunSeqLoop
:
PostProcessorRunSeqLoop
:
for
_
,
ppSeq
:=
range
b
.
postProcessors
{
priorArtifact
:=
builderArtifact
for
i
,
corePP
:=
range
ppSeq
{
ui
.
Say
(
fmt
.
Sprintf
(
"Running post-processor: %s"
,
corePP
.
processorType
))
artifact
,
err
:=
corePP
.
processor
.
PostProcess
(
ui
,
priorArtifact
)
ppUi
:=
&
PrefixedUi
{
fmt
.
Sprintf
(
"==> %s (%s)"
,
b
.
Name
(),
corePP
.
processorType
),
fmt
.
Sprintf
(
" %s (%s)"
,
b
.
Name
(),
corePP
.
processorType
),
originalUi
,
}
builderUi
.
Say
(
fmt
.
Sprintf
(
"Running post-processor: %s"
,
corePP
.
processorType
))
artifact
,
err
:=
corePP
.
processor
.
PostProcess
(
ppUi
,
priorArtifact
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"Post-processor failed: %s"
,
err
))
continue
PostProcessorRunSeqLoop
...
...
@@ -235,17 +248,17 @@ PostProcessorRunSeqLoop:
}
return
artifacts
,
err
}
}
func
(
b
*
coreBuild
)
SetDebug
(
val
bool
)
{
func
(
b
*
coreBuild
)
SetDebug
(
val
bool
)
{
if
b
.
prepareCalled
{
panic
(
"prepare has already been called"
)
}
b
.
debug
=
val
}
}
// Cancels the build if it is running.
func
(
b
*
coreBuild
)
Cancel
()
{
// Cancels the build if it is running.
func
(
b
*
coreBuild
)
Cancel
()
{
b
.
builder
.
Cancel
()
}
}
packer/build_test.go
View file @
bd6f176b
...
...
@@ -113,7 +113,6 @@ func TestBuild_Run(t *testing.T) {
// Verify builder was run
builder
:=
build
.
builder
.
(
*
TestBuilder
)
assert
.
True
(
builder
.
runCalled
,
"run should be called"
)
assert
.
Equal
(
builder
.
runUi
,
ui
,
"run should be called with ui"
)
// Verify hooks are disapatchable
dispatchHook
:=
builder
.
runHook
...
...
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