From f836a58c1874456dd1570169f100da58b66b86d8 Mon Sep 17 00:00:00 2001 From: Roman Zipp Date: Mon, 17 Jan 2022 18:34:45 +0100 Subject: [PATCH] Add storage provider working directory parameter --- main.go | 3 +-- storage/storage.go | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index aef8790..0d98519 100644 --- a/main.go +++ b/main.go @@ -42,8 +42,7 @@ func RegisterPipelineRoutes(r *mux.Router, pipelines []pipelines.IPipeline, stor } func main() { - storageProvider := storage.GetFileSystemStorageProvider("test") - + storageProvider := storage.GetFileSystemStorageProvider("test", "") storageProvider.StoreRaw("abc", "def.test", []byte{0x12, 0x10}) pipes := pipelines.LoadPipelines() diff --git a/storage/storage.go b/storage/storage.go index 24a34c6..2f63381 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -39,8 +39,10 @@ func (sp FileSystemStorageProvider) StoreExisting(bucketName string, objectName return sp.StoreRaw(bucketName, objectName, bytesRead) } -func GetFileSystemStorageProvider(basePath string) FileSystemStorageProvider { - wd, _ := os.Getwd() +func GetFileSystemStorageProvider(basePath string, wd string) FileSystemStorageProvider { + if wd == "" { + wd, _ = os.Getwd() + } return FileSystemStorageProvider{ fileSystem: afero.NewBasePathFs(afero.NewOsFs(), filepath.Join(wd, "files")),