diff --git a/backend/local/backend.go b/backend/local/backend.go index 3f6f61847..6b119c297 100644 --- a/backend/local/backend.go +++ b/backend/local/backend.go @@ -180,28 +180,9 @@ func (b *Local) DeleteState(name string) error { func (b *Local) State(name string) (state.State, error) { statePath, stateOutPath, backupPath := b.StatePaths(name) - // If we have a backend handling state, defer to that. + // If we have a backend handling state, delegate to that. if b.Backend != nil { - s, err := b.Backend.State(name) - if err != nil { - return nil, err - } - - // make sure we always have a backup state, unless it disabled - if backupPath == "" { - return s, nil - } - - // see if the delegated backend returned a BackupState of its own - if s, ok := s.(*state.BackupState); ok { - return s, nil - } - - s = &state.BackupState{ - Real: s, - Path: backupPath, - } - return s, nil + return b.Backend.State(name) } if s, ok := b.states[name]; ok { diff --git a/backend/local/backend_test.go b/backend/local/backend_test.go index 2b70df2fc..c22b92cd6 100644 --- a/backend/local/backend_test.go +++ b/backend/local/backend_test.go @@ -229,43 +229,6 @@ func TestLocal_multiStateBackend(t *testing.T) { } } -// verify that a remote state backend is always wrapped in a BackupState -func TestLocal_remoteStateBackup(t *testing.T) { - // assign a separate backend to mock a remote state backend - b := &Local{ - Backend: &testDelegateBackend{}, - } - - s, err := b.State("default") - if err != nil { - t.Fatal(err) - } - - bs, ok := s.(*state.BackupState) - if !ok { - t.Fatal("remote state is not backed up") - } - - if bs.Path != DefaultStateFilename+DefaultBackupExtension { - t.Fatal("bad backup location:", bs.Path) - } - - // do the same with a named state, which should use the local env directories - s, err = b.State("test") - if err != nil { - t.Fatal(err) - } - - bs, ok = s.(*state.BackupState) - if !ok { - t.Fatal("remote state is not backed up") - } - - if bs.Path != filepath.Join(DefaultWorkspaceDir, "test", DefaultStateFilename+DefaultBackupExtension) { - t.Fatal("bad backup location:", bs.Path) - } -} - // change into a tmp dir and return a deferable func to change back and cleanup func testTmpDir(t *testing.T) func() { tmp, err := ioutil.TempDir("", "tf")