Documentation
¶
Index ¶
- Constants
- type Library
- type ProviderFactories
- type ProviderLaunchers
- type ProviderManager
- type ProvisionerFactories
- type ProvisionerManager
- type Schemas
- func (ss *Schemas) ProviderConfig(provider addrs.Provider) *configschema.Block
- func (ss *Schemas) ProviderSchema(provider addrs.Provider) providers.ProviderSchema
- func (ss *Schemas) ProvisionerConfig(name string) *configschema.Block
- func (ss *Schemas) ResourceTypeConfig(provider addrs.Provider, resourceMode addrs.ResourceMode, resourceType string) (block *providers.Schema, schemaVersion uint64)
Constants ¶
const TraceNameStartProvider = "Start provider"
TraceNameStartProvider is the span name for starting a provider plugin (GitHub issue #1898): launching its process, the go-plugin handshake and dispensing the client.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Library ¶
type Library interface {
NewProviderManager() ProviderManager
NewProvisionerManager() ProvisionerManager
HasProvider(addr addrs.Provider) bool
HasProvisioner(typ string) bool
}
Library represents a suite of provider and provisioner plugins. It does not expose much functionality itself, instead serving as a starting point for the more complex managers.
func NewLibrary ¶
func NewLibrary(providerFactories ProviderFactories, provisionerFactories ProvisionerFactories) Library
func NewLibraryWithLaunchers ¶ added in v0.22.0
func NewLibraryWithLaunchers(providerFactories ProviderFactories, providerLaunchers ProviderLaunchers, provisionerFactories ProvisionerFactories) Library
NewLibraryWithLaunchers is NewLibrary with launchers for the providers that have one. A provider started through a launcher gets the "Start provider" span as its trace parent (GitHub issue #1898); a provider with only a factory still gets the span, but its process is not handed it.
type ProviderFactories ¶
func (ProviderFactories) HasProvider ¶
func (p ProviderFactories) HasProvider(addr addrs.Provider) bool
func (ProviderFactories) NewInstance ¶
type ProviderLaunchers ¶ added in v0.22.0
ProviderLaunchers are the context-taking forms of some of a library's provider factories. See providers.Launcher.
type ProviderManager ¶
type ProviderManager interface {
// HasProvider checks to see if the underlying library contains a given provider.
HasProvider(addr addrs.Provider) bool
// GetProviderSchema returns a fully validated and cached provider schema. This should
// always be preferred to accessing the schema directly from a provider.
GetProviderSchema(ctx context.Context, addr addrs.Provider) (providers.ProviderSchema, tfdiags.Diagnostics)
// NewProvider starts and tracks a new provider instance of the given type.
NewProvider(ctx context.Context, addr addrs.Provider) (providers.Interface, tfdiags.Diagnostics)
// NewConfiguredProvider starts, configures, and tracks a new provider instance of the give type.
NewConfiguredProvider(ctx context.Context, addr addrs.Provider, cfgVal cty.Value) (providers.Configured, tfdiags.Diagnostics)
// StopAll gracefully requests all tracked providers to stop.
// See [providers.Unconfigured.Stop] for more information.
StopAll(context.Context) error
// CloseAll forcefully closes all tracked providers.
// See [providers.Unconfigured.Close] for more information.
// Every tofu.Context owns one manager of each kind and its owner calls
// (*tofu.Context).Close, which calls Shutdown. plugin.CleanupClients in
// cmd/choudoufu/main.go remains only as a backstop for a process that
// exits without reaching that Close (a forced interrupt, a panic).
CloseAll(context.Context) error
// Shutdown locks the provider manager in a Shutdown state and calls CloseAll,
// preventing any further usage of this object.
Shutdown(context.Context) error
}
ProviderManager allows for spawning, tracking and management of provider instances.
type ProvisionerFactories ¶
type ProvisionerFactories map[string]provisioners.Factory
func (ProvisionerFactories) HasProvisioner ¶
func (p ProvisionerFactories) HasProvisioner(typ string) bool
func (ProvisionerFactories) NewInstance ¶
func (p ProvisionerFactories) NewInstance(typ string) (provisioners.Interface, error)
type ProvisionerManager ¶
type ProvisionerManager interface {
// HasProvisioner checks to see if the underlying library contains a given provisioner.
HasProvisioner(typ string) bool
// ProvisionerSchema is a caching wrapper for [provisioners.Interface.GetSchema]
ProvisionerSchema(typ string) (*configschema.Block, error)
// [provisioners.Interface.ValidateProvisionerConfig]
ValidateProvisionerConfig(ctx context.Context, typ string, config cty.Value) tfdiags.Diagnostics
// [provisioners.Interface.ProvisionResource]
ProvisionResource(ctx context.Context, typ string, config cty.Value, connection cty.Value, output provisioners.UIOutput) tfdiags.Diagnostics
// StopAll gracefully requests all tracked provisioners to stop.
// See [provisioners.Interface.Stop] for more information.
StopAll() error
// CloseAll forcefully closes all tracked provisioners.
// See [provisioners.Interface.Close] for more information.
// Every tofu.Context owns one manager of each kind and its owner calls
// (*tofu.Context).Close, which calls Shutdown. plugin.CleanupClients in
// cmd/choudoufu/main.go remains only as a backstop for a process that
// exits without reaching that Close (a forced interrupt, a panic).
CloseAll() error
// Shutdown locks the provisioner manager in a Shutdown state and calls CloseAll,
// preventing any further usage of this object.
Shutdown() error
}
ProvisionerManager exposes provisioner functionality through functions, instead of providing access to the provisioner instances themselves.
type Schemas ¶ added in v0.34.0
type Schemas struct {
Providers map[addrs.Provider]providers.ProviderSchema
Provisioners map[string]*configschema.Block
}
Schemas is a container for various kinds of schema that OpenTofu needs during processing.
Although not all schemas necessarily come from plugins, this type lives here out of pragmatism because plugins are the most common place that schemas come from.
func (*Schemas) ProviderConfig ¶ added in v0.34.0
func (ss *Schemas) ProviderConfig(provider addrs.Provider) *configschema.Block
ProviderConfig returns the schema for the provider configuration of the given provider type, or nil if no such schema is available.
func (*Schemas) ProviderSchema ¶ added in v0.34.0
func (ss *Schemas) ProviderSchema(provider addrs.Provider) providers.ProviderSchema
ProviderSchema returns the entire ProviderSchema object that was produced by the plugin for the given provider, or nil if no such schema is available.
It's usually better to go use the more precise methods offered by type Schemas to handle this detail automatically.
func (*Schemas) ProvisionerConfig ¶ added in v0.34.0
func (ss *Schemas) ProvisionerConfig(name string) *configschema.Block
ProvisionerConfig returns the schema for the configuration of a given provisioner, or nil of no such schema is available.
func (*Schemas) ResourceTypeConfig ¶ added in v0.34.0
func (ss *Schemas) ResourceTypeConfig(provider addrs.Provider, resourceMode addrs.ResourceMode, resourceType string) (block *providers.Schema, schemaVersion uint64)
ResourceTypeConfig returns the schema for the configuration of a given resource type belonging to a given provider type, or nil of no such schema is available.
In many cases the provider type is inferable from the resource type name, but this is not always true because users can override the provider for a resource using the "provider" meta-argument. Therefore, it's important to always pass the correct provider name, even though it many cases it feels redundant.