2023-07-06 13:00:46 +00:00
|
|
|
package bus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/wagoodman/go-partybus"
|
2023-11-30 16:25:50 +00:00
|
|
|
"github.com/wagoodman/go-progress"
|
2023-07-06 13:00:46 +00:00
|
|
|
|
2023-08-29 19:52:26 +00:00
|
|
|
"github.com/anchore/clio"
|
|
|
|
"github.com/anchore/syft/internal/redact"
|
2023-07-06 13:00:46 +00:00
|
|
|
"github.com/anchore/syft/syft/event"
|
2023-11-30 16:25:50 +00:00
|
|
|
"github.com/anchore/syft/syft/event/monitor"
|
2023-07-06 13:00:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Exit() {
|
2023-08-29 19:52:26 +00:00
|
|
|
Publish(clio.ExitEvent(false))
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExitWithInterrupt() {
|
|
|
|
Publish(clio.ExitEvent(true))
|
2023-07-06 13:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Report(report string) {
|
|
|
|
if len(report) == 0 {
|
|
|
|
return
|
|
|
|
}
|
2023-08-29 19:52:26 +00:00
|
|
|
report = redact.Apply(report)
|
2023-07-06 13:00:46 +00:00
|
|
|
Publish(partybus.Event{
|
|
|
|
Type: event.CLIReport,
|
|
|
|
Value: report,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Notify(message string) {
|
|
|
|
Publish(partybus.Event{
|
|
|
|
Type: event.CLINotification,
|
|
|
|
Value: message,
|
|
|
|
})
|
|
|
|
}
|
2023-11-30 16:25:50 +00:00
|
|
|
|
|
|
|
func StartCatalogerTask(info monitor.GenericTask, size int64, initialStage string) *monitor.CatalogerTaskProgress {
|
|
|
|
t := &monitor.CatalogerTaskProgress{
|
|
|
|
AtomicStage: progress.NewAtomicStage(initialStage),
|
|
|
|
Manual: progress.NewManual(size),
|
|
|
|
}
|
|
|
|
|
|
|
|
Publish(partybus.Event{
|
|
|
|
Type: event.CatalogerTaskStarted,
|
|
|
|
Source: info,
|
|
|
|
Value: progress.StagedProgressable(t),
|
|
|
|
})
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|