mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 06:26:30 +01:00
* add bubbletea UI Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * swap pipeline to go 1.20.x and add attest guard for cosign binary Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update note in developing.md about the required golang version Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix merge conflict for windows path handling Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * temp test for attest handler Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add addtional test iterations for background reader Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package monitor
|
|
|
|
import (
|
|
"github.com/wagoodman/go-partybus"
|
|
"github.com/wagoodman/go-progress"
|
|
|
|
"github.com/anchore/syft/internal/bus"
|
|
"github.com/anchore/syft/syft/event"
|
|
)
|
|
|
|
// TODO: this should be refactored to support read-only/write-only access using idioms of the progress lib
|
|
|
|
type CatalogerTask struct {
|
|
prog *progress.Manual
|
|
// Title
|
|
Title string
|
|
// TitleOnCompletion a string to use as title when completed
|
|
TitleOnCompletion string
|
|
// SubStatus indicates this progress should be rendered as a sub-item
|
|
SubStatus bool
|
|
// RemoveOnCompletion indicates this progress line will be removed when completed
|
|
RemoveOnCompletion bool
|
|
// value is the value to display -- not public as SetValue needs to be called to initialize this progress
|
|
value string
|
|
}
|
|
|
|
func (e *CatalogerTask) init() {
|
|
e.prog = progress.NewManual(-1)
|
|
|
|
bus.Publish(partybus.Event{
|
|
Type: event.CatalogerTaskStarted,
|
|
Source: e,
|
|
})
|
|
}
|
|
|
|
func (e *CatalogerTask) SetCompleted() {
|
|
if e.prog != nil {
|
|
e.prog.SetCompleted()
|
|
}
|
|
}
|
|
|
|
func (e *CatalogerTask) SetValue(value string) {
|
|
if e.prog == nil {
|
|
e.init()
|
|
}
|
|
e.value = value
|
|
}
|
|
|
|
func (e *CatalogerTask) GetValue() string {
|
|
return e.value
|
|
}
|
|
|
|
func (e *CatalogerTask) GetMonitor() *progress.Manual {
|
|
return e.prog
|
|
}
|