mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Remove Stop() from plugins.ProviderManager interface
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
@@ -146,7 +146,7 @@ func (b *Local) opPlanWithExperimentalRuntime(stopCtx context.Context, cancelCtx
|
|||||||
prevRoundState = states.NewState() // this is the first round, starting with an empty state
|
prevRoundState = states.NewState() // this is the first round, starting with an empty state
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins := plugins.NewRuntimePlugins(b.ContextOpts.Plugins.Manager(ctx))
|
plugins := plugins.NewRuntimePlugins(b.ContextOpts.Plugins.Manager(stopCtx))
|
||||||
evalCtx := &eval.EvalContext{
|
evalCtx := &eval.EvalContext{
|
||||||
RootModuleDir: op.ConfigDir,
|
RootModuleDir: op.ConfigDir,
|
||||||
OriginalWorkingDir: b.ContextOpts.Meta.OriginalWorkingDir,
|
OriginalWorkingDir: b.ContextOpts.Meta.OriginalWorkingDir,
|
||||||
@@ -156,16 +156,6 @@ func (b *Local) opPlanWithExperimentalRuntime(stopCtx context.Context, cancelCtx
|
|||||||
Providers: plugins,
|
Providers: plugins,
|
||||||
Provisioners: plugins,
|
Provisioners: plugins,
|
||||||
}
|
}
|
||||||
defer func() {
|
|
||||||
// We'll call close with a cancel-free context because we do still
|
|
||||||
// want to shut the providers down even if we're dealing with
|
|
||||||
// graceful shutdown after cancellation.
|
|
||||||
err := plugins.Close(context.WithoutCancel(ctx))
|
|
||||||
// If a provider fails to close there isn't really much we can do
|
|
||||||
// about that... this shouldn't really be possible unless the
|
|
||||||
// plugin process already exited for some other reason anyway.
|
|
||||||
log.Printf("[ERROR] plugin shutdown failed: %s", err)
|
|
||||||
}()
|
|
||||||
|
|
||||||
// The new config-loading system wants to work in terms of module source
|
// The new config-loading system wants to work in terms of module source
|
||||||
// addresses rather than raw local filenames, so we'll ask the
|
// addresses rather than raw local filenames, so we'll ask the
|
||||||
|
|||||||
@@ -91,34 +91,34 @@ func NewRuntimePlugins(manager plugins.PluginManager) Plugins {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfiguredProvider implements evalglue.Providers.
|
// NewConfiguredProvider implements Providers.
|
||||||
func (n *newRuntimePlugins) NewConfiguredProvider(ctx context.Context, provider addrs.AbsProviderInstanceCorrect, configVal cty.Value) (providers.Configured, tfdiags.Diagnostics) {
|
func (n *newRuntimePlugins) NewConfiguredProvider(ctx context.Context, provider addrs.AbsProviderInstanceCorrect, configVal cty.Value) (providers.Configured, tfdiags.Diagnostics) {
|
||||||
diags := n.providers.ConfigureProvider(ctx, provider, configVal)
|
diags := n.providers.ConfigureProvider(ctx, provider, configVal)
|
||||||
configured := n.providers.ConfiguredProvider(provider)
|
configured := n.providers.ConfiguredProvider(provider)
|
||||||
return configured, diags
|
return configured, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProviderConfigSchema implements evalglue.Providers.
|
// ProviderConfigSchema implements Providers.
|
||||||
func (n *newRuntimePlugins) ProviderConfigSchema(ctx context.Context, provider addrs.Provider) (*providers.Schema, tfdiags.Diagnostics) {
|
func (n *newRuntimePlugins) ProviderConfigSchema(ctx context.Context, provider addrs.Provider) (*providers.Schema, tfdiags.Diagnostics) {
|
||||||
return n.providers.ProviderConfigSchema(ctx, provider)
|
return n.providers.ProviderConfigSchema(ctx, provider)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResourceTypeSchema implements evalglue.Providers.
|
// ResourceTypeSchema implements Providers.
|
||||||
func (n *newRuntimePlugins) ResourceTypeSchema(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string) (*providers.Schema, tfdiags.Diagnostics) {
|
func (n *newRuntimePlugins) ResourceTypeSchema(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string) (*providers.Schema, tfdiags.Diagnostics) {
|
||||||
return n.providers.ResourceTypeSchema(ctx, provider, mode, typeName)
|
return n.providers.ResourceTypeSchema(ctx, provider, mode, typeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateProviderConfig implements evalglue.Providers.
|
// ValidateProviderConfig implements Providers.
|
||||||
func (n *newRuntimePlugins) ValidateProviderConfig(ctx context.Context, provider addrs.Provider, configVal cty.Value) tfdiags.Diagnostics {
|
func (n *newRuntimePlugins) ValidateProviderConfig(ctx context.Context, provider addrs.Provider, configVal cty.Value) tfdiags.Diagnostics {
|
||||||
return n.providers.ValidateProviderConfig(ctx, provider, configVal)
|
return n.providers.ValidateProviderConfig(ctx, provider, configVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateResourceConfig implements evalglue.Providers.
|
// ValidateResourceConfig implements Providers.
|
||||||
func (n *newRuntimePlugins) ValidateResourceConfig(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string, configVal cty.Value) tfdiags.Diagnostics {
|
func (n *newRuntimePlugins) ValidateResourceConfig(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string, configVal cty.Value) tfdiags.Diagnostics {
|
||||||
return n.providers.ValidateResourceConfig(ctx, provider, mode, typeName, configVal)
|
return n.providers.ValidateResourceConfig(ctx, provider, mode, typeName, configVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProvisionerConfigSchema implements evalglue.Provisioners.
|
// ProvisionerConfigSchema implements Provisioners.
|
||||||
func (n *newRuntimePlugins) ProvisionerConfigSchema(ctx context.Context, typeName string) (*configschema.Block, tfdiags.Diagnostics) {
|
func (n *newRuntimePlugins) ProvisionerConfigSchema(ctx context.Context, typeName string) (*configschema.Block, tfdiags.Diagnostics) {
|
||||||
schema, err := n.provisioners.ProvisionerSchema(typeName)
|
schema, err := n.provisioners.ProvisionerSchema(typeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -126,10 +126,3 @@ func (n *newRuntimePlugins) ProvisionerConfigSchema(ctx context.Context, typeNam
|
|||||||
}
|
}
|
||||||
return schema, nil
|
return schema, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close terminates any plugins that are managed by this object and are still
|
|
||||||
// running.
|
|
||||||
func (n *newRuntimePlugins) Close(ctx context.Context) error {
|
|
||||||
// TODO use proper close?
|
|
||||||
return n.providers.Stop(ctx)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -79,6 +79,4 @@ type ProviderManager interface {
|
|||||||
CallFunction(ctx context.Context, addr addrs.AbsProviderInstanceCorrect, name string, arguments []cty.Value) (cty.Value, error)
|
CallFunction(ctx context.Context, addr addrs.AbsProviderInstanceCorrect, name string, arguments []cty.Value) (cty.Value, error)
|
||||||
|
|
||||||
CloseProvider(ctx context.Context, addr addrs.AbsProviderInstanceCorrect) error
|
CloseProvider(ctx context.Context, addr addrs.AbsProviderInstanceCorrect) error
|
||||||
|
|
||||||
Stop(ctx context.Context) error
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ func NewProviderManager(ctx context.Context, factories map[addrs.Provider]provid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := manager.Stop(ctx)
|
err := manager.stop(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Unable to stop provider manager: %s", err.Error())
|
log.Printf("[ERROR] Unable to stop provider manager: %s", err.Error())
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ func (p *providerManager) CloseProvider(ctx context.Context, addr addrs.AbsProvi
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *providerManager) Stop(ctx context.Context) error {
|
func (p *providerManager) stop(ctx context.Context) error {
|
||||||
|
|
||||||
p.configuredLock.Lock()
|
p.configuredLock.Lock()
|
||||||
defer p.configuredLock.Unlock()
|
defer p.configuredLock.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user