From ce9794b2c60b4db42eb4ebe36e08941db5e9e72a Mon Sep 17 00:00:00 2001 From: Lukas Schulte Pelkum Date: Thu, 15 Apr 2021 21:03:26 +0200 Subject: [PATCH] Restructure drivers --- internal/storage/driver.go | 9 ++++++--- internal/storage/{ => file}/file_driver.go | 2 +- internal/storage/{ => mongodb}/mongodb_driver.go | 2 +- internal/storage/{ => s3}/s3_driver.go | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) rename internal/storage/{ => file}/file_driver.go (99%) rename internal/storage/{ => mongodb}/mongodb_driver.go (99%) rename internal/storage/{ => s3}/s3_driver.go (99%) diff --git a/internal/storage/driver.go b/internal/storage/driver.go index 98c9831..3290a88 100644 --- a/internal/storage/driver.go +++ b/internal/storage/driver.go @@ -6,6 +6,9 @@ import ( "github.com/lus/pasty/internal/config" "github.com/lus/pasty/internal/shared" + "github.com/lus/pasty/internal/storage/file" + "github.com/lus/pasty/internal/storage/mongodb" + "github.com/lus/pasty/internal/storage/s3" ) // Current holds the current storage driver @@ -43,14 +46,14 @@ func Load() error { func GetDriver(storageType shared.StorageType) (Driver, error) { switch storageType { case shared.StorageTypeFile: - return new(FileDriver), nil + return new(file.FileDriver), nil case shared.StorageTypePostgres: // TODO: Implement Postgres driver return nil, errors.New("TODO") case shared.StorageTypeMongoDB: - return new(MongoDBDriver), nil + return new(mongodb.MongoDBDriver), nil case shared.StorageTypeS3: - return new(S3Driver), nil + return new(s3.S3Driver), nil default: return nil, fmt.Errorf("invalid storage type '%s'", storageType) } diff --git a/internal/storage/file_driver.go b/internal/storage/file/file_driver.go similarity index 99% rename from internal/storage/file_driver.go rename to internal/storage/file/file_driver.go index 055f1fd..f394f2b 100644 --- a/internal/storage/file_driver.go +++ b/internal/storage/file/file_driver.go @@ -1,4 +1,4 @@ -package storage +package file import ( "encoding/base64" diff --git a/internal/storage/mongodb_driver.go b/internal/storage/mongodb/mongodb_driver.go similarity index 99% rename from internal/storage/mongodb_driver.go rename to internal/storage/mongodb/mongodb_driver.go index 66937ab..2831422 100644 --- a/internal/storage/mongodb_driver.go +++ b/internal/storage/mongodb/mongodb_driver.go @@ -1,4 +1,4 @@ -package storage +package mongodb import ( "context" diff --git a/internal/storage/s3_driver.go b/internal/storage/s3/s3_driver.go similarity index 99% rename from internal/storage/s3_driver.go rename to internal/storage/s3/s3_driver.go index e79b40c..e3f0e06 100644 --- a/internal/storage/s3_driver.go +++ b/internal/storage/s3/s3_driver.go @@ -1,4 +1,4 @@ -package storage +package s3 import ( "bytes"