Skip to content

Commit

Permalink
Allow restore post
Browse files Browse the repository at this point in the history
  • Loading branch information
dmashuda committed Feb 6, 2025
1 parent f440629 commit 00b42a2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions internal/dev_server/api/restore_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ package api

import (
"context"
"github.com/launchdarkly/ldcli/internal/dev_server/model"
)

func (s server) RestoreBackup(ctx context.Context, request RestoreBackupRequestObject) (RestoreBackupResponseObject, error) {
request.Body
panic("implement me")
store := model.StoreFromContext(ctx)
_, err := store.RestoreBackup(ctx, request.Body)
if err != nil {
return nil, err
}
return RestoreBackup200Response{}, nil
}
2 changes: 1 addition & 1 deletion internal/dev_server/db/backup/sqllite_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (m *Manager) connectToDb(ctx context.Context, path string) (*sql.DB, error)
}

// RestoreToFile returns a string path of the sqlite database restored from the stream
func (m *Manager) RestoreToFile(ctx context.Context, stream io.ReadCloser) (string, error) {
func (m *Manager) RestoreToFile(ctx context.Context, stream io.Reader) (string, error) {
m.mutex.Lock()
defer m.mutex.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion internal/dev_server/db/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (s Sqlite) DeactivateOverride(ctx context.Context, projectKey, flagKey stri
return version, nil
}

func (s Sqlite) RestoreBackup(ctx context.Context, stream io.ReadCloser) (string, error) {
func (s Sqlite) RestoreBackup(ctx context.Context, stream io.Reader) (string, error) {
filepath, err := s.backupManager.RestoreToFile(ctx, stream)

return filepath, err
Expand Down
2 changes: 1 addition & 1 deletion internal/dev_server/model/mocks/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/dev_server/model/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Store interface {
GetAvailableVariationsForProject(ctx context.Context, projectKey string) (map[string][]Variation, error)

CreateBackup(ctx context.Context) (io.ReadCloser, int64, error)
RestoreBackup(ctx context.Context, stream io.ReadCloser) (string, error)
RestoreBackup(ctx context.Context, stream io.Reader) (string, error)
}

func ContextWithStore(ctx context.Context, store Store) context.Context {
Expand Down

0 comments on commit 00b42a2

Please sign in to comment.