Skip to content

Commit

Permalink
localfs first skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuller authored and Gerrit91 committed Feb 7, 2024
1 parent 751e006 commit 7cd119b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ endif
.PHONY: build
build: generate-examples
go mod tidy
go build -ldflags "$(LINKMODE)" -tags 'osusergo netgo static_build' -o bin/backup-restore-sidecar github.com/metal-stack/backup-restore-sidecar/cmd
go build -ldflags "-X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
-X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)' \
$(EXTLDFLAGS)" \
-tags 'osusergo netgo static_build' -o bin/backup-restore-sidecar github.com/metal-stack/backup-restore-sidecar/cmd
strip bin/backup-restore-sidecar

.PHONY: test
Expand Down
35 changes: 35 additions & 0 deletions cmd/internal/database/localfs/localfs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package localfs

import "go.uber.org/zap"

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

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

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

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

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

func (l *LocalFS) Probe() error {
//Nothing to do, not a real Database
return nil
}
10 changes: 9 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ 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 Down Expand Up @@ -273,7 +275,7 @@ func init() {
rootCmd.AddCommand(startCmd, waitCmd, restoreCmd, createBackupCmd)

rootCmd.PersistentFlags().StringP(logLevelFlg, "", "info", "sets the application log level")
rootCmd.PersistentFlags().StringP(databaseFlg, "", "", "the kind of the database [postgres|rethinkdb|etcd|meilisearch|redis|keydb]")
rootCmd.PersistentFlags().StringP(databaseFlg, "", "", "the kind of the database [postgres|rethinkdb|etcd|meilisearch|redis|keydb|localfs]")
rootCmd.PersistentFlags().StringP(databaseDatadirFlg, "", "", "the directory where the database stores its data in")

err := viper.BindPFlags(rootCmd.PersistentFlags())
Expand Down Expand Up @@ -459,6 +461,12 @@ func initDatabase() error {
if err != nil {
return err
}
case "localfs":
db = localfs.New(
logger.Named("localfs"),
datadir,
)

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

0 comments on commit 7cd119b

Please sign in to comment.