packer: Post-processors are configured
This commit is contained in:
parent
218692950b
commit
75fe58d5f7
|
@ -109,6 +109,15 @@ func (b *coreBuild) Prepare() (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Prepare the post-processors
|
||||
for _, ppSeq := range b.postProcessors {
|
||||
for _, corePP := range ppSeq {
|
||||
if err = corePP.processor.Configure(corePP.config); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,11 @@ func testBuild() Build {
|
|||
provisioners: []coreBuildProvisioner{
|
||||
coreBuildProvisioner{&TestProvisioner{}, []interface{}{42}},
|
||||
},
|
||||
postProcessors: [][]coreBuildPostProcessor{
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&TestPostProcessor{}, 42},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +52,11 @@ func TestBuild_Prepare(t *testing.T) {
|
|||
prov := coreProv.provisioner.(*TestProvisioner)
|
||||
assert.True(prov.prepCalled, "prepare should be called")
|
||||
assert.Equal(prov.prepConfigs, []interface{}{42, debugFalseConfig}, "prepare should be called with proper config")
|
||||
|
||||
corePP := coreB.postProcessors[0][0]
|
||||
pp := corePP.processor.(*TestPostProcessor)
|
||||
assert.True(pp.configCalled, "config should be called")
|
||||
assert.Equal(pp.configVal, 42, "config should have right value")
|
||||
}
|
||||
|
||||
func TestBuild_Prepare_Twice(t *testing.T) {
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
package packer
|
||||
|
||||
type TestPostProcessor struct{}
|
||||
type TestPostProcessor struct {
|
||||
configCalled bool
|
||||
configVal interface{}
|
||||
ppCalled bool
|
||||
ppArtifact Artifact
|
||||
}
|
||||
|
||||
func (*TestPostProcessor) Configure(interface{}) error {
|
||||
func (pp *TestPostProcessor) Configure(v interface{}) error {
|
||||
pp.configCalled = true
|
||||
pp.configVal = v
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*TestPostProcessor) PostProcess(Artifact) (Artifact, error) {
|
||||
func (pp *TestPostProcessor) PostProcess(a Artifact) (Artifact, error) {
|
||||
pp.ppCalled = true
|
||||
pp.ppArtifact = a
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue