result: add a helper to get packages by ID

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza 2020-08-28 12:20:23 -04:00
parent 444b191404
commit 8fc7efd464

View file

@ -19,6 +19,15 @@ func NewResult() Result {
}
}
// GetByPkgID returns a slice of potential matches from an ID
func (r *Result) GetByPkgID(id pkg.ID) []match.Match {
matches, ok := r.byPackage[id]
if !ok {
return nil
}
return matches
}
func (r *Result) Merge(other Result) {
// note: de-duplication of matches is an upstream concern (not here)
for pkgID, matches := range other.byPackage {