refac: decouple persistence and image storage behind driver registries
This commit is contained in:
1 parent
421cfafec3
commit
81e299f09a
46 files changed
+1036
-374
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
domain "RenewCMS/internal/domain/image"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const DriverLocal = "local"
|
||||
|
||||
type Config struct {
|
||||
Driver string
|
||||
Location string
|
||||
}
|
||||
|
||||
func Open(config Config) (domain.Storage, error) {
|
||||
switch config.Driver {
|
||||
case DriverLocal:
|
||||
return NewLocalStorage(config.Location), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported storage driver %q", config.Driver)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user