Skip to content

Commit 9a5b628

Browse files
committed
Ensure consistent order of yaml keys in migrateConfig
1 parent 1f61685 commit 9a5b628

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/config/config_file.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func migrateConfig(filename string) error {
108108
return err
109109
}
110110

111-
var hosts map[string][]map[string]string
111+
var hosts map[string][]yaml.Node
112112
err = yaml.Unmarshal(b, &hosts)
113113
if err != nil {
114114
return fmt.Errorf("error decoding legacy format: %w", err)
@@ -119,8 +119,9 @@ func migrateConfig(filename string) error {
119119
if len(entries) < 1 {
120120
continue
121121
}
122-
for key, value := range entries[0] {
123-
if err := cfg.Set(hostname, key, value); err != nil {
122+
mapContent := entries[0].Content
123+
for i := 0; i < len(mapContent)-1; i += 2 {
124+
if err := cfg.Set(hostname, mapContent[i].Value, mapContent[i+1].Value); err != nil {
124125
return err
125126
}
126127
}

0 commit comments

Comments
 (0)