From d3764c869419d7f8a6bd5c95720f91aa9bbd8ca2 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 18 Aug 2023 13:39:24 -0400 Subject: [PATCH] fill out new version notice Signed-off-by: Alex Goodman --- .../ui/__snapshots__/post_ui_event_writer_test.snap | 7 +------ cmd/syft/internal/ui/post_ui_event_writer.go | 5 ++++- cmd/syft/internal/ui/post_ui_event_writer_test.go | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap b/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap index bf473e331d4..64cafcab3d2 100755 --- a/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap +++ b/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap @@ -27,12 +27,7 @@ report 1!!> - - - - - +A newer version of syft is available for download: v0.33.0 (installed version is [not provided]) --- diff --git a/cmd/syft/internal/ui/post_ui_event_writer.go b/cmd/syft/internal/ui/post_ui_event_writer.go index e3772981b06..22287d8ffdd 100644 --- a/cmd/syft/internal/ui/post_ui_event_writer.go +++ b/cmd/syft/internal/ui/post_ui_event_writer.go @@ -10,6 +10,7 @@ import ( "github.com/wagoodman/go-partybus" "github.com/anchore/syft/internal/log" + "github.com/anchore/syft/internal/version" "github.com/anchore/syft/syft/event" "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) 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 } + 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 { // don't let this be fatal log.WithFields("error", err).Warn("failed to write app update notification") diff --git a/cmd/syft/internal/ui/post_ui_event_writer_test.go b/cmd/syft/internal/ui/post_ui_event_writer_test.go index a5bdd5792eb..83af4d2c528 100644 --- a/cmd/syft/internal/ui/post_ui_event_writer_test.go +++ b/cmd/syft/internal/ui/post_ui_event_writer_test.go @@ -35,7 +35,7 @@ func Test_postUIEventWriter_write(t *testing.T) { }, { Type: event.CLIAppUpdateAvailable, - Value: "\n\n\n\n", + Value: "v0.33.0", }, { Type: event.CLINotification,