packer: coreBuild runs provisioners as part of Run
This commit is contained in:
parent
83eab87c26
commit
1b78fc88a9
|
@ -70,6 +70,20 @@ func (b *coreBuild) Run(ui Ui) Artifact {
|
||||||
copy(hooks[hookName], hookList)
|
copy(hooks[hookName], hookList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a hook for the provisioners if we have provisioners
|
||||||
|
if len(b.provisioners) > 0 {
|
||||||
|
provisioners := make([]Provisioner, len(b.provisioners))
|
||||||
|
for i, p := range b.provisioners {
|
||||||
|
provisioners[i] = p.provisioner
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := hooks[HookProvision]; !ok {
|
||||||
|
hooks[HookProvision] = make([]Hook, 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
hooks[HookProvision] = append(hooks[HookProvision], &ProvisionHook{provisioners})
|
||||||
|
}
|
||||||
|
|
||||||
hook := &DispatchHook{hooks}
|
hook := &DispatchHook{hooks}
|
||||||
return b.builder.Run(ui, hook)
|
return b.builder.Run(ui, hook)
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,11 @@ func TestBuild_Run(t *testing.T) {
|
||||||
hook := coreB.hooks["foo"][0].(*TestHook)
|
hook := coreB.hooks["foo"][0].(*TestHook)
|
||||||
assert.True(hook.runCalled, "run should be called")
|
assert.True(hook.runCalled, "run should be called")
|
||||||
assert.Equal(hook.runData, 42, "should have correct data")
|
assert.Equal(hook.runData, 42, "should have correct data")
|
||||||
|
|
||||||
|
// Verify provisioners run
|
||||||
|
dispatchHook.Run(HookProvision, nil, nil, 42)
|
||||||
|
prov := coreB.provisioners[0].provisioner.(*TestProvisioner)
|
||||||
|
assert.True(prov.provCalled, "provision should be called")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuild_RunBeforePrepare(t *testing.T) {
|
func TestBuild_RunBeforePrepare(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue