From 0edde8fde85e8a6a38fb1e2f870b0a45d2d1955c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 7 Feb 2026 12:58:32 +0100 Subject: [PATCH] cmd/containerd-stress: enable '--version' flag All other binaries have a `-v` and/or `--version` flag, which can be useful to perform a quick check if the binary is "functional". Before this: containerd-stress --version | tail -n1 flag provided but not defined: -version --help, -h Show help After this: containerd-stress --version | tail -n1 containerd-stress github.com/containerd/containerd/v2 v2.2.0-306-g2e46d7659.m containerd-stress --help | tail -n1 --version, -v Print the version Signed-off-by: Sebastiaan van Stijn --- cmd/containerd-stress/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/containerd-stress/main.go b/cmd/containerd-stress/main.go index eded65ca1c..f8d0d0949e 100644 --- a/cmd/containerd-stress/main.go +++ b/cmd/containerd-stress/main.go @@ -33,6 +33,7 @@ import ( "github.com/containerd/containerd/v2/integration/remote" "github.com/containerd/containerd/v2/pkg/namespaces" "github.com/containerd/containerd/v2/plugins" + "github.com/containerd/containerd/v2/version" "github.com/containerd/log" metrics "github.com/docker/go-metrics" "github.com/urfave/cli/v2" @@ -64,6 +65,19 @@ func init() { panic(err) } + cli.VersionPrinter = func(cliContext *cli.Context) { + fmt.Println(cliContext.App.Name, version.Package, cliContext.App.Version) + } + + // Override the default flag descriptions for '--version' and '--help' + // to align with other flags and start with uppercase. + cli.VersionFlag = &cli.BoolFlag{ + Name: "version", + Aliases: []string{"v"}, + Usage: "Print the version", + + DisableDefaultText: true, + } cli.HelpFlag = &cli.BoolFlag{ Name: "help", Aliases: []string{"h"}, @@ -132,6 +146,7 @@ func main() { app := cli.NewApp() app.Name = "containerd-stress" app.Description = "stress test a containerd daemon" + app.Version = version.Version app.Flags = []cli.Flag{ &cli.BoolFlag{ Name: "debug",