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
+18
View File
@@ -0,0 +1,18 @@
package pkg
type Catalog struct {
// TODO: catalog by package ID for potential indexing
catalog map[Type][]Package
}
type CatalogWriter interface {
Add(Package) error
}
func (c *Catalog) Add(p Package) {
_, ok := c.catalog[p.Type]
if !ok {
c.catalog[p.Type] = make([]Package, 0)
}
c.catalog[p.Type] = append(c.catalog[p.Type], p)
}
+16
View File
@@ -0,0 +1,16 @@
package pkg
import "github.com/anchore/stereoscope/pkg/file"
// TODO: add package ID (random/incremental)
type Package struct {
Name string
Version string
Source []file.Reference
Licenses []string
Type Type
Metadata interface{}
}
// TODO: stringer...
+17
View File
@@ -0,0 +1,17 @@
package pkg
const (
UnknownPkg uint = iota
ApkPkg
DebPkg
JavaPkg
NodePkg
PacmanPkg
PythonPkg
RpmPkg
RubyPkg
)
type Type uint
// TODO: stringer...