Merge pull request #12778 from hashicorp/jbardin/GH-12741

change to default state after backend migration
This commit is contained in:
James Bardin 2017-03-16 16:07:25 -04:00 committed by GitHub
commit 9bfa361e21
4 changed files with 10 additions and 0 deletions

View File

@ -183,6 +183,10 @@ func (m *Meta) backendMigrateState_S_s(opts *backendMigrateOpts) error {
// Copy the default state // Copy the default state
opts.oneEnv = currentEnv opts.oneEnv = currentEnv
// now switch back to the default env so we can acccess the new backend
m.SetEnv(backend.DefaultStateName)
return m.backendMigrateState_s_s(opts) return m.backendMigrateState_s_s(opts)
} }

View File

@ -1144,6 +1144,11 @@ func TestMetaBackend_configuredChangeCopy_multiToSingle(t *testing.T) {
if _, err := os.Stat(envPath); err != nil { if _, err := os.Stat(envPath); err != nil {
t.Fatal("env should exist") t.Fatal("env should exist")
} }
// Verify we are now in the default env, or we may not be able to access the new backend
if env := m.Env(); env != backend.DefaultStateName {
t.Fatal("using non-default env with single-env backend")
}
} }
// Changing a configured backend that supports multi-state to a // Changing a configured backend that supports multi-state to a