fix tests
This commit is contained in:
parent
46f41d1f12
commit
3e3768ec3e
|
@ -194,20 +194,12 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) {
|
|||
|
||||
// Add a hook for the provisioners if we have provisioners
|
||||
if len(b.provisioners) > 0 {
|
||||
provisioners := make([]Provisioner, len(b.provisioners))
|
||||
provisionerTypes := make([]string, len(b.provisioners))
|
||||
for i, p := range b.provisioners {
|
||||
provisioners[i] = p.provisioner
|
||||
provisionerTypes[i] = p.pType
|
||||
}
|
||||
|
||||
if _, ok := hooks[HookProvision]; !ok {
|
||||
hooks[HookProvision] = make([]Hook, 0, 1)
|
||||
}
|
||||
|
||||
hooks[HookProvision] = append(hooks[HookProvision], &ProvisionHook{
|
||||
Provisioners: provisioners,
|
||||
ProvisionerTypes: provisionerTypes,
|
||||
Provisioners: b.provisioners,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ type Provisioner interface {
|
|||
type ProvisionHook struct {
|
||||
// The provisioners to run as part of the hook. These should already
|
||||
// be prepared (by calling Prepare) at some earlier stage.
|
||||
Provisioners []Provisioner
|
||||
ProvisionerTypes []string
|
||||
Provisioners []coreBuildProvisioner
|
||||
|
||||
lock sync.Mutex
|
||||
runningProvisioner Provisioner
|
||||
|
@ -58,13 +57,19 @@ func (h *ProvisionHook) Run(name string, ui Ui, comm Communicator, data interfac
|
|||
h.runningProvisioner = nil
|
||||
}()
|
||||
|
||||
for i, p := range h.Provisioners {
|
||||
for _, p := range h.Provisioners {
|
||||
h.lock.Lock()
|
||||
h.runningProvisioner = p
|
||||
h.runningProvisioner = p.provisioner
|
||||
h.lock.Unlock()
|
||||
|
||||
ts := CheckpointReporter.AddSpan(h.ProvisionerTypes[i], "provisioner", p)
|
||||
err := p.Provision(ui, comm)
|
||||
var pConfig interface{}
|
||||
if len(p.config) > 0 {
|
||||
pConfig = p.config[0]
|
||||
}
|
||||
ts := CheckpointReporter.AddSpan(p.pType, "provisioner", pConfig)
|
||||
|
||||
err := p.provisioner.Provision(ui, comm)
|
||||
|
||||
ts.End(err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -23,8 +23,10 @@ func TestProvisionHook(t *testing.T) {
|
|||
var data interface{} = nil
|
||||
|
||||
hook := &ProvisionHook{
|
||||
Provisioners: []Provisioner{pA, pB},
|
||||
ProvisionerTypes: []string{"", ""},
|
||||
Provisioners: []coreBuildProvisioner{
|
||||
{"", pA, nil},
|
||||
{"", pB, nil},
|
||||
},
|
||||
}
|
||||
|
||||
hook.Run("foo", ui, comm, data)
|
||||
|
@ -47,8 +49,10 @@ func TestProvisionHook_nilComm(t *testing.T) {
|
|||
var data interface{} = nil
|
||||
|
||||
hook := &ProvisionHook{
|
||||
Provisioners: []Provisioner{pA, pB},
|
||||
ProvisionerTypes: []string{"", ""},
|
||||
Provisioners: []coreBuildProvisioner{
|
||||
{"", pA, nil},
|
||||
{"", pB, nil},
|
||||
},
|
||||
}
|
||||
|
||||
err := hook.Run("foo", ui, comm, data)
|
||||
|
@ -74,8 +78,9 @@ func TestProvisionHook_cancel(t *testing.T) {
|
|||
}
|
||||
|
||||
hook := &ProvisionHook{
|
||||
Provisioners: []Provisioner{p},
|
||||
ProvisionerTypes: []string{""},
|
||||
Provisioners: []coreBuildProvisioner{
|
||||
{"", p, nil},
|
||||
},
|
||||
}
|
||||
|
||||
finished := make(chan struct{})
|
||||
|
|
Loading…
Reference in New Issue