File tree Expand file tree Collapse file tree 1 file changed +38
-4
lines changed
Expand file tree Collapse file tree 1 file changed +38
-4
lines changed Original file line number Diff line number Diff line change 4848
4949logger = logging .getLogger (__name__ )
5050
51+ SINGLE_DOCKER_FLAGS = {
52+ "-d" ,
53+ "--detach" ,
54+ "--init" ,
55+ "-i" ,
56+ "--interactive" ,
57+ "--no-healthcheck" ,
58+ "--oom-kill-disable" ,
59+ "--privileged" ,
60+ "-P" ,
61+ "--publish-all" ,
62+ "-q" ,
63+ "--quiet" ,
64+ "--read-only" ,
65+ "--rm" ,
66+ "--sig-proxy" ,
67+ "-t" ,
68+ "--tty" ,
69+ "--use-api-socket" ,
70+ # A couple of common combinations
71+ "-ti" ,
72+ "-it" ,
73+ }
74+
5175
5276def process_command (command : "Sequence[str]" ) -> "str" :
5377 basename_command = os .path .basename (command [0 ])
@@ -65,13 +89,23 @@ def process_command(command: "Sequence[str]") -> "str":
6589 retlabel += "\n " + os .path .basename (token )
6690 break
6791 elif basename_command == "docker" :
92+ is_docker_run = False
93+ prev_flag = False
6894 for token in command [1 :]:
69- if token == "stats" :
95+ if is_docker_run :
96+ if token .startswith ("-" ):
97+ prev_flag = token not in SINGLE_DOCKER_FLAGS
98+ elif prev_flag :
99+ prev_flag = False
100+ else :
101+ retlabel += "\n " + token
102+ break
103+ elif token == "stats" :
70104 retlabel = "docker stats"
71105 break
72- elif not token . startswith ( "-" ) and token ! = "run" :
73- retlabel = "docker run\n " + token
74- break
106+ elif token = = "run" :
107+ retlabel = "docker run"
108+ is_docker_run = True
75109
76110 return retlabel
77111
You can’t perform that action at this time.
0 commit comments