Skip to content

Commit

Permalink
Reuse existing implementation for retrieving sorted map keys.
Browse files Browse the repository at this point in the history
Signed-off-by: Vasil Sirakov <sirakov97@gmail.com>
  • Loading branch information
VasilSirakov committed Feb 11, 2025
1 parent 236564f commit 4188000
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions sbom/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package generator
import (
"encoding/json"
"fmt"
"slices"
"strings"
"time"

Expand All @@ -15,6 +14,7 @@ import (
"go.mondoo.com/cnquery/v11/cli/reporter"
"go.mondoo.com/cnquery/v11/mrn"
"go.mondoo.com/cnquery/v11/sbom"
"go.mondoo.com/cnquery/v11/utils/sortx"
)

var LABEL_KERNEL_RUNNING = "mondoo.com/os/kernel-running"
Expand Down Expand Up @@ -62,7 +62,7 @@ func GenerateBom(r *reporter.Report) []*sbom.Sbom {
continue
}
// ensure deterministic order of enumeration
keys := getSortedMapKeys(dataPoints.Values)
keys := sortx.Keys(dataPoints.Values)
for _, k := range keys {
dataValue := dataPoints.Values[k]
jsondata, err := reporter.JsonValue(dataValue.Content)
Expand Down Expand Up @@ -205,12 +205,3 @@ func enrichPlatformIds(ids []string) []string {
}
return platformIds
}

func getSortedMapKeys[T any](m map[string]T) []string {
keys := []string{}
for k := range m {
keys = append(keys, k)
}
slices.Sort(keys)
return keys
}

0 comments on commit 4188000

Please sign in to comment.