mirror of
https://github.com/anchore/syft
synced 2024-11-12 23:27:20 +00:00
048df17e3d
* use pkg values in relationship fields Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add linter rule for using values in relationships Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * use new cmptest package for comparing relationships Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * create cmptest for common cmp.Diff options in test Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * condense matches for relationship ruleguard Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove relationship type from rules Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * restore build tag Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * suggest using values Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * nil check pkgs Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
26 lines
728 B
Go
26 lines
728 B
Go
package cmptest
|
|
|
|
import (
|
|
"github.com/sanity-io/litter"
|
|
|
|
"github.com/anchore/syft/syft/artifact"
|
|
)
|
|
|
|
type RelationshipComparer func(x, y artifact.Relationship) bool
|
|
|
|
var relationshipStringer = litter.Options{
|
|
Compact: true,
|
|
StripPackageNames: false,
|
|
HidePrivateFields: true, // we want to ignore package IDs
|
|
HideZeroValues: true,
|
|
StrictGo: true,
|
|
//FieldExclusions: ... // these can be added for future values that need to be ignored
|
|
//FieldFilter: ...
|
|
}
|
|
|
|
func DefaultRelationshipComparer(x, y artifact.Relationship) bool {
|
|
// we just need a stable sort, the ordering does not need to be sensible
|
|
xStr := relationshipStringer.Sdump(x)
|
|
yStr := relationshipStringer.Sdump(y)
|
|
return xStr < yStr
|
|
}
|