add analyzer interface/controller and supporting package/catalog

This commit is contained in:
Alex Goodman
2020-05-13 10:13:48 -04:00
parent 11b2b1ab45
commit cb6555491c
7 changed files with 91 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
package analyzer
import (
"github.com/anchore/imgbom/imgbom/pkg"
"github.com/anchore/imgbom/imgbom/scope"
"github.com/anchore/stereoscope/pkg/file"
)
type Analyzer interface {
SelectFiles(scope.Scope) []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(pkg.CatalogWriter, map[file.Reference]string) error
}
+21
View File
@@ -0,0 +1,21 @@
package analyzer
var controllerInstance controller
func init() {
controllerInstance = controller{
analyzers: make([]Analyzer, 0),
}
}
type controller struct {
analyzers []Analyzer
}
func (c *controller) add(a Analyzer) {
c.analyzers = append(c.analyzers, a)
}
func Add(a Analyzer) {
controllerInstance.add(a)
}