command: use backendinit instead of initializing legacy directly

Fixes #12806

This should've been part of 2c19aa69d9

This is the same issue, just missed a spot. Tests are hard to cover for
this since we're removing the legacy backends one by one, eventually
it'll be gone. A good sign is that we don't import backendlegacy at all
anymore in command/
This commit is contained in:
Mitchell Hashimoto 2017-03-17 10:41:13 -07:00
parent c87f3dfdd5
commit 96e38041ab
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 7 additions and 4 deletions

View File

@ -23,7 +23,6 @@ import (
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/mapstructure"
backendlegacy "github.com/hashicorp/terraform/backend/legacy"
backendlocal "github.com/hashicorp/terraform/backend/local"
)
@ -1325,8 +1324,12 @@ func (m *Meta) backendInitFromLegacy(s *terraform.RemoteState) (backend.Backend,
}
config := terraform.NewResourceConfig(rawC)
// Initialize the legacy remote backend
b := &backendlegacy.Backend{Type: s.Type}
// Get the backend
f := backendinit.Backend(s.Type)
if f == nil {
return nil, fmt.Errorf(strings.TrimSpace(errBackendLegacyUnknown), s.Type)
}
b := f()
// Configure
if err := b.Configure(config); err != nil {
@ -1381,7 +1384,7 @@ If fixing these errors requires changing your remote state configuration,
you must switch your configuration to the new remote backend configuration.
You can learn more about remote backends at the URL below:
TODO: URL
https://www.terraform.io/docs/backends/index.html
The error(s) configuring the legacy remote state: