Add poc for local fs repos
This commit is contained in:
parent
0e6ef90e41
commit
64b9d362cf
@ -96,6 +96,8 @@ func (w *conn) Initialize(
|
|||||||
opts repository.Options,
|
opts repository.Options,
|
||||||
retentionOpts repository.Retention,
|
retentionOpts repository.Retention,
|
||||||
) error {
|
) error {
|
||||||
|
w.storage.Provider = storage.ProviderFS
|
||||||
|
|
||||||
bst, err := blobStoreByProvider(ctx, opts, w.storage)
|
bst, err := blobStoreByProvider(ctx, opts, w.storage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return clues.Wrap(err, "initializing storage")
|
return clues.Wrap(err, "initializing storage")
|
||||||
@ -154,6 +156,8 @@ func (w *conn) Initialize(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *conn) Connect(ctx context.Context, opts repository.Options) error {
|
func (w *conn) Connect(ctx context.Context, opts repository.Options) error {
|
||||||
|
w.storage.Provider = storage.ProviderFS
|
||||||
|
|
||||||
bst, err := blobStoreByProvider(ctx, opts, w.storage)
|
bst, err := blobStoreByProvider(ctx, opts, w.storage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return clues.Wrap(err, "initializing storage")
|
return clues.Wrap(err, "initializing storage")
|
||||||
@ -225,6 +229,8 @@ func blobStoreByProvider(
|
|||||||
switch s.Provider {
|
switch s.Provider {
|
||||||
case storage.ProviderS3:
|
case storage.ProviderS3:
|
||||||
return s3BlobStorage(ctx, opts, s)
|
return s3BlobStorage(ctx, opts, s)
|
||||||
|
case storage.ProviderFS:
|
||||||
|
return localFSBlobStorage(ctx, opts, s)
|
||||||
default:
|
default:
|
||||||
return nil, clues.New("storage provider details are required").WithClues(ctx)
|
return nil, clues.New("storage provider details are required").WithClues(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,11 @@ package kopia
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/kopia/kopia/repo/blob"
|
"github.com/kopia/kopia/repo/blob"
|
||||||
|
"github.com/kopia/kopia/repo/blob/filesystem"
|
||||||
"github.com/kopia/kopia/repo/blob/s3"
|
"github.com/kopia/kopia/repo/blob/s3"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||||
@ -54,3 +56,20 @@ func s3BlobStorage(
|
|||||||
|
|
||||||
return store, nil
|
return store, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func localFSBlobStorage(
|
||||||
|
ctx context.Context,
|
||||||
|
repoOpts repository.Options,
|
||||||
|
s storage.Storage,
|
||||||
|
) (blob.Storage, error) {
|
||||||
|
opts := filesystem.Options{
|
||||||
|
Path: os.Getenv("filesystem_path"),
|
||||||
|
}
|
||||||
|
|
||||||
|
store, err := filesystem.New(ctx, &opts, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, clues.Stack(err).WithClues(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
return store, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ type storageProvider int
|
|||||||
const (
|
const (
|
||||||
ProviderUnknown storageProvider = 0 // Unknown Provider
|
ProviderUnknown storageProvider = 0 // Unknown Provider
|
||||||
ProviderS3 storageProvider = 1 // S3
|
ProviderS3 storageProvider = 1 // S3
|
||||||
|
ProviderFS storageProvider = 2 // local or network attached file system
|
||||||
)
|
)
|
||||||
|
|
||||||
// storage parsing errors
|
// storage parsing errors
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user