update provisioners for multiple processes

The "internal" provisioners are still run in a separate process, and
need to be updated to restart on each walk.
This commit is contained in:
James Bardin 2018-10-08 12:25:16 -04:00 committed by Martin Atkins
parent a14fe7ae0c
commit 52c0032aed
3 changed files with 8 additions and 7 deletions

View File

@ -326,12 +326,7 @@ func (m *Meta) provisionerFactories() map[string]terraform.ProvisionerFactory {
// Wire up the internal provisioners first. These might be overridden
// by discovered provisioners below.
for name := range InternalProvisioners {
client, err := internalPluginClient("provisioner", name)
if err != nil {
log.Printf("[WARN] failed to build command line for internal plugin %q: %s", name, err)
continue
}
factories[name] = internalProvisionerFactory(client)
factories[name] = internalProvisionerFactory(discovery.PluginMeta{Name: name})
}
byName := plugins.ByName()
@ -397,8 +392,12 @@ func provisionerFactory(meta discovery.PluginMeta) terraform.ProvisionerFactory
}
}
func internalProvisionerFactory(client *plugin.Client) terraform.ProvisionerFactory {
func internalProvisionerFactory(meta discovery.PluginMeta) terraform.ProvisionerFactory {
return func() (provisioners.Interface, error) {
client, err := internalPluginClient("provisioner", meta.Name)
if err != nil {
return nil, fmt.Errorf("[WARN] failed to build command line for internal plugin %q: %s", meta.Name, err)
}
return newProvisionerClient(client)
}
}

View File

@ -124,6 +124,7 @@ func (s *GRPCProvisionerServer) ProvisionResource(req *proto.ProvisionResource_R
Ephemeral: terraform.EphemeralState{
ConnInfo: conn,
},
Meta: make(map[string]interface{}),
}
err = s.provisioner.Apply(uiOutput{srv}, instanceState, resourceConfig)

View File

@ -64,6 +64,7 @@ func (p *GRPCProvisioner) GetSchema() (resp provisioners.GetSchemaResponse) {
resp.Diagnostics = resp.Diagnostics.Append(err)
return resp
}
resp.Diagnostics = resp.Diagnostics.Append(convert.ProtoToDiagnostics(protoResp.Diagnostics))
if protoResp.Provisioner == nil {
resp.Diagnostics = resp.Diagnostics.Append(errors.New("missing provisioner schema"))