syft/imgbom/presenter/presenter.go
Alfredo Deza 312c8acfbe presenter can pick text-dir, text-img, json-text, or json-img for reporting
Signed-off-by: Alfredo Deza <adeza@anchore.com>
2020-07-02 15:12:48 -04:00

39 lines
974 B
Go

package presenter
import (
"io"
"github.com/anchore/imgbom/imgbom/pkg"
json_dirs "github.com/anchore/imgbom/imgbom/presenter/json/dirs"
json_imgs "github.com/anchore/imgbom/imgbom/presenter/json/imgs"
text_dirs "github.com/anchore/imgbom/imgbom/presenter/text/dirs"
text_imgs "github.com/anchore/imgbom/imgbom/presenter/text/imgs"
"github.com/anchore/stereoscope/pkg/image"
)
type Presenter interface {
Present(io.Writer) error
}
func GetImgPresenter(option Option, img *image.Image, catalog *pkg.Catalog) Presenter {
switch option {
case JSONPresenter:
return json_imgs.NewPresenter(img, catalog)
case TextPresenter:
return text_imgs.NewPresenter(img, catalog)
default:
return nil
}
}
func GetDirPresenter(option Option, path string, catalog *pkg.Catalog) Presenter {
switch option {
case JSONPresenter:
return json_dirs.NewPresenter(catalog, path)
case TextPresenter:
return text_dirs.NewPresenter(catalog, path)
default:
return nil
}
}