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
e73c2247
Commit
e73c2247
authored
Jun 18, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Build runs the post-processors
parent
75fe58d5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
5 deletions
+57
-5
packer/artifact_test.go
packer/artifact_test.go
+19
-0
packer/build.go
packer/build.go
+30
-3
packer/build_test.go
packer/build_test.go
+7
-1
packer/builder_test.go
packer/builder_test.go
+1
-1
No files found.
packer/artifact_test.go
0 → 100644
View file @
e73c2247
package
packer
type
TestArtifact
struct
{}
func
(
*
TestArtifact
)
BuilderId
()
string
{
return
"bid"
}
func
(
*
TestArtifact
)
Files
()
[]
string
{
return
[]
string
{
"a"
,
"b"
}
}
func
(
*
TestArtifact
)
Id
()
string
{
return
"id"
}
func
(
*
TestArtifact
)
String
()
string
{
return
"string"
}
packer/build.go
View file @
e73c2247
package
packer
import
(
"fmt"
"log"
"sync"
)
...
...
@@ -151,10 +152,36 @@ func (b *coreBuild) Run(ui Ui, cache Cache) ([]Artifact, error) {
hook
:=
&
DispatchHook
{
hooks
}
artifacts
:=
make
([]
Artifact
,
0
,
1
)
artifact
,
err
:=
b
.
builder
.
Run
(
ui
,
hook
,
cache
)
if
artifact
!=
nil
{
builderArtifact
,
err
:=
b
.
builder
.
Run
(
ui
,
hook
,
cache
)
if
builderArtifact
!=
nil
{
artifacts
=
append
(
artifacts
,
builderArtifact
)
}
if
err
!=
nil
{
return
artifacts
,
err
}
errors
:=
make
([]
error
,
0
)
// Run the post-processors
PostProcessorRunSeqLoop
:
for
_
,
ppSeq
:=
range
b
.
postProcessors
{
artifact
:=
builderArtifact
for
_
,
corePP
:=
range
ppSeq
{
var
err
error
artifact
,
err
=
corePP
.
processor
.
PostProcess
(
artifact
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"Post-processor failed: %s"
,
err
))
continue
PostProcessorRunSeqLoop
}
artifacts
=
append
(
artifacts
,
artifact
)
}
}
if
len
(
errors
)
>
0
{
err
=
&
MultiError
{
errors
}
}
return
artifacts
,
err
}
...
...
packer/build_test.go
View file @
e73c2247
...
...
@@ -107,7 +107,9 @@ func TestBuild_Run(t *testing.T) {
build
:=
testBuild
()
build
.
Prepare
()
build
.
Run
(
ui
,
cache
)
artifacts
,
err
:=
build
.
Run
(
ui
,
cache
)
assert
.
Nil
(
err
,
"should not error"
)
assert
.
Equal
(
len
(
artifacts
),
2
,
"should have two artifacts"
)
coreB
:=
build
.
(
*
coreBuild
)
...
...
@@ -128,6 +130,10 @@ func TestBuild_Run(t *testing.T) {
dispatchHook
.
Run
(
HookProvision
,
nil
,
nil
,
42
)
prov
:=
coreB
.
provisioners
[
0
]
.
provisioner
.
(
*
TestProvisioner
)
assert
.
True
(
prov
.
provCalled
,
"provision should be called"
)
// Verify post-processor was run
pp
:=
coreB
.
postProcessors
[
0
][
0
]
.
processor
.
(
*
TestPostProcessor
)
assert
.
True
(
pp
.
ppCalled
,
"post processor should be called"
)
}
func
TestBuild_RunBeforePrepare
(
t
*
testing
.
T
)
{
...
...
packer/builder_test.go
View file @
e73c2247
...
...
@@ -21,7 +21,7 @@ func (tb *TestBuilder) Run(ui Ui, h Hook, c Cache) (Artifact, error) {
tb
.
runHook
=
h
tb
.
runUi
=
ui
tb
.
runCache
=
c
return
n
il
,
nil
return
n
ew
(
TestArtifact
)
,
nil
}
func
(
tb
*
TestBuilder
)
Cancel
()
{
...
...
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