mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
fill out new version notice (#2042)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
4762ba0943
commit
cb0214ec1d
@ -27,12 +27,7 @@ report 1!!>
|
|||||||
|
|
||||||
<notification 2>
|
<notification 2>
|
||||||
<notification 3>
|
<notification 3>
|
||||||
|
A newer version of syft is available for download: v0.33.0 (installed version is [not provided])
|
||||||
|
|
||||||
<my app can be updated!!
|
|
||||||
...to this version>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/wagoodman/go-partybus"
|
"github.com/wagoodman/go-partybus"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/log"
|
"github.com/anchore/syft/internal/log"
|
||||||
|
"github.com/anchore/syft/internal/version"
|
||||||
"github.com/anchore/syft/syft/event"
|
"github.com/anchore/syft/syft/event"
|
||||||
"github.com/anchore/syft/syft/event/parsers"
|
"github.com/anchore/syft/syft/event/parsers"
|
||||||
)
|
)
|
||||||
@ -118,12 +119,14 @@ func writeAppUpdate(writer io.Writer, events ...partybus.Event) error {
|
|||||||
style := lipgloss.NewStyle().Foreground(lipgloss.Color("13")).Italic(true)
|
style := lipgloss.NewStyle().Foreground(lipgloss.Color("13")).Italic(true)
|
||||||
|
|
||||||
for _, e := range events {
|
for _, e := range events {
|
||||||
notice, err := parsers.ParseCLIAppUpdateAvailable(e)
|
newVersion, err := parsers.ParseCLIAppUpdateAvailable(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields("error", err).Warn("failed to parse app update notification")
|
log.WithFields("error", err).Warn("failed to parse app update notification")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notice := fmt.Sprintf("A newer version of syft is available for download: %s (installed version is %s)", newVersion, version.FromBuild().Version)
|
||||||
|
|
||||||
if _, err := fmt.Fprintln(writer, style.Render(notice)); err != nil {
|
if _, err := fmt.Fprintln(writer, style.Render(notice)); err != nil {
|
||||||
// don't let this be fatal
|
// don't let this be fatal
|
||||||
log.WithFields("error", err).Warn("failed to write app update notification")
|
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,
|
Type: event.CLIAppUpdateAvailable,
|
||||||
Value: "\n\n<my app can be updated!!\n...to this version>\n\n",
|
Value: "v0.33.0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: event.CLINotification,
|
Type: event.CLINotification,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user