Skip to content

Commit

Permalink
Merge pull request #512 from openSUSE/stats-first-arg
Browse files Browse the repository at this point in the history
Treat first `crictl stats` argument as filter ID
  • Loading branch information
k8s-ci-robot authored Aug 30, 2019
2 parents 303e219 + 5cc722b commit df1252c
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 df1252c

Please sign in to comment.