Commit b0d2931a authored by ale's avatar ale

Load configuration files in sorted order

Allows us to use rc.d-style setup where later files override contents
from previous ones, useful in a configuration management context.
parent 53e98a2c
Pipeline #2170 passed with stages
in 1 minute and 26 seconds
......@@ -4,6 +4,7 @@ import (
......@@ -81,12 +82,21 @@ func loadStandaloneBackendConfig(path string) (map[string]yaml.MapSlice, error)
return out, nil
// Sort a string slice.
type filesList []string
func (l filesList) Len() int { return len(l) }
func (l filesList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
func (l filesList) Less(i, j int) bool { return l[i] < l[j] }
// Apply a function to all files matching a glob pattern (errors are ignored).
// Files are visited in sorted order.
func forAllFiles(pattern string, f func(string)) {
files, err := filepath.Glob(pattern)
if err != nil {
for _, file := range files {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment