Skip to content

Commit

Permalink
clairctl: add environment variables for clairctl
Browse files Browse the repository at this point in the history
This makes the import/export commands respect the CLAIR_CONF environment
variable that `clair` proper uses.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Oct 12, 2020
1 parent d2bc2b6 commit 2363778
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 18 deletions.
55 changes: 40 additions & 15 deletions Documentation/reference/clairctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
`clairctl` is a command line tool for working with Clair.
This CLI is capable of generating manifests from most public registries (dockerhub, quay.io, Red Hat Container Catalog) and submitting them for analysis to a running Clair.


```
NAME:
clairctl - A new cli application
clairctl - interact with a clair API
USAGE:
clairctl [global options] command [command options] [arguments...]
Expand All @@ -18,9 +17,11 @@ DESCRIPTION:
A command-line tool for clair v4.
COMMANDS:
manifest
report request vulnerability reports for the named containers
help, h Shows a list of commands or help for one command
manifest print a clair manifest for the named container
report request vulnerability reports for the named containers
export-updaters run updaters and export results
import-updaters import updates
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
-D print debugging logs (default: false)
Expand All @@ -30,19 +31,15 @@ GLOBAL OPTIONS:

```
NAME:
clairctl manifest -
clairctl manifest - print a clair manifest for the named container
USAGE:
clairctl manifest [command options] [arguments...]
clairctl manifest [arguments...]
DESCRIPTION:
print a clair manifest for the provided container
OPTIONS:
--help, -h show help (default: false)
print a clair manifest for the named container
```


```
NAME:
clairctl report - request vulnerability reports for the named containers
Expand All @@ -51,10 +48,38 @@ USAGE:
clairctl report [command options] container...
DESCRIPTION:
Request and print a Clair vulnerability report for the provided container(s).
Request and print a Clair vulnerability report for the named container(s).
OPTIONS:
--host value URL for the clairv4 v1 API. (default: "http://localhost:6060/")
--host value URL for the clairv4 v1 API. (default: "http://localhost:6060/") [$CLAIR_API]
--out value, -o value output format: text, json, xml (default: text)
--help, -h show help (default: false)
```

```
NAME:
clairctl export-updaters - run updaters and export results
USAGE:
clairctl export-updaters [command options] [out]
DESCRIPTION:
Run configured exporters and export to a file.
OPTIONS:
--strict Return non-zero exit when updaters report errors. (default: false)
--config value, -c value clair configuration file (default: "config.yaml") [$CLAIR_CONF]
```

```
NAME:
clairctl import-updaters - import updates
USAGE:
clairctl import-updaters [command options] in
DESCRIPTION:
Import updates from a file.
OPTIONS:
--config value, -c value clair configuration file (default: "config.yaml") [$CLAIR_CONF]
```
1 change: 1 addition & 0 deletions cmd/clairctl/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var ExportCmd = &cli.Command{
Usage: "clair configuration file",
Value: "config.yaml",
TakesFile: true,
EnvVars: []string{"CLAIR_CONF"},
},
},
}
Expand Down
1 change: 1 addition & 0 deletions cmd/clairctl/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var ImportCmd = &cli.Command{
Usage: "clair configuration file",
Value: "config.yaml",
TakesFile: true,
EnvVars: []string{"CLAIR_CONF"},
},
},
}
Expand Down
1 change: 1 addition & 0 deletions cmd/clairctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
app := &cli.App{
Name: "clairctl",
Version: "0.1.0",
Usage: "interact with a clair API",
Description: "A command-line tool for clair v4.",
EnableBashCompletion: true,
Before: func(c *cli.Context) error {
Expand Down
7 changes: 4 additions & 3 deletions cmd/clairctl/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ var ReportCmd = &cli.Command{
ArgsUsage: "container...",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
Usage: "URL for the clairv4 v1 API.",
Value: "http://localhost:6060/",
Name: "host",
Usage: "URL for the clairv4 v1 API.",
Value: "http://localhost:6060/",
EnvVars: []string{"CLAIR_API"},
},
&cli.GenericFlag{
Name: "out",
Expand Down

0 comments on commit 2363778

Please sign in to comment.