use new atomic stager struct

Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
Will Murphy 2023-09-08 10:13:52 -04:00
parent abfd244dc5
commit d54d20a563
11 changed files with 25 additions and 25 deletions

View File

@ -65,7 +65,7 @@ func (m *Handler) handleAttestationStarted(e partybus.Event) []tea.Model {
return nil
}
stage := progress.NewStage("")
stage := progress.NewAtomicStage("")
tsk := m.newTaskProgress(
taskprogress.Title{
@ -108,7 +108,7 @@ func newLogFrame(reader *backgroundLineReader, prog progress.Progressable, borde
}
}
func newBackgroundLineReader(wg *sync.WaitGroup, reader io.Reader, stage *progress.Stage) *backgroundLineReader {
func newBackgroundLineReader(wg *sync.WaitGroup, reader io.Reader, stage *progress.AtomicStage) *backgroundLineReader {
r := &backgroundLineReader{
limit: 7,
lock: &sync.RWMutex{},
@ -131,7 +131,7 @@ func newBackgroundLineReader(wg *sync.WaitGroup, reader io.Reader, stage *progre
return r
}
func (l *backgroundLineReader) read(reader io.Reader, stage *progress.Stage) {
func (l *backgroundLineReader) read(reader io.Reader, stage *progress.AtomicStage) {
s := bufio.NewScanner(reader)
for s.Scan() {

View File

@ -33,7 +33,7 @@ func TestHandler_handleFetchImage(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{
@ -56,7 +56,7 @@ func TestHandler_handleFetchImage(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{

View File

@ -33,7 +33,7 @@ func TestHandler_handleFileDigestsCatalogerStarted(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{
@ -55,7 +55,7 @@ func TestHandler_handleFileDigestsCatalogerStarted(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{

View File

@ -33,7 +33,7 @@ func TestHandler_handleFileIndexingStarted(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{
@ -56,7 +56,7 @@ func TestHandler_handleFileIndexingStarted(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{

View File

@ -33,7 +33,7 @@ func TestHandler_handleFileMetadataCatalogerStarted(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{
@ -55,7 +55,7 @@ func TestHandler_handleFileMetadataCatalogerStarted(t *testing.T) {
progress.Stager
}{
Progressable: prog,
Stager: progress.NewStage("current"),
Stager: progress.NewAtomicStage("current"),
}
return partybus.Event{

View File

@ -25,7 +25,7 @@ func TestHandler_handleSecretsCatalogerStarted(t *testing.T) {
{
name: "cataloging in progress",
eventFn: func(t *testing.T) partybus.Event {
stage := progress.NewStage("current")
stage := progress.NewAtomicStage("current")
secretsDiscovered := progress.NewManual(-1)
secretsDiscovered.Set(64)
prog := progress.NewManual(72)
@ -45,7 +45,7 @@ func TestHandler_handleSecretsCatalogerStarted(t *testing.T) {
{
name: "cataloging complete",
eventFn: func(t *testing.T) partybus.Event {
stage := progress.NewStage("current")
stage := progress.NewAtomicStage("current")
secretsDiscovered := progress.NewManual(-1)
secretsDiscovered.Set(64)
prog := progress.NewManual(72)

View File

@ -91,8 +91,8 @@ func (i *Cataloger) catalogLocation(resolver file.Resolver, location file.Locati
return digests, nil
}
func digestsCatalogingProgress(locations int64) (*progress.Stage, *progress.Manual) {
stage := progress.NewStage("")
func digestsCatalogingProgress(locations int64) (*progress.AtomicStage, *progress.Manual) {
stage := progress.NewAtomicStage("")
prog := progress.NewManual(locations)
bus.Publish(partybus.Event{

View File

@ -52,8 +52,8 @@ func (i *Cataloger) Catalog(resolver file.Resolver, coordinates ...file.Coordina
return results, nil
}
func metadataCatalogingProgress(locations int64) (*progress.Stage, *progress.Manual) {
stage := &progress.Stage{}
func metadataCatalogingProgress(locations int64) (*progress.AtomicStage, *progress.Manual) {
stage := progress.NewAtomicStage("")
prog := progress.NewManual(locations)
bus.Publish(partybus.Event{

View File

@ -139,8 +139,8 @@ type Monitor struct {
progress.Progressable
}
func secretsCatalogingProgress(locations int64) (*progress.Stage, *progress.Manual, *progress.Manual) {
stage := progress.NewStage("")
func secretsCatalogingProgress(locations int64) (*progress.AtomicStage, *progress.Manual, *progress.Manual) {
stage := progress.NewAtomicStage("")
secretsDiscovered := &progress.Manual{}
prog := progress.NewManual(locations)

View File

@ -58,7 +58,7 @@ func (r *directoryIndexer) build() (filetree.Reader, filetree.IndexReader, error
return r.tree, r.index, indexAllRoots(r.path, r.indexTree)
}
func indexAllRoots(root string, indexer func(string, *progress.Stage) ([]string, error)) error {
func indexAllRoots(root string, indexer func(string, *progress.AtomicStage) ([]string, error)) error {
// why account for multiple roots? To cover cases when there is a symlink that references above the root path,
// in which case we need to additionally index where the link resolves to. it's for this reason why the filetree
// must be relative to the root of the filesystem (and not just relative to the given path).
@ -95,7 +95,7 @@ loop:
return nil
}
func (r *directoryIndexer) indexTree(root string, stager *progress.Stage) ([]string, error) {
func (r *directoryIndexer) indexTree(root string, stager *progress.AtomicStage) ([]string, error) {
log.WithFields("path", root).Trace("indexing filetree")
var roots []string
@ -172,7 +172,7 @@ func isRealPath(root string) (bool, error) {
return rootParent == realRootParent, nil
}
func (r *directoryIndexer) indexBranch(root string, stager *progress.Stage) ([]string, error) {
func (r *directoryIndexer) indexBranch(root string, stager *progress.AtomicStage) ([]string, error) {
rootRealPath, err := filepath.EvalSymlinks(root)
if err != nil {
return nil, err
@ -464,8 +464,8 @@ func requireFileInfo(_ string, info os.FileInfo, _ error) error {
return nil
}
func indexingProgress(path string) (*progress.Stage, *progress.Manual) {
stage := &progress.Stage{}
func indexingProgress(path string) (*progress.AtomicStage, *progress.Manual) {
stage := progress.NewAtomicStage("")
prog := progress.NewManual(-1)
bus.Publish(partybus.Event{

View File

@ -22,7 +22,7 @@ type indexerMock struct {
additionalRoots map[string][]string
}
func (m *indexerMock) indexer(s string, _ *progress.Stage) ([]string, error) {
func (m *indexerMock) indexer(s string, _ *progress.AtomicStage) ([]string, error) {
m.observedRoots = append(m.observedRoots, s)
return m.additionalRoots[s], nil
}