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
67993150
Commit
67993150
authored
Jun 18, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Improved logging around build runs
parent
b243eeda
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
packer/build.go
packer/build.go
+10
-2
packer/build_test.go
packer/build_test.go
+8
-8
packer/template.go
packer/template.go
+2
-0
No files found.
packer/build.go
View file @
67993150
...
...
@@ -48,6 +48,7 @@ type coreBuild struct {
name
string
builder
Builder
builderConfig
interface
{}
builderType
string
hooks
map
[
string
][]
Hook
postProcessors
[][]
coreBuildPostProcessor
provisioners
[]
coreBuildProvisioner
...
...
@@ -61,6 +62,7 @@ type coreBuild struct {
// post-processor used within a build.
type
coreBuildPostProcessor
struct
{
processor
PostProcessor
processorType
string
config
interface
{}
keepInputArtifact
bool
}
...
...
@@ -153,6 +155,7 @@ func (b *coreBuild) Run(ui Ui, cache Cache) ([]Artifact, error) {
hook
:=
&
DispatchHook
{
hooks
}
artifacts
:=
make
([]
Artifact
,
0
,
1
)
log
.
Printf
(
"Running builder: %s"
,
b
.
builderType
)
builderArtifact
,
err
:=
b
.
builder
.
Run
(
ui
,
hook
,
cache
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -166,6 +169,7 @@ 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
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"Post-processor failed: %s"
,
err
))
...
...
@@ -181,8 +185,11 @@ PostProcessorRunSeqLoop:
// This is the first post-processor. We handle deleting
// previous artifacts a bit different because multiple
// post-processors may be using the original and need it.
if
!
keepOriginalArtifact
{
keepOriginalArtifact
=
corePP
.
keepInputArtifact
if
!
keepOriginalArtifact
&&
corePP
.
keepInputArtifact
{
log
.
Printf
(
"Flagging to keep original artifact from post-processor '%s'"
,
corePP
.
processorType
)
keepOriginalArtifact
=
true
}
}
else
{
// We have a prior artifact. If we want to keep it, we append
...
...
@@ -190,6 +197,7 @@ PostProcessorRunSeqLoop:
if
corePP
.
keepInputArtifact
{
artifacts
=
append
(
artifacts
,
priorArtifact
)
}
else
{
log
.
Printf
(
"Deleting prior artifact from post-processor '%s'"
,
corePP
.
processorType
)
if
err
:=
priorArtifact
.
Destroy
();
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"Failed cleaning up prior artifact: %s"
,
err
))
}
...
...
packer/build_test.go
View file @
67993150
...
...
@@ -19,7 +19,7 @@ func testBuild() *coreBuild {
},
postProcessors
:
[][]
coreBuildPostProcessor
{
[]
coreBuildPostProcessor
{
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp"
},
42
,
true
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp"
},
"testPP"
,
42
,
true
},
},
},
}
...
...
@@ -163,7 +163,7 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build
=
testBuild
()
build
.
postProcessors
=
[][]
coreBuildPostProcessor
{
[]
coreBuildPostProcessor
{
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp"
},
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp"
},
"pp"
,
42
,
false
},
},
}
...
...
@@ -188,10 +188,10 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build
=
testBuild
()
build
.
postProcessors
=
[][]
coreBuildPostProcessor
{
[]
coreBuildPostProcessor
{
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp1"
},
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp1"
},
"pp"
,
42
,
false
},
},
[]
coreBuildPostProcessor
{
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp2"
},
42
,
true
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp2"
},
"pp"
,
42
,
true
},
},
}
...
...
@@ -216,12 +216,12 @@ func TestBuild_Run_Artifacts(t *testing.T) {
build
=
testBuild
()
build
.
postProcessors
=
[][]
coreBuildPostProcessor
{
[]
coreBuildPostProcessor
{
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp1a"
},
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp1b"
},
42
,
true
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp1a"
},
"pp"
,
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp1b"
},
"pp"
,
42
,
true
},
},
[]
coreBuildPostProcessor
{
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp2a"
},
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp2b"
},
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp2a"
},
"pp"
,
42
,
false
},
coreBuildPostProcessor
{
&
TestPostProcessor
{
artifactId
:
"pp2b"
},
"pp"
,
42
,
false
},
},
}
...
...
packer/template.go
View file @
67993150
...
...
@@ -302,6 +302,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
current
[
i
]
=
coreBuildPostProcessor
{
processor
:
pp
,
processorType
:
rawPP
.
Type
,
config
:
rawPP
.
rawConfig
,
keepInputArtifact
:
rawPP
.
KeepInputArtifact
,
}
...
...
@@ -341,6 +342,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
name
:
name
,
builder
:
builder
,
builderConfig
:
builderConfig
.
rawConfig
,
builderType
:
builderConfig
.
Type
,
hooks
:
hooks
,
postProcessors
:
postProcessors
,
provisioners
:
provisioners
,
...
...
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