Skip to content

Commit 52162e0

Browse files
committed
fix: use accessor functions for LatestVersion, Warnings and Announcements
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
1 parent 4ed1a05 commit 52162e0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/notification/notice.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ func (v *VersionChecker) PrintNotices(output io.Writer) {
122122

123123
var notices []string
124124

125-
notices = append(notices, v.latestVersion.Warnings...)
126-
for _, announcement := range v.latestVersion.Announcements {
125+
notices = append(notices, v.Warnings()...)
126+
for _, announcement := range v.Announcements() {
127127
if time.Now().Before(announcement.ToDate) && time.Now().After(announcement.FromDate) {
128128
notices = append(notices, announcement.Announcement)
129129
}
130130
}
131131

132-
if v.currentVersion != v.latestVersion.Trivy.LatestVersion {
132+
if v.currentVersion != v.LatestVersion() {
133133
notices = append(notices, fmt.Sprintf("Version %s of Trivy is now available, current version is %s", v.latestVersion.Trivy.LatestVersion, v.currentVersion))
134134
}
135135

@@ -158,6 +158,13 @@ func (v *VersionChecker) Announcements() []announcement {
158158
return nil
159159
}
160160

161+
func (v *VersionChecker) Warnings() []string {
162+
if v.responseReceived {
163+
return v.latestVersion.Warnings
164+
}
165+
return nil
166+
}
167+
161168
// getFlags returns the just the flag portion without the values
162169
func getFlags(args []string) []string {
163170
var flags []string

0 commit comments

Comments
 (0)