syft/imgbom/lib.go
Alfredo Deza faf21a67a6 lib: return a protocol-based scope (dir or img)
Signed-off-by: Alfredo Deza <adeza@anchore.com>
2020-07-02 15:12:48 -04:00

42 lines
961 B
Go

package imgbom
import (
"github.com/anchore/imgbom/imgbom/cataloger"
"github.com/anchore/imgbom/imgbom/distro"
"github.com/anchore/imgbom/imgbom/logger"
"github.com/anchore/imgbom/imgbom/pkg"
"github.com/anchore/imgbom/imgbom/scope"
"github.com/anchore/imgbom/internal/bus"
"github.com/anchore/imgbom/internal/log"
"github.com/anchore/stereoscope/pkg/image"
"github.com/wagoodman/go-partybus"
)
func IdentifyDistro(img *image.Image) *distro.Distro {
return distro.Identify(img)
}
func CatalogDir(d string, o scope.Option) (*pkg.Catalog, error) {
s, err := scope.NewDirScope(d, o)
if err != nil {
return nil, err
}
return cataloger.Catalog(s)
}
func CatalogImg(img *image.Image, o scope.Option) (*pkg.Catalog, error) {
s, err := scope.NewImageScope(img, o)
if err != nil {
return nil, err
}
return cataloger.Catalog(s)
}
func SetLogger(logger logger.Logger) {
log.Log = logger
}
func SetBus(b *partybus.Bus) {
bus.SetPublisher(b)
}