Skip to content

Commit

Permalink
sort unit presets in alphabetical order per coreos#1339
Browse files Browse the repository at this point in the history
  • Loading branch information
marmijo committed Jun 1, 2022
1 parent 163492f commit 3091f01
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/exec/stages/files/units.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,16 @@ func (s *stage) createSystemdPresetFile(presets map[string]*Preset) error {
return err
}
hasInstanceUnit := false
for _, value := range presets {

// sort the units before writing to the systemd presets file
unitNames := make([]string, 0, len(presets))
for unit, _ := range(presets) {

This comment has been minimized.

Copy link
@marmijo

marmijo Jun 1, 2022

Author Owner

This syntax works, but I'm not sure that it's necessary. Does Go automatically throw away the second return, or should I explicitly capture it?

unitNames = append(unitNames, unit)
}
sort.Strings(unitNames)

for i := range unitNames {
value := presets[unitNames[i]]
unitString := value.unit
if value.instantiatable {
hasInstanceUnit = true
Expand Down

0 comments on commit 3091f01

Please sign in to comment.