Skip to content

Commit

Permalink
Adapt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Feb 7, 2024
1 parent 7cd119b commit 2d351c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 15 additions & 7 deletions cmd/internal/database/localfs/localfs.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
package localfs

import "go.uber.org/zap"
import (
"context"
"log/slog"
)

type LocalFS struct {
datadir string
log *zap.SugaredLogger
log *slog.Logger
}

func New(log *zap.SugaredLogger, datadir string) *LocalFS {
func New(log *slog.Logger, datadir string) *LocalFS {
return &LocalFS{
datadir: datadir,
log: log,
}
}

func (l *LocalFS) Check() (bool, error) {
func (l *LocalFS) Check(ctx context.Context) (bool, error) {
//ToDo: check if Datadir empty -> true
return true, nil
}

func (l *LocalFS) Backup() error {
func (l *LocalFS) Backup(ctx context.Context) error {
//ToDo: put Datadir into compressed archive
return nil
}

func (l *LocalFS) Recover() error {
func (l *LocalFS) Recover(ctx context.Context) error {
//ToDo: decompress archive into Datadir
return nil
}

func (l *LocalFS) Probe() error {
func (l *LocalFS) Probe(ctx context.Context) error {
//Nothing to do, not a real Database
return nil
}

func (_ *LocalFS) Upgrade(ctx context.Context) error {
// Nothing to do here
return nil
}
6 changes: 2 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"os/signal"
"strings"

"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/localfs"

v1 "github.com/metal-stack/backup-restore-sidecar/api/v1"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/backup"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/backup/providers"
Expand All @@ -20,6 +18,7 @@ import (
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/compress"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/etcd"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/localfs"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/meilisearch"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/postgres"
"github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/redis"
Expand Down Expand Up @@ -463,10 +462,9 @@ func initDatabase() error {
}
case "localfs":
db = localfs.New(
logger.Named("localfs"),
logger.WithGroup("localfs"),
datadir,
)

default:
return fmt.Errorf("unsupported database type: %s", dbString)
}
Expand Down

0 comments on commit 2d351c9

Please sign in to comment.