From d87ae291e4d80b325a5a6cb220a74fe7b9cb5c43 Mon Sep 17 00:00:00 2001 From: Fabian Vowie Date: Mon, 17 Jan 2022 12:10:48 +0100 Subject: [PATCH] Rename FileSystem in settings to StorageProvider --- main.go | 4 ++-- settings/settings.go | 14 +++++++------- settings/settings_test.go | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 42c4945..e8bf674 100644 --- a/main.go +++ b/main.go @@ -47,8 +47,8 @@ func main() { var storageProvider storage.IStorageProvider - if settings.FileSystem.Type == 0 { - storageProvider = storage.GetFileSystemStorageProvider(settings.FileSystem.BasePath) + if settings.StorageProvider.Type == 0 { + storageProvider = storage.GetFileSystemStorageProvider(settings.StorageProvider.BasePath) } else { panic("Invalid file system provided!") } diff --git a/settings/settings.go b/settings/settings.go index c4186fc..35e960d 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -13,17 +13,17 @@ const ( type FileSystemType int type Settings struct { - Endpoint string - Token string - FileSystem FileSystemSettings + Endpoint string + Token string + StorageProvider StorageSettings } -type FileSystemSettings struct { +type StorageSettings struct { Type FileSystemType BasePath string } -func ParseSettings(data []byte) Settings { +func parseSettings(data []byte) Settings { settings := Settings{} json.Unmarshal(data, &settings) @@ -39,14 +39,14 @@ func LoadSettings() Settings { data, err := os.ReadFile(path) if err == nil { - return ParseSettings(data) + return parseSettings(data) } // If file does not exist, create default settings defaultSettings := Settings{ Endpoint: "127.0.0.1:8000", Token: "changeme", - FileSystem: FileSystemSettings{ + StorageProvider: StorageSettings{ Type: Local, BasePath: "assets", }, diff --git a/settings/settings_test.go b/settings/settings_test.go index 3a1f44e..96e667a 100644 --- a/settings/settings_test.go +++ b/settings/settings_test.go @@ -10,17 +10,17 @@ func TestSettingsLoading(t *testing.T) { const file string = `{ "endpoint": "0.0.0.0:8000", "token": "foobar", - "fileSystem": { + "storageProvider": { "type": 0, "basePath": "assets" } }` t.Run("Settings parsing is successful", func(t *testing.T) { - settings := ParseSettings([]byte(file)) + settings := parseSettings([]byte(file)) assert.Equal(t, "0.0.0.0:8000", settings.Endpoint) assert.Equal(t, "foobar", settings.Token) - assert.Equal(t, "assets", settings.FileSystem.BasePath) + assert.Equal(t, "assets", settings.StorageProvider.BasePath) }) }