Skip to content

Commit eb7fe7d

Browse files
committed
Fix zuul.conf render
This change fixes the way zuul.conf file is rendered. Before zuul.config file the keys under each section were ordered by the order they were added to the section. Now we sort each section before writing into the secret. Change-Id: I30859f9809b4d27b06272e5d7ad6ad00590ba72d
1 parent db9b8db commit eb7fe7d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

controllers/zuul.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
_ "embed"
99
"fmt"
1010
"regexp"
11+
"sort"
1112
"strconv"
1213
"strings"
1314

@@ -1452,7 +1453,29 @@ func LoadConfigINI(zuulConf string) *ini.File {
14521453
}
14531454

14541455
func DumpConfigINI(cfg *ini.File) string {
1456+
14551457
writer := bytes.NewBufferString("")
1458+
sections := cfg.Sections()
1459+
1460+
for _, section := range sections {
1461+
1462+
keys := section.Keys()
1463+
sortedKeys := []*ini.Key{}
1464+
1465+
sort.Slice(keys, func(i, j int) bool {
1466+
return keys[i].Name() < keys[j].Name()
1467+
})
1468+
1469+
for _, key := range keys {
1470+
sortedKeys = append(sortedKeys, key)
1471+
section.DeleteKey(key.Name())
1472+
}
1473+
1474+
for _, key := range sortedKeys {
1475+
section.NewKey(key.Name(), key.Value())
1476+
}
1477+
1478+
}
14561479
cfg.WriteTo(writer)
14571480
return writer.String()
14581481
}

0 commit comments

Comments
 (0)