Skip to content

Commit

Permalink
files: sort unit preset in alphabetical order
Browse files Browse the repository at this point in the history
Sort unit presets in alphabetical order in the 20-ignition.preset file
to ensure the preset file is in a consistent order

Fixes coreos#1339
  • Loading branch information
marmijo committed Jun 1, 2022
1 parent 163492f commit 9370084
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/exec/stages/files/units.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"path/filepath"
"sort"
"strings"

"github.com/coreos/ignition/v2/config/shared/errors"
Expand Down Expand Up @@ -151,7 +152,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 {
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 9370084

Please sign in to comment.