diff --git a/.gitignore b/.gitignore
index 8f1ab1a5b641837ad60ab6222a8b54953acc53b1..b8bff3c0a2646500944e4df452535a083981997f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,7 +24,8 @@ var/
tmp/
# HARMONY specific
-config/**/*.local.*
+config/**/local/*
+!config/**/local/.gitkeep
files/**/*
!files/.gitkeep
diff --git a/config/local/.gitkeep b/config/local/.gitkeep
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/src/core/config/config.go b/src/core/config/config.go
index e07db49be725bb3e6cad3977b3434f0241b4f591..885afc541af6ebbfd1b8bf897a5eb719f1e91f16 100644
--- a/src/core/config/config.go
+++ b/src/core/config/config.go
@@ -88,7 +88,7 @@ func defaultOptions() *Options {
// C reads a config file of type TOML and unmarshalls it into the given config struct.
// C will override the config struct with a local config file if it exists.
-// After overriding with .local.toml the config will be overwritten by environment variables as well.
+// After overriding with the local config file the config will be overwritten by environment variables as well.
// The C function expects parameters through Option functions, default values are provided.
//
// If the Validate() Option is passed a validator.Validate the config struct will be validated.
@@ -96,9 +96,10 @@ func defaultOptions() *Options {
// Using default options the config file is expected to be located in the config/ directory.
// Default example: config/config.toml
//
-// The config file will be overwritten by a local config file if it exists.
-// For the local config a "local" will be inserted between filename and file extension.
-// Default example: config/config.local.toml
+// For the local config it locates the sub-folder local/ and looks for a file with the same name and extension.
+// Default example: config/local/config.toml
+// Before, this was done by appending ".local" to the filename and before the extension. However, this was changed because
+// it was inconvenient when using docker volumes.
//
// Then the config will be overwritten by environment variables.
// For overwriting through environment variables the struct must be annotated
@@ -127,13 +128,14 @@ func C(c any, opts ...Option) error {
opt(o)
}
- fPath := filepath.Join(o.dir, fmt.Sprintf("%s.%s", o.filename, o.fileExt))
+ fullFilename := fmt.Sprintf("%s.%s", o.filename, o.fileExt)
+ fPath := filepath.Join(o.dir, fullFilename)
b, err := os.ReadFile(fPath)
if err != nil {
return errors.Join(herr.ErrReadFile, err)
}
- flPath := filepath.Join(o.dir, fmt.Sprintf("%s.local.%s", o.filename, o.fileExt))
+ flPath := filepath.Join(o.dir, "local", fullFilename)
bl, _ := os.ReadFile(flPath) // ignore error
if err := parseConfig(c, b, bl); err != nil {
diff --git a/src/core/config/config_test.go b/src/core/config/config_test.go
index 6647a79ea59634c9bcd4f33081f37e2e60495f87..f2cd6f94a3f2294118755e2ca6da683cfbbb0b5f 100644
--- a/src/core/config/config_test.go
+++ b/src/core/config/config_test.go
@@ -82,9 +82,13 @@ func TestC(t *testing.T) {
t.Run("local config override", func(t *testing.T) {
tempDir := t.TempDir()
+ localDir := filepath.Join(tempDir, "local")
+ err := os.Mkdir(localDir, 0755)
+ require.NoError(t, err)
+
path := filepath.Join(tempDir, "config.toml")
- localPath := filepath.Join(tempDir, "config.local.toml")
- err := os.WriteFile(path, []byte(`Name = "OriginalName"`), 0644)
+ localPath := filepath.Join(localDir, "config.toml")
+ err = os.WriteFile(path, []byte(`Name = "OriginalName"`), 0644)
require.NoError(t, err)
err = os.WriteFile(localPath, []byte(`Name = "LocalName"`), 0644)