Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit a0eabb3

Browse files
authoredJun 2, 2023
Merge pull request #2249 from milas/adjust-compose-events
metrics: adjust Compose event collection
2 parents e099b83 + b821810 commit a0eabb3

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed
 

‎cli/metrics/commands.go

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var commandFlags = []string{
2626
// Generated with generatecommands/main.go
2727
var managementCommands = []string{
2828
"help",
29+
"alpha",
2930
"app",
3031
"builder",
3132
"buildx",
@@ -160,4 +161,5 @@ var commands = []string{
160161
"validate",
161162
"version",
162163
"wait",
164+
"watch",
163165
}

‎cli/metrics/docker_command.go

+6-27
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func NewDockerCLIEvent(cmd CmdResult) *DockerCLIEvent {
6868
subcommand = strings.Join(subcommandParts, "-")
6969
}
7070

71+
cmdOrPlugin := cmdPath[1]
72+
if cmdOrPlugin.plugin && subcommand == "" {
73+
return nil
74+
}
75+
7176
var usage bool
7277
for _, arg := range cmd.Args {
7378
// TODO(milas): also support `docker help build` syntax
@@ -81,7 +86,7 @@ func NewDockerCLIEvent(cmd CmdResult) *DockerCLIEvent {
8186
}
8287

8388
event := &DockerCLIEvent{
84-
Command: cmdPath[1].name,
89+
Command: cmdOrPlugin.name,
8590
Subcommand: subcommand,
8691
ExitCode: int32(cmd.ExitCode),
8792
Usage: usage,
@@ -161,32 +166,6 @@ var cmdHierarchy = &cmdNode{
161166
{name: "dryrun"},
162167
},
163168
},
164-
{name: "build"},
165-
{name: "config"},
166-
{name: "convert"},
167-
{name: "cp"},
168-
{name: "create"},
169-
{name: "down"},
170-
{name: "events"},
171-
{name: "exec"},
172-
{name: "images"},
173-
{name: "kill"},
174-
{name: "logs"},
175-
{name: "ls"},
176-
{name: "pause"},
177-
{name: "port"},
178-
{name: "ps"},
179-
{name: "pull"},
180-
{name: "push"},
181-
{name: "restart"},
182-
{name: "rm"},
183-
{name: "run"},
184-
{name: "start"},
185-
{name: "stop"},
186-
{name: "top"},
187-
{name: "unpause"},
188-
{name: "up"},
189-
{name: "version"},
190169
},
191170
},
192171
},

‎cli/metrics/docker_command_test.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,35 @@ func TestCmdCompose(t *testing.T) {
4343
{
4444
name: "Compose - Base",
4545
input: "docker compose",
46-
expected: &DockerCLIEvent{Command: "compose"},
46+
expected: nil,
47+
},
48+
{
49+
name: "Compose - Ignored",
50+
input: "docker compose up",
51+
expected: nil,
4752
},
4853
{
4954
name: "Compose - Root Args",
50-
input: "docker --host 127.0.0.1 --debug=true compose ls",
55+
input: "docker --host 127.0.0.1 --debug=true compose alpha watch",
5156
expected: &DockerCLIEvent{
5257
Command: "compose",
53-
Subcommand: "ls",
58+
Subcommand: "alpha-watch",
5459
},
5560
},
5661
{
5762
name: "Compose - Base Args",
58-
input: "docker compose -p myproject build myservice",
63+
input: "docker compose -p myproject alpha watch myservice",
5964
expected: &DockerCLIEvent{
6065
Command: "compose",
61-
Subcommand: "build",
66+
Subcommand: "alpha-watch",
6267
},
6368
},
6469
{
6570
name: "Compose - Usage",
66-
input: "docker compose --file=mycompose.yaml up --help myservice",
71+
input: "docker compose --file=mycompose.yaml alpha watch --help myservice",
6772
expected: &DockerCLIEvent{
6873
Command: "compose",
69-
Subcommand: "up",
74+
Subcommand: "alpha-watch",
7075
Usage: true,
7176
},
7277
},

0 commit comments

Comments
 (0)