Skip to content

Commit 14be1ce

Browse files
ncwyuval-cloudinary
authored andcommitted
fs: fix --dump filters not always appearing
Before this fix, we initialised the options blocks in a random order. This meant that there was a 50/50 chance whether --dump filters would show the filters or not as it was depending on the "main" block having being read first to set the Dump flags. This initialises the options blocks in a defined order which is alphabetically but with main first which fixes the problem.
1 parent 2a245e3 commit 14be1ce

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

fs/registry.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,22 @@ func (oi *OptionsInfo) load() error {
531531
// their values read from the options, environment variables and
532532
// command line parameters.
533533
func GlobalOptionsInit() error {
534-
for _, opt := range OptionsRegistry {
534+
var keys []string
535+
for key := range OptionsRegistry {
536+
keys = append(keys, key)
537+
}
538+
sort.Slice(keys, func(i, j int) bool {
539+
// Sort alphabetically, but with "main" first
540+
if keys[i] == "main" {
541+
return true
542+
}
543+
if keys[j] == "main" {
544+
return false
545+
}
546+
return keys[i] < keys[j]
547+
})
548+
for _, key := range keys {
549+
opt := OptionsRegistry[key]
535550
err := opt.load()
536551
if err != nil {
537552
return err

0 commit comments

Comments
 (0)