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:
parent
d51921f085
commit
dcfa077adf
|
@ -15,12 +15,10 @@ import (
|
||||||
type contextComponentFactory interface {
|
type contextComponentFactory interface {
|
||||||
// ResourceProvider creates a new ResourceProvider with the given type.
|
// ResourceProvider creates a new ResourceProvider with the given type.
|
||||||
ResourceProvider(typ addrs.Provider) (providers.Interface, error)
|
ResourceProvider(typ addrs.Provider) (providers.Interface, error)
|
||||||
ResourceProviders() []string
|
|
||||||
|
|
||||||
// ResourceProvisioner creates a new ResourceProvisioner with the given
|
// ResourceProvisioner creates a new ResourceProvisioner with the given
|
||||||
// type.
|
// type.
|
||||||
ResourceProvisioner(typ string) (provisioners.Interface, error)
|
ResourceProvisioner(typ string) (provisioners.Interface, error)
|
||||||
ResourceProvisioners() []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// basicComponentFactory just calls a factory from a map directly.
|
// basicComponentFactory just calls a factory from a map directly.
|
||||||
|
@ -29,23 +27,6 @@ type basicComponentFactory struct {
|
||||||
provisioners map[string]provisioners.Factory
|
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) {
|
func (c *basicComponentFactory) ResourceProvider(typ addrs.Provider) (providers.Interface, error) {
|
||||||
f, ok := c.providers[typ]
|
f, ok := c.providers[typ]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in New Issue