mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
Add check for app update (#88)
* add check for app update; fix ETUI error handling * validate user args
This commit is contained in:
@@ -3,6 +3,7 @@ package event
|
||||
import "github.com/wagoodman/go-partybus"
|
||||
|
||||
const (
|
||||
CatalogerStarted partybus.EventType = "cataloger-started-event"
|
||||
CatalogerFinished partybus.EventType = "cataloger-finished-event"
|
||||
AppUpdateAvailable partybus.EventType = "app-update-available"
|
||||
CatalogerStarted partybus.EventType = "cataloger-started-event"
|
||||
CatalogerFinished partybus.EventType = "cataloger-finished-event"
|
||||
)
|
||||
|
||||
@@ -59,3 +59,16 @@ func ParseCatalogerFinished(e partybus.Event) (presenter.Presenter, error) {
|
||||
|
||||
return pres, nil
|
||||
}
|
||||
|
||||
func ParseAppUpdateAvailable(e partybus.Event) (string, error) {
|
||||
if err := checkEventType(e.Type, event.AppUpdateAvailable); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
newVersion, ok := e.Value.(string)
|
||||
if !ok {
|
||||
return "", newPayloadErr(e.Type, "Value", e.Value)
|
||||
}
|
||||
|
||||
return newVersion, nil
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,8 +1,6 @@
|
||||
package imgbom
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anchore/imgbom/imgbom/cataloger"
|
||||
"github.com/anchore/imgbom/imgbom/distro"
|
||||
"github.com/anchore/imgbom/imgbom/logger"
|
||||
@@ -17,14 +15,14 @@ func Catalog(userInput string, scoptOpt scope.Option) (*pkg.Catalog, *scope.Scop
|
||||
s, cleanup, err := scope.NewScope(userInput, scoptOpt)
|
||||
defer cleanup()
|
||||
if err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("failed to create scope: %w", err)
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
d := IdentifyDistro(s)
|
||||
|
||||
catalog, err := CatalogFromScope(s)
|
||||
if err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("failed to produce catalog: %w", err)
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return catalog, &s, &d, nil
|
||||
|
||||
Reference in New Issue
Block a user