core: contextComponentFactory doesn't need to enumerate components

In earlier Terraform versions we used the set of all available plugins of
each type to make graph-building decisions, but in modern Terraform we
make those decisions based entirely on the configuration.

Consequently, we no longer need the methods which can enumerate all of the
known plugin components of a given type. Instead, we just try to
instantiate each of the plugins that the configuration refers to and then
handle the error when that fails, which typically means that the user
needs to run "terraform init" to install some new plugins.
This commit is contained in:
Martin Atkins 2021-08-31 10:22:25 -07:00
parent d51921f085
commit dcfa077adf

View File

@ -15,12 +15,10 @@ import (
type contextComponentFactory interface {
// ResourceProvider creates a new ResourceProvider with the given type.
ResourceProvider(typ addrs.Provider) (providers.Interface, error)
ResourceProviders() []string
// ResourceProvisioner creates a new ResourceProvisioner with the given
// type.
ResourceProvisioner(typ string) (provisioners.Interface, error)
ResourceProvisioners() []string
}
// basicComponentFactory just calls a factory from a map directly.
@ -29,23 +27,6 @@ type basicComponentFactory struct {
provisioners map[string]provisioners.Factory
}
func (c *basicComponentFactory) ResourceProviders() []string {
var result []string
for k := range c.providers {
result = append(result, k.String())
}
return result
}
func (c *basicComponentFactory) ResourceProvisioners() []string {
var result []string
for k := range c.provisioners {
result = append(result, k)
}
return result
}
func (c *basicComponentFactory) ResourceProvider(typ addrs.Provider) (providers.Interface, error) {
f, ok := c.providers[typ]
if !ok {