mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 17:03:17 +01:00
presenter: use new scoped source
Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
parent
4b69758f2c
commit
6e9171e8a6
@ -8,30 +8,50 @@ import (
|
|||||||
json_imgs "github.com/anchore/imgbom/imgbom/presenter/json/imgs"
|
json_imgs "github.com/anchore/imgbom/imgbom/presenter/json/imgs"
|
||||||
text_dirs "github.com/anchore/imgbom/imgbom/presenter/text/dirs"
|
text_dirs "github.com/anchore/imgbom/imgbom/presenter/text/dirs"
|
||||||
text_imgs "github.com/anchore/imgbom/imgbom/presenter/text/imgs"
|
text_imgs "github.com/anchore/imgbom/imgbom/presenter/text/imgs"
|
||||||
"github.com/anchore/stereoscope/pkg/image"
|
"github.com/anchore/imgbom/imgbom/scope"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Presenter interface {
|
type Presenter interface {
|
||||||
Present(io.Writer) error
|
Present(io.Writer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetImgPresenter(option Option, img *image.Image, catalog *pkg.Catalog) Presenter {
|
// GetPresenter returns a presenter for images or directories
|
||||||
switch option {
|
func GetPresenter(option Option, s scope.Scope, catalog *pkg.Catalog) Presenter {
|
||||||
case JSONPresenter:
|
src := s.Source()
|
||||||
return json_imgs.NewPresenter(img, catalog)
|
|
||||||
case TextPresenter:
|
switch src.(type) {
|
||||||
return text_imgs.NewPresenter(img, catalog)
|
case scope.DirSource:
|
||||||
|
return GetDirPresenter(option, s, catalog)
|
||||||
|
case scope.ImageSource:
|
||||||
|
return GetImgPresenter(option, s, catalog)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDirPresenter(option Option, path string, catalog *pkg.Catalog) Presenter {
|
// GetImgPresenter returns a Json or Text presenter for images
|
||||||
|
func GetImgPresenter(option Option, s scope.Scope, c *pkg.Catalog) Presenter {
|
||||||
|
src := s.Source()
|
||||||
|
img := src.(scope.ImageSource).Img
|
||||||
switch option {
|
switch option {
|
||||||
case JSONPresenter:
|
case JSONPresenter:
|
||||||
return json_dirs.NewPresenter(catalog, path)
|
return json_imgs.NewPresenter(img, c)
|
||||||
case TextPresenter:
|
case TextPresenter:
|
||||||
return text_dirs.NewPresenter(catalog, path)
|
return text_imgs.NewPresenter(img, c)
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDirPresenter returns a Json or Text presenter for directories
|
||||||
|
func GetDirPresenter(option Option, s scope.Scope, c *pkg.Catalog) Presenter {
|
||||||
|
src := s.Source()
|
||||||
|
path := src.(scope.DirSource).Path
|
||||||
|
switch option {
|
||||||
|
case JSONPresenter:
|
||||||
|
return json_dirs.NewPresenter(c, path)
|
||||||
|
case TextPresenter:
|
||||||
|
return text_dirs.NewPresenter(c, path)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user