Skip to content
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

feat!: add clean subcommand #6993

Merged
merged 13 commits into from
Jun 25, 2024
Merged

Conversation

knqyf263
Copy link
Collaborator

Description

Delete cache management flags and add trivy clean.

Clear all caches

Before

$ trivy image --reset

After

$ trivy clean --all

Clear scan cache

Before

$ trivy image --clear-cache

After

$ trivy clean --scan-cache

Clear checks bundle

Before

$ trivy config --reset-checks-bundle

After

$ trivy clean --checks-bundle

Clear vulnerability database

Before

N/A (trivy image --reset removes all)

After

$ trivy clean --vuln-db

Clear Java database

Before

N/A (trivy image --reset removes all)

After

$ trivy clean --java-db

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).

Signed-off-by: knqyf263 <knqyf263@gmail.com>
@knqyf263 knqyf263 added the kind/breaking Categorizes issue or PR as related to breaking compatibility. label Jun 21, 2024
@knqyf263 knqyf263 marked this pull request as ready for review June 21, 2024 18:31
@knqyf263 knqyf263 requested a review from a team June 21, 2024 18:31
@knqyf263 knqyf263 self-assigned this Jun 21, 2024
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.

@knqyf263 i found that we show 2 same errors:

➜  ./trivy -d image --reset alpine
2024-06-24T11:18:41+06:00       ERROR   "--reset" was removed. Use "trivy clean --all" instead.
2024-06-24T11:18:41+06:00       FATAL   Fatal error     flag error: db flag error: unable to parse flag: "--reset" was removed

pkg/commands/clean/run.go Show resolved Hide resolved
pkg/commands/clean/run.go Outdated Show resolved Hide resolved
pkg/flag/db_flags.go Show resolved Hide resolved
pkg/flag/clean_flags.go Outdated Show resolved Hide resolved
docs/docs/configuration/cache.md Show resolved Hide resolved
docs/docs/configuration/cache.md Outdated Show resolved Hide resolved
docs/docs/configuration/db.md Outdated Show resolved Hide resolved
docs/tutorials/integrations/gitlab-ci.md Show resolved Hide resolved
knqyf263 and others added 2 commits June 24, 2024 10:30
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
@knqyf263
Copy link
Collaborator Author

2024-06-24T11:18:41+06:00 ERROR "--reset" was removed. Use "trivy clean --all" instead.
2024-06-24T11:18:41+06:00 FATAL Fatal error flag error: db flag error: unable to parse flag: "--reset" was removed

I returned Use "trivy clean --all" instead as an error, but it appears at the end of the log message and is therefore difficult to find as below.

2024-06-24T11:18:41+06:00 FATAL Fatal error flag error: db flag error: unable to parse flag: "--reset" was removed.
use "trivy clean --all" instead.

I eventually separated the error message. In short, it's intended.

If you don't like "--reset" was removed. is displayed twice, I can change the error message.

Signed-off-by: knqyf263 <knqyf263@gmail.com>
@DmitriyLewen
Copy link
Contributor

I eventually separated the error message. In short, it's intended.

Got it 😄
Then no problem 👍

knqyf263 and others added 5 commits June 24, 2024 11:00
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
`trivy image --clear-cache` now returns an error "Require at least 1 argument", then it doesn't show "Use 'trivy clean' instead".

Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
@knqyf263
Copy link
Collaborator Author

@DmitriyLewen I change the message slightly.
5a989d4

@knqyf263
Copy link
Collaborator Author

@simar7 @nikpivkin According to the discussion in #6992, I didn't add --terraform-module flag. If you want to move the cache under the Trivy cache directory and let Trivy delete the cache, please feel free to open a new PR. I don't think it's a blocker of this PR.

pkg/commands/app.go Outdated Show resolved Hide resolved
pkg/flag/db_flags.go Outdated Show resolved Hide resolved
Signed-off-by: knqyf263 <knqyf263@gmail.com>
Signed-off-by: knqyf263 <knqyf263@gmail.com>
@DmitriyLewen
Copy link
Contributor

@knqyf263
I understand that didn't write about comments for --reset-checks-bundle flag.
Added in 8995644

@knqyf263
Copy link
Collaborator Author

@DmitriyLewen Thanks! It's my bad.

@knqyf263
Copy link
Collaborator Author

@chen-keinan @simar7 @nikpivkin Since it's a breaking change, I'd wait for you guys.

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!

@knqyf263 knqyf263 enabled auto-merge June 25, 2024 08:47
@knqyf263 knqyf263 added this pull request to the merge queue Jun 25, 2024
Merged via the queue into aquasecurity:main with commit 8d0ae1f Jun 25, 2024
17 checks passed
@knqyf263 knqyf263 deleted the feat/add_clean branch June 25, 2024 09:25
@knqyf263
Copy link
Collaborator Author

Announced #7010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/breaking Categorizes issue or PR as related to breaking compatibility.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce trivy clean command and remove cache-clearing flags
5 participants