Skip to content

Commit ddd0ba0

Browse files
committed
Fix docker-agent version for cli plugin & standalone exec
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
1 parent 3ee027a commit ddd0ba0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎cmd/root/version.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/docker/cagent/pkg/cli"
77
"github.com/docker/cagent/pkg/telemetry"
88
"github.com/docker/cagent/pkg/version"
9+
"github.com/docker/cli/cli-plugins/plugin"
910
)
1011

1112
func newVersionCmd() *cobra.Command {
@@ -22,6 +23,14 @@ func runVersionCommand(cmd *cobra.Command, args []string) {
2223
telemetry.TrackCommand("version", args)
2324

2425
out := cli.NewPrinter(cmd.OutOrStdout())
25-
out.Printf("cagent version %s\n", version.Version)
26+
27+
commandName := "docker-agent"
28+
if cmd.Parent() != nil {
29+
commandName = cmd.Parent().Name()
30+
}
31+
if !plugin.RunningStandalone() {
32+
commandName = "docker " + commandName
33+
}
34+
out.Printf("%s version %s\n", commandName, version.Version)
2635
out.Printf("Commit: %s\n", version.Commit)
2736
}

0 commit comments

Comments
 (0)