mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 22:46:36 +01:00
pull in temp dir generator from stereoscope
Signed-off-by: Alex Goodman <wagoodman@gmail.com>
This commit is contained in:
+7
-4
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/anchore/syft/syft"
|
||||
"github.com/anchore/syft/internal/log"
|
||||
"github.com/anchore/syft/internal/ui"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
@@ -50,10 +51,12 @@ func eventLoop(workerErrs <-chan error, signals <-chan os.Signal, subscription *
|
||||
}
|
||||
}
|
||||
case <-signals:
|
||||
if err := subscription.Unsubscribe(); err != nil {
|
||||
log.Warnf("unable to unsubscribe from the event bus: %+v", err)
|
||||
events = nil
|
||||
}
|
||||
// ignore further results from any event source and exit ASAP, but ensure that all cache is cleaned up.
|
||||
// we ignore further errors since cleaning up the tmp directories will affect running catalogers that are
|
||||
// reading/writing from/to their nested temp dirs. This is acceptable since we are bailing without result.
|
||||
events = nil
|
||||
workerErrs = nil
|
||||
syft.Cleanup()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-5
@@ -6,10 +6,6 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/anchore/syft/syft/presenter/packages"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
"github.com/anchore/syft/internal/anchore"
|
||||
"github.com/anchore/syft/internal/bus"
|
||||
@@ -19,10 +15,12 @@ import (
|
||||
"github.com/anchore/syft/syft/distro"
|
||||
"github.com/anchore/syft/syft/event"
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
"github.com/anchore/syft/syft/presenter/packages"
|
||||
"github.com/anchore/syft/syft/source"
|
||||
"github.com/pkg/profile"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/wagoodman/go-partybus"
|
||||
)
|
||||
|
||||
@@ -206,7 +204,11 @@ func packagesExecWorker(userInput string) <-chan error {
|
||||
errs <- fmt.Errorf("failed to determine image source: %+v", err)
|
||||
return
|
||||
}
|
||||
defer cleanup()
|
||||
defer func() {
|
||||
if err := cleanup(); err != nil {
|
||||
log.Warnf("unable to cleanup source temp dir: %+v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
catalog, d, err := syft.CatalogPackages(src, appConfig.Package.Cataloger.ScopeOpt)
|
||||
if err != nil {
|
||||
|
||||
+6
-2
@@ -5,8 +5,8 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
|
||||
"github.com/anchore/syft/internal/bus"
|
||||
"github.com/anchore/syft/internal/log"
|
||||
"github.com/anchore/syft/internal/presenter/poweruser"
|
||||
"github.com/anchore/syft/internal/ui"
|
||||
"github.com/anchore/syft/syft/event"
|
||||
@@ -89,7 +89,11 @@ func powerUserExecWorker(userInput string) <-chan error {
|
||||
errs <- err
|
||||
return
|
||||
}
|
||||
defer cleanup()
|
||||
defer func() {
|
||||
if err := cleanup(); err != nil {
|
||||
log.Warnf("unable to cleanup source temp dir: %+v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
if src.Metadata.Scheme != source.ImageScheme {
|
||||
errs <- fmt.Errorf("the power-user subcommand only allows for 'image' schemes, given %q", src.Metadata.Scheme)
|
||||
|
||||
Reference in New Issue
Block a user