mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 17:03:17 +01:00
update event handlers relative to new command structure
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
6a960ec1f3
commit
18dd2950ac
@ -8,11 +8,11 @@ import (
|
||||
"github.com/wagoodman/go-partybus"
|
||||
)
|
||||
|
||||
// CatalogerFinishedHandler is a UI function for processing the CatalogerFinished bus event, displaying the catalog
|
||||
// CatalogerPresenterReady is a UI function for processing the CatalogerFinished bus event, displaying the catalog
|
||||
// via the given presenter to stdout.
|
||||
func CatalogerFinishedHandler(event partybus.Event) error {
|
||||
func CatalogerPresenterReady(event partybus.Event) error {
|
||||
// show the report to stdout
|
||||
pres, err := syftEventParsers.ParseCatalogerFinished(event)
|
||||
pres, err := syftEventParsers.ParsePresenterReady(event)
|
||||
if err != nil {
|
||||
return fmt.Errorf("bad CatalogerFinished event: %w", err)
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ eventLoop:
|
||||
log.Errorf("unable to show %s event: %+v", e.Type, err)
|
||||
}
|
||||
|
||||
case e.Type == syftEvent.CatalogerFinished:
|
||||
case e.Type == syftEvent.PresenterReady:
|
||||
// we may have other background processes still displaying progress, wait for them to
|
||||
// finish before discontinuing dynamic content and showing the final report
|
||||
wg.Wait()
|
||||
@ -146,7 +146,7 @@ eventLoop:
|
||||
fmt.Fprint(output, logBuffer.String())
|
||||
}
|
||||
|
||||
if err := common.CatalogerFinishedHandler(e); err != nil {
|
||||
if err := common.CatalogerPresenterReady(e); err != nil {
|
||||
log.Errorf("unable to show %s event: %+v", e.Type, err)
|
||||
}
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ eventLoop:
|
||||
}
|
||||
|
||||
// ignore all events except for the final event
|
||||
if e.Type == syftEvent.CatalogerFinished {
|
||||
err := common.CatalogerFinishedHandler(e)
|
||||
if e.Type == syftEvent.PresenterReady {
|
||||
err := common.CatalogerPresenterReady(e)
|
||||
if err != nil {
|
||||
log.Errorf("unable to show catalog image finished event: %+v", err)
|
||||
}
|
||||
|
||||
@ -268,8 +268,8 @@ func ReadImageHandler(ctx context.Context, fr *frame.Frame, event partybus.Event
|
||||
return nil
|
||||
}
|
||||
|
||||
// CatalogerStartedHandler periodically writes catalog statistics to a single line.
|
||||
func CatalogerStartedHandler(ctx context.Context, fr *frame.Frame, event partybus.Event, wg *sync.WaitGroup) error {
|
||||
// PackageCatalogerStartedHandler periodically writes catalog statistics to a single line.
|
||||
func PackageCatalogerStartedHandler(ctx context.Context, fr *frame.Frame, event partybus.Event, wg *sync.WaitGroup) error {
|
||||
monitor, err := syftEventParsers.ParseCatalogerStarted(event)
|
||||
if err != nil {
|
||||
return fmt.Errorf("bad %s event: %w", event.Type, err)
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
"github.com/wagoodman/jotframe/pkg/frame"
|
||||
)
|
||||
|
||||
// Handler is an aggregated event handler for the set of supported events (PullDockerImage, ReadImage, FetchImage, CatalogerStarted)
|
||||
// Handler is an aggregated event handler for the set of supported events (PullDockerImage, ReadImage, FetchImage, PackageCatalogerStarted)
|
||||
type Handler struct {
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ func NewHandler() *Handler {
|
||||
// RespondsTo indicates if the handler is capable of handling the given event.
|
||||
func (r *Handler) RespondsTo(event partybus.Event) bool {
|
||||
switch event.Type {
|
||||
case stereoscopeEvent.PullDockerImage, stereoscopeEvent.ReadImage, stereoscopeEvent.FetchImage, syftEvent.CatalogerStarted, syftEvent.ImportStarted:
|
||||
case stereoscopeEvent.PullDockerImage, stereoscopeEvent.ReadImage, stereoscopeEvent.FetchImage, syftEvent.PackageCatalogerStarted, syftEvent.ImportStarted:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
@ -46,8 +46,8 @@ func (r *Handler) Handle(ctx context.Context, fr *frame.Frame, event partybus.Ev
|
||||
case stereoscopeEvent.FetchImage:
|
||||
return FetchImageHandler(ctx, fr, event, wg)
|
||||
|
||||
case syftEvent.CatalogerStarted:
|
||||
return CatalogerStartedHandler(ctx, fr, event, wg)
|
||||
case syftEvent.PackageCatalogerStarted:
|
||||
return PackageCatalogerStartedHandler(ctx, fr, event, wg)
|
||||
|
||||
case syftEvent.ImportStarted:
|
||||
return ImportStartedHandler(ctx, fr, event, wg)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user