syft/imgbom/lib.go
Alex Goodman 7ebb9f4e0b
Add check for app update (#88)
* add check for app update; fix ETUI error handling

* validate user args
2020-07-21 12:02:03 -04:00

48 lines
1.1 KiB
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/wagoodman/go-partybus"
)
func Catalog(userInput string, scoptOpt scope.Option) (*pkg.Catalog, *scope.Scope, *distro.Distro, error) {
s, cleanup, err := scope.NewScope(userInput, scoptOpt)
defer cleanup()
if err != nil {
return nil, nil, nil, err
}
d := IdentifyDistro(s)
catalog, err := CatalogFromScope(s)
if err != nil {
return nil, nil, nil, err
}
return catalog, &s, &d, nil
}
func IdentifyDistro(s scope.Scope) distro.Distro {
log.Info("Identifying Distro")
return distro.Identify(s)
}
func CatalogFromScope(s scope.Scope) (*pkg.Catalog, error) {
log.Info("Building the Catalog")
return cataloger.Catalog(s)
}
func SetLogger(logger logger.Logger) {
log.Log = logger
}
func SetBus(b *partybus.Bus) {
bus.SetPublisher(b)
}