split catalogers into two sets, one for images another for directory scans

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2020-10-08 10:23:24 -04:00
committed by Toure Dunnon
parent 1c320a8382
commit 10b44f5311
19 changed files with 218 additions and 149 deletions
+1 -3
View File
@@ -34,9 +34,7 @@ func NewPresenter(catalog *pkg.Catalog, s scope.Scope, d distro.Distro) *Present
func (pres *Presenter) Present(output io.Writer) error {
bom := NewDocumentFromCatalog(pres.catalog, pres.distro)
srcObj := pres.scope.Source()
switch src := srcObj.(type) {
switch src := pres.scope.Source.(type) {
case scope.DirSource:
bom.BomDescriptor.Component = &BdComponent{
Component: Component{
+1 -2
View File
@@ -15,8 +15,7 @@ type ImageLocation struct {
}
func NewLocations(p *pkg.Package, s scope.Scope) (Locations, error) {
srcObj := s.Source()
switch src := srcObj.(type) {
switch src := s.Source.(type) {
case scope.ImageSource:
locations := make([]ImageLocation, len(p.Source))
for idx := range p.Source {
+2 -3
View File
@@ -12,8 +12,7 @@ type Source struct {
}
func NewSource(s scope.Scope) (Source, error) {
srcObj := s.Source()
switch src := srcObj.(type) {
switch src := s.Source.(type) {
case scope.ImageSource:
return Source{
Type: "image",
@@ -22,7 +21,7 @@ func NewSource(s scope.Scope) (Source, error) {
case scope.DirSource:
return Source{
Type: "directory",
Target: s.DirSrc.Path,
Target: src.Path,
}, nil
default:
return Source{}, fmt.Errorf("unsupported source: %T", src)
+1 -2
View File
@@ -27,9 +27,8 @@ func (pres *Presenter) Present(output io.Writer) error {
// init the tabular writer
w := new(tabwriter.Writer)
w.Init(output, 0, 8, 0, '\t', tabwriter.AlignRight)
srcObj := pres.scope.Source()
switch src := srcObj.(type) {
switch src := pres.scope.Source.(type) {
case scope.DirSource:
fmt.Fprintln(w, fmt.Sprintf("[Path: %s]", src.Path))
case scope.ImageSource: