mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
use new atomic stager struct
Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
parent
abfd244dc5
commit
d54d20a563
@ -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() {
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user