github.com/anchore/syft@v1.38.2/syft/format/internal/location_sorter.go (about)

     1  package internal
     2  
     3  import (
     4  	"github.com/anchore/syft/syft/file"
     5  	"github.com/anchore/syft/syft/sbom"
     6  	"github.com/anchore/syft/syft/source"
     7  )
     8  
     9  func GetLocationSorters(s sbom.SBOM) (func(a, b file.Location) int, func(a, b file.Coordinates) int) {
    10  	var layers []string
    11  	if m, ok := s.Source.Metadata.(source.ImageMetadata); ok {
    12  		for _, l := range m.Layers {
    13  			layers = append(layers, l.Digest)
    14  		}
    15  	}
    16  	return file.LocationSorter(layers), file.CoordinatesSorter(layers)
    17  }