Skip to content

Commit

Permalink
result: add a helper to get packages by ID
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Deza <adeza@anchore.com>
  • Loading branch information
Alfredo Deza committed Aug 31, 2020
1 parent 444b191 commit 8fc7efd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions grype/result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8fc7efd

Please sign in to comment.