Add check for app update (#88)

* add check for app update; fix ETUI error handling

* validate user args
This commit is contained in:
Alex Goodman
2020-07-21 12:02:03 -04:00
committed by GitHub
parent 380cd39514
commit 7ebb9f4e0b
19 changed files with 438 additions and 66 deletions
+3 -2
View File
@@ -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"
)
+13
View File
@@ -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
View File
@@ -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