mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
stabilize json file metadata presenter order
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
0e9c1c1d86
commit
40199096e9
@ -2,6 +2,7 @@ package poweruser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"github.com/anchore/syft/syft/file"
|
||||
@ -46,5 +47,13 @@ func NewJSONFileMetadata(data map[source.Location]source.FileMetadata, digests m
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// sort by real path then virtual path to ensure the result is stable across multiple runs
|
||||
sort.SliceStable(results, func(i, j int) bool {
|
||||
if results[i].Location.RealPath != results[j].Location.RealPath {
|
||||
return results[i].Location.VirtualPath < results[j].Location.VirtualPath
|
||||
}
|
||||
return false
|
||||
})
|
||||
return results, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user