add update check to entrypoint (#67)

This commit is contained in:
Alex Goodman 2020-07-24 14:24:16 -04:00 committed by GitHub
parent 695cc0f640
commit fdbcc665a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ import (
"github.com/anchore/grype/grype/presenter"
"github.com/anchore/grype/internal"
"github.com/anchore/grype/internal/format"
"github.com/anchore/grype/internal/version"
"github.com/anchore/syft/syft/scope"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -78,6 +79,18 @@ func init() {
}
func runDefaultCmd(_ *cobra.Command, args []string) error {
if appConfig.CheckForAppUpdate {
isAvailable, newVersion, err := version.IsUpdateAvailable()
if err != nil {
log.Errorf(err.Error())
}
if isAvailable {
log.Infof("New version of %s is available: %s", internal.ApplicationName, newVersion)
} else {
log.Debugf("No new %s update available", internal.ApplicationName)
}
}
userImageStr := args[0]
provider, err := grype.LoadVulnerabilityDb(appConfig.Db.ToCuratorConfig(), appConfig.Db.AutoUpdate)