diff --git a/terraform/context_components.go b/terraform/context_components.go index 78ce9c2d3..f99c36695 100644 --- a/terraform/context_components.go +++ b/terraform/context_components.go @@ -14,7 +14,7 @@ import ( // a Context. This information is used for debugging. type contextComponentFactory interface { // ResourceProvider creates a new ResourceProvider with the given type. - ResourceProvider(typ string) (providers.Interface, error) + ResourceProvider(typ addrs.Provider) (providers.Interface, error) ResourceProviders() []string // ResourceProvisioner creates a new ResourceProvisioner with the given @@ -46,10 +46,10 @@ func (c *basicComponentFactory) ResourceProvisioners() []string { return result } -func (c *basicComponentFactory) ResourceProvider(typ string) (providers.Interface, error) { - f, ok := c.providers[addrs.NewLegacyProvider(typ)] +func (c *basicComponentFactory) ResourceProvider(typ addrs.Provider) (providers.Interface, error) { + f, ok := c.providers[typ] if !ok { - return nil, fmt.Errorf("unknown provider %q", typ) + return nil, fmt.Errorf("unknown provider %q", typ.LegacyString()) } return f() diff --git a/terraform/eval_context.go b/terraform/eval_context.go index d8dd55b4c..a682b3d6c 100644 --- a/terraform/eval_context.go +++ b/terraform/eval_context.go @@ -30,13 +30,13 @@ type EvalContext interface { // Input is the UIInput object for interacting with the UI. Input() UIInput - // InitProvider initializes the provider with the given type and address, and - // returns the implementation of the resource provider or an error. + // InitProvider initializes the provider with the given address, and returns + // the implementation of the resource provider or an error. // // It is an error to initialize the same provider more than once. This // method will panic if the module instance address of the given provider // configuration does not match the Path() of the EvalContext. - InitProvider(typ string, addr addrs.AbsProviderConfig) (providers.Interface, error) + InitProvider(addr addrs.AbsProviderConfig) (providers.Interface, error) // Provider gets the provider instance with the given address (already // initialized) or returns nil if the provider isn't initialized. diff --git a/terraform/eval_context_builtin.go b/terraform/eval_context_builtin.go index 308512ec6..70583b2f6 100644 --- a/terraform/eval_context_builtin.go +++ b/terraform/eval_context_builtin.go @@ -105,7 +105,7 @@ func (ctx *BuiltinEvalContext) Input() UIInput { return ctx.InputValue } -func (ctx *BuiltinEvalContext) InitProvider(typeName string, addr addrs.AbsProviderConfig) (providers.Interface, error) { +func (ctx *BuiltinEvalContext) InitProvider(addr addrs.AbsProviderConfig) (providers.Interface, error) { ctx.once.Do(ctx.init) absAddr := addr if !absAddr.Module.Equal(ctx.Path()) { @@ -126,12 +126,12 @@ func (ctx *BuiltinEvalContext) InitProvider(typeName string, addr addrs.AbsProvi key := absAddr.String() - p, err := ctx.Components.ResourceProvider(typeName) + p, err := ctx.Components.ResourceProvider(addr.Provider) if err != nil { return nil, err } - log.Printf("[TRACE] BuiltinEvalContext: Initialized %q provider for %s", typeName, absAddr) + log.Printf("[TRACE] BuiltinEvalContext: Initialized %q provider for %s", addr.LegacyString(), absAddr) ctx.ProviderCache[key] = p return p, nil diff --git a/terraform/eval_context_builtin_test.go b/terraform/eval_context_builtin_test.go index f9596678d..d1be2ba7f 100644 --- a/terraform/eval_context_builtin_test.go +++ b/terraform/eval_context_builtin_test.go @@ -78,11 +78,11 @@ func TestBuildingEvalContextInitProvider(t *testing.T) { Alias: "foo", } - _, err := ctx.InitProvider("test", providerAddrDefault) + _, err := ctx.InitProvider(providerAddrDefault) if err != nil { t.Fatalf("error initializing provider test: %s", err) } - _, err = ctx.InitProvider("test", providerAddrAlias) + _, err = ctx.InitProvider(providerAddrAlias) if err != nil { t.Fatalf("error initializing provider test.foo: %s", err) } diff --git a/terraform/eval_context_mock.go b/terraform/eval_context_mock.go index 228bbc4ee..210a40d80 100644 --- a/terraform/eval_context_mock.go +++ b/terraform/eval_context_mock.go @@ -154,9 +154,9 @@ func (c *MockEvalContext) Input() UIInput { return c.InputInput } -func (c *MockEvalContext) InitProvider(t string, addr addrs.AbsProviderConfig) (providers.Interface, error) { +func (c *MockEvalContext) InitProvider(addr addrs.AbsProviderConfig) (providers.Interface, error) { c.InitProviderCalled = true - c.InitProviderType = t + c.InitProviderType = addr.LegacyString() c.InitProviderAddr = addr return c.InitProviderProvider, c.InitProviderError } diff --git a/terraform/eval_provider.go b/terraform/eval_provider.go index 03e340937..3b802d4ed 100644 --- a/terraform/eval_provider.go +++ b/terraform/eval_provider.go @@ -88,12 +88,11 @@ func (n *EvalConfigProvider) Eval(ctx EvalContext) (interface{}, error) { // and returns nothing. The provider can be retrieved again with the // EvalGetProvider node. type EvalInitProvider struct { - TypeName string - Addr addrs.AbsProviderConfig + Addr addrs.AbsProviderConfig } func (n *EvalInitProvider) Eval(ctx EvalContext) (interface{}, error) { - return ctx.InitProvider(n.TypeName, n.Addr) + return ctx.InitProvider(n.Addr) } // EvalCloseProvider is an EvalNode implementation that closes provider diff --git a/terraform/evaltree_provider.go b/terraform/evaltree_provider.go index 3474c4321..d4aa94d3d 100644 --- a/terraform/evaltree_provider.go +++ b/terraform/evaltree_provider.go @@ -15,10 +15,7 @@ func ProviderEvalTree(n *NodeApplyableProvider, config *configs.Provider) EvalNo seq := make([]EvalNode, 0, 5) seq = append(seq, &EvalInitProvider{ - // FIXME: type is now in the AbsProviderConfig, EvalInitProvider doen't - // need this field anymore - TypeName: addr.Provider.Type, - Addr: addr, + Addr: addr, }) // Input stuff diff --git a/terraform/node_provider_eval.go b/terraform/node_provider_eval.go index 60eaa1790..4814d1fae 100644 --- a/terraform/node_provider_eval.go +++ b/terraform/node_provider_eval.go @@ -13,9 +13,6 @@ func (n *NodeEvalableProvider) EvalTree() EvalNode { addr := n.Addr return &EvalInitProvider{ - // FIXME: type is now in the AbsProviderConfig, EvalInitProvider doen't - // need this field anymore - TypeName: addr.Provider.Type, - Addr: addr, + Addr: addr, } } diff --git a/terraform/schemas.go b/terraform/schemas.go index b10c0f91d..9158382d8 100644 --- a/terraform/schemas.go +++ b/terraform/schemas.go @@ -100,8 +100,8 @@ func loadProviderSchemas(schemas map[addrs.Provider]*ProviderSchema, config *con return } - log.Printf("[TRACE] LoadSchemas: retrieving schema for provider type %q", typeName) - provider, err := components.ResourceProvider(typeName) + log.Printf("[TRACE] LoadSchemas: retrieving schema for provider type %q", fqn.LegacyString()) + provider, err := components.ResourceProvider(fqn) if err != nil { // We'll put a stub in the map so we won't re-attempt this on // future calls.