-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin): specify plugin version (#6683)
Signed-off-by: knqyf263 <[email protected]> Co-authored-by: DmitriyLewen <[email protected]>
- Loading branch information
1 parent
a944f0e
commit d6dc567
Showing
26 changed files
with
368 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,16 @@ The following rules will apply in deciding which platform to select: | |
After determining platform, Trivy will download the execution file from `uri` and store it in the plugin cache. | ||
When the plugin is called via Trivy CLI, `bin` command will be executed. | ||
|
||
#### Tagging plugin repositories | ||
If you are hosting your plugin in a Git repository, it is strongly recommended to tag your releases with a version number. | ||
By tagging your releases, Trivy can install specific versions of your plugin. | ||
|
||
```bash | ||
$ trivy plugin install [email protected] | ||
``` | ||
|
||
When tagging versions, you must follow [the Semantic Versioning][semver] and prefix the tag with `v`, like `v1.2.3`. | ||
|
||
#### Plugin arguments/flags | ||
The plugin is responsible for handling flags and arguments. | ||
Any arguments are passed to the plugin from the `trivy` command. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ $ trivy plugin install referrer | |
|
||
This command will download the plugin and install it in the plugin cache. | ||
|
||
|
||
|
||
Trivy adheres to the XDG specification, so the location depends on whether XDG_DATA_HOME is set. | ||
Trivy will now search XDG_DATA_HOME for the location of the Trivy plugins cache. | ||
The preference order is as follows: | ||
|
@@ -56,6 +58,15 @@ $ trivy plugin install github.com/aquasecurity/trivy-plugin-kubectl | |
$ trivy plugin install myplugin.tar.gz | ||
``` | ||
|
||
If the plugin's Git repository is [properly tagged](./developer-guide.md#tagging-plugin-repositories), you can specify the version to install like this: | ||
|
||
```bash | ||
$ trivy plugin install [email protected] | ||
``` | ||
|
||
!!! note | ||
The leading `v` in the version is required. Also, the version must follow the [Semantic Versioning](https://semver.org/). | ||
|
||
Under the hood Trivy leverages [go-getter][go-getter] to download plugins. | ||
This means the following protocols are supported for downloading plugins: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,19 @@ Install a plugin | |
trivy plugin install NAME | URL | FILE_PATH | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Install a plugin from the plugin index | ||
$ trivy plugin install referrer | ||
# Specify the version of the plugin to install | ||
$ trivy plugin install [email protected] | ||
# Install a plugin from a URL | ||
$ trivy plugin install github.com/aquasecurity/trivy-plugin-referrer | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -724,9 +724,17 @@ func NewPluginCommand() *cobra.Command { | |
} | ||
cmd.AddCommand( | ||
&cobra.Command{ | ||
Use: "install NAME | URL | FILE_PATH", | ||
Aliases: []string{"i"}, | ||
Short: "Install a plugin", | ||
Use: "install NAME | URL | FILE_PATH", | ||
Aliases: []string{"i"}, | ||
Short: "Install a plugin", | ||
Example: ` # Install a plugin from the plugin index | ||
$ trivy plugin install referrer | ||
# Specify the version of the plugin to install | ||
$ trivy plugin install [email protected] | ||
# Install a plugin from a URL | ||
$ trivy plugin install github.com/aquasecurity/trivy-plugin-referrer`, | ||
SilenceErrors: true, | ||
SilenceUsage: true, | ||
DisableFlagsInUseLine: true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.