From dcfa077adf68efdcf0083280dff554720f7ba468 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 31 Aug 2021 10:22:25 -0700 Subject: [PATCH] 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. --- internal/terraform/context_components.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/internal/terraform/context_components.go b/internal/terraform/context_components.go index 8532cfd4a..66f5dc664 100644 --- a/internal/terraform/context_components.go +++ b/internal/terraform/context_components.go @@ -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 {