change to default state after backend migration
When migrating from a multi-state backend to a single-state backend, we have to ensure that our locally configured environment is changed back to "default", or we won't be able to access the new backend.
This commit is contained in:
parent
fe4668cc88
commit
ea095eda87
|
@ -183,6 +183,10 @@ func (m *Meta) backendMigrateState_S_s(opts *backendMigrateOpts) error {
|
|||
|
||||
// Copy the default state
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -1144,6 +1144,11 @@ func TestMetaBackend_configuredChangeCopy_multiToSingle(t *testing.T) {
|
|||
if _, err := os.Stat(envPath); err != nil {
|
||||
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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
env1
|
Loading…
Reference in New Issue