mirror of
https://github.com/anchore/grype
synced 2024-11-10 14:44:12 +00:00
fill out new version notice (#1445)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
7ff37a0310
commit
3c50c885d3
3 changed files with 11 additions and 9 deletions
|
@ -27,12 +27,7 @@ report 1!!>
|
|||
|
||||
<notification 2>
|
||||
<notification 3>
|
||||
|
||||
|
||||
<my app can be updated!!
|
||||
...to this version>
|
||||
|
||||
|
||||
A newer version of grype is available for download: v0.33.0 (installed version is [not provided])
|
||||
|
||||
---
|
||||
|
||||
|
@ -43,4 +38,4 @@ report 1!!>
|
|||
|
||||
[Test_postUIEventWriter_write/quiet_only_shows_report/stderr - 1]
|
||||
|
||||
---
|
||||
---
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/anchore/grype/grype/event"
|
||||
"github.com/anchore/grype/grype/event/parsers"
|
||||
"github.com/anchore/grype/internal/log"
|
||||
"github.com/anchore/grype/internal/version"
|
||||
)
|
||||
|
||||
type postUIEventWriter struct {
|
||||
|
@ -118,12 +119,18 @@ func writeAppUpdate(writer io.Writer, events ...partybus.Event) error {
|
|||
style := lipgloss.NewStyle().Foreground(lipgloss.Color("13")).Italic(true)
|
||||
|
||||
for _, e := range events {
|
||||
notice, err := parsers.ParseCLIAppUpdateAvailable(e)
|
||||
newVersion, err := parsers.ParseCLIAppUpdateAvailable(e)
|
||||
if err != nil {
|
||||
log.WithFields("error", err).Warn("failed to parse app update notification")
|
||||
continue
|
||||
}
|
||||
|
||||
if newVersion == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
notice := fmt.Sprintf("A newer version of grype is available for download: %s (installed version is %s)", newVersion, version.FromBuild().Version)
|
||||
|
||||
if _, err := fmt.Fprintln(writer, style.Render(notice)); err != nil {
|
||||
// don't let this be fatal
|
||||
log.WithFields("error", err).Warn("failed to write app update notification")
|
||||
|
|
|
@ -35,7 +35,7 @@ func Test_postUIEventWriter_write(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Type: event.CLIAppUpdateAvailable,
|
||||
Value: "\n\n<my app can be updated!!\n...to this version>\n\n",
|
||||
Value: "v0.33.0",
|
||||
},
|
||||
{
|
||||
Type: event.CLINotification,
|
||||
|
|
Loading…
Reference in a new issue