mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
add analyzer interface/controller and supporting package/catalog
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user