Skip to content

feat(cli): Add available version checking #8553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 28, 2025
Merged

Conversation

owenrumney
Copy link
Member

@owenrumney owenrumney commented Mar 14, 2025

Description

Adds a background check to https://api.trivy.cloud/check to see if there is new version or any relevant notices available.

The check will be suppressed if the user uses the --no-notices or --quiet envvars or flags. The docs have been updated with the new notices flag

Example output

image

Although the image shows dummy versions, the api has been updated to reflect the correct information and has no announcements at this time... just the latest version (0.60.0)

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@owenrumney owenrumney self-assigned this Mar 14, 2025
@owenrumney owenrumney marked this pull request as ready for review March 14, 2025 11:44
@owenrumney owenrumney requested a review from knqyf263 as a code owner March 14, 2025 11:44
@knqyf263 knqyf263 requested a review from DmitriyLewen March 17, 2025 02:44
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@owenrumney left comments.
Take a look, please.

Also I think update is not a very good name for this logic.
Maybe something like notification?

UPD:
and I would also think about how we can inform users about the ---no-notises flag

@owenrumney owenrumney marked this pull request as draft March 17, 2025 11:54
@owenrumney owenrumney force-pushed the feat/add-update-checking branch 2 times, most recently from 4a269dd to be383c3 Compare March 17, 2025 13:46
@owenrumney owenrumney marked this pull request as ready for review April 14, 2025 11:26
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I left small comments.

@owenrumney owenrumney force-pushed the feat/add-update-checking branch 2 times, most recently from 9c714fb to f21196a Compare April 16, 2025 18:23
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to create a new page for privacy. @itaysk should know some examples from other OSS projects.

if !v.skipUpdateCheck && !v.quiet {
v.responseReceived = true
}
v.done = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually only used in the test at the moment to know when the process is completed

@owenrumney owenrumney force-pushed the feat/add-update-checking branch from 67acb5e to 5152ff5 Compare April 17, 2025 18:41
@itaysk
Copy link
Contributor

itaysk commented Apr 18, 2025

I think we also need to create a new page for privacy. @itaysk should know some examples from other OSS projects.

yes I already have a draft for a dedicated doc, wasn't sure if we want it in the same PR or not. actually I'll try to add it to this one. (ps i don't think the doc should include referenences from other products)

Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I'm fine with updating the documentation either in this PR or in a separate one, as long as it gets updated before the next release—so I'll approve this PR.

Copy link
Contributor

@nikpivkin nikpivkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a small comment

@itaysk
Copy link
Contributor

itaysk commented Apr 19, 2025

I may have some more comment after writing the doc, so don't merge it yet please

@owenrumney owenrumney requested a review from afdesk as a code owner April 22, 2025 08:02
@owenrumney owenrumney force-pushed the feat/add-update-checking branch from 929742f to bd1feb4 Compare May 5, 2025 18:58
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
left small comments

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
left small comments

- Update the preRun and postRun to check and print the latest version
  - Run in a go routine so as not to interfere or slow the normal flow
  - Provide new `--no-notices` flag to prevent notice checking, same if
    they `-q/--quiet` flag is used
- Add tests for the identifier and the check logic
- change no-notices flag to `skip-version-check` and add
  `disable-metrics` flag
- create VersionChecker type and add to runner
- if the flag conditions are met, create a new checker and trigger check
- handle logic of flags for disabling metrics
- update the tests
owenrumney and others added 12 commits May 12, 2025 06:15
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
Remove the -x prefix as per RFC6648. While headers are case-insensitve,  making custom headers title case as per general
convention.

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
- update the URL to check.trivy.cloud/updates
- change the flag to disable-telemetry
- update tests

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
offline scan isn't to be included at the moment, this will be tackled
as a different piece of work.

tidied up the notices option to be more consistent with the flag it
reflects

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
…ents

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
- add support for different formats of date time from the service

Signed-off-by: Owen Rumney <owen.rumney@aquasec.com>
@owenrumney owenrumney force-pushed the feat/add-update-checking branch from 52162e0 to c6f5d66 Compare May 12, 2025 05:48
Copy link
Member

@simar7 simar7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, left a small comment.

Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@knqyf263
Copy link
Collaborator

@itaysk Can we merge this PR?

@knqyf263 knqyf263 added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit 5a0bf9e May 28, 2025
21 checks passed
@knqyf263 knqyf263 deleted the feat/add-update-checking branch May 28, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(cli): Capture some basic information during the update check feat(cli): Add new version checking
6 participants