github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/internal/cmptest/relationship.go (about) 1 package cmptest 2 3 import ( 4 "github.com/sanity-io/litter" 5 6 "github.com/anchore/syft/syft/artifact" 7 ) 8 9 type RelationshipComparer func(x, y artifact.Relationship) bool 10 11 var relationshipStringer = litter.Options{ 12 Compact: true, 13 StripPackageNames: false, 14 HidePrivateFields: true, // we want to ignore package IDs 15 HideZeroValues: true, 16 StrictGo: true, 17 //FieldExclusions: ... // these can be added for future values that need to be ignored 18 //FieldFilter: ... 19 } 20 21 func DefaultRelationshipComparer(x, y artifact.Relationship) bool { 22 // we just need a stable sort, the ordering does not need to be sensible 23 xStr := relationshipStringer.Sdump(x) 24 yStr := relationshipStringer.Sdump(y) 25 return xStr < yStr 26 }