Merge pull request #35 from anchore/use-filetree-reader

Utilize filetree reader
This commit is contained in:
Alex Goodman
2020-06-04 14:36:40 -04:00
committed by GitHub
6 changed files with 459 additions and 13 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import (
type Analyzer interface {
Name() string
// TODO: add ID / Name for analyze for uniquely identifying this analyzer type
SelectFiles([]*tree.FileTree) []file.Reference
SelectFiles([]tree.FileTreeReader) []file.Reference
// NOTE: one of the errors which is returned is "IterationNeeded", which indicates to the driver to
// continue with another Select/Analyze pass
Analyze(map[file.Reference]string) ([]pkg.Package, error)
+1 -1
View File
@@ -21,7 +21,7 @@ func (a *Analyzer) Name() string {
return "dpkg-analyzer"
}
func (a *Analyzer) SelectFiles(trees []*tree.FileTree) []file.Reference {
func (a *Analyzer) SelectFiles(trees []tree.FileTreeReader) []file.Reference {
files := make([]file.Reference, 0)
for _, tree := range trees {
// TODO: extract into function/slice/etc
+2 -2
View File
@@ -9,12 +9,12 @@ import (
type Scope struct {
Option Option
Trees []*tree.FileTree
Trees []tree.FileTreeReader
Image *image.Image
}
func NewScope(img *image.Image, option Option) (Scope, error) {
var trees = make([]*tree.FileTree, 0)
var trees = make([]tree.FileTreeReader, 0)
if img == nil {
return Scope{}, fmt.Errorf("no image given")
+5 -1
View File
@@ -81,7 +81,11 @@ func TestScope(t *testing.T) {
t.Fatalf("mismatched tree lengths: %d!=%d", len(actual.Trees), len(c.expectedTrees))
}
for idx, at := range actual.Trees {
for idx, atr := range actual.Trees {
at, ok := atr.(*tree.FileTree)
if !ok {
t.Fatalf("could not extract tree from reader")
}
if !at.Equal(c.expectedTrees[idx]) {
t.Error("mismatched tree @ idx", idx)
}