1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00

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/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)
}

View File

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

View File

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

View File

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