Skip to content

Commit

Permalink
Treat first crictl stats argument as filter ID
Browse files Browse the repository at this point in the history
The first argument supplied to `crictl stats` can be taken as the filter
ID of the container, whereas `--id` gets precedence.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
  • Loading branch information
saschagrunert committed Aug 30, 2019
1 parent 303e219 commit 5cc722b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/crictl/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var statsCommand = cli.Command{
Usage: "List container(s) resource usage statistics",
SkipArgReorder: true,
UseShortOptionHandling: true,
ArgsUsage: "[ID]",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "all, a",
Expand Down Expand Up @@ -90,9 +91,14 @@ var statsCommand = cli.Command{
}
defer closeConnection(context, runtimeConn)

id := context.String("id")
if id == "" && context.Args() != nil {
id = context.Args()[0]
}

opts := statsOptions{
all: context.Bool("all"),
id: context.String("id"),
id: id,
podID: context.String("pod"),
sample: time.Duration(context.Int("seconds")) * time.Second,
output: context.String("output"),
Expand Down

0 comments on commit 5cc722b

Please sign in to comment.