Restructure drivers

This commit is contained in:
Lukas Schulte Pelkum 2021-04-15 21:03:26 +02:00
parent 681ee9f1d0
commit ce9794b2c6
No known key found for this signature in database
GPG Key ID: 408DA7CA81DB885C
4 changed files with 9 additions and 6 deletions

View File

@ -6,6 +6,9 @@ import (
"github.com/lus/pasty/internal/config" "github.com/lus/pasty/internal/config"
"github.com/lus/pasty/internal/shared" "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 // Current holds the current storage driver
@ -43,14 +46,14 @@ func Load() error {
func GetDriver(storageType shared.StorageType) (Driver, error) { func GetDriver(storageType shared.StorageType) (Driver, error) {
switch storageType { switch storageType {
case shared.StorageTypeFile: case shared.StorageTypeFile:
return new(FileDriver), nil return new(file.FileDriver), nil
case shared.StorageTypePostgres: case shared.StorageTypePostgres:
// TODO: Implement Postgres driver // TODO: Implement Postgres driver
return nil, errors.New("TODO") return nil, errors.New("TODO")
case shared.StorageTypeMongoDB: case shared.StorageTypeMongoDB:
return new(MongoDBDriver), nil return new(mongodb.MongoDBDriver), nil
case shared.StorageTypeS3: case shared.StorageTypeS3:
return new(S3Driver), nil return new(s3.S3Driver), nil
default: default:
return nil, fmt.Errorf("invalid storage type '%s'", storageType) return nil, fmt.Errorf("invalid storage type '%s'", storageType)
} }

View File

@ -1,4 +1,4 @@
package storage package file
import ( import (
"encoding/base64" "encoding/base64"

View File

@ -1,4 +1,4 @@
package storage package mongodb
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package storage package s3
import ( import (
"bytes" "bytes"