1
- """interpret the output of `docker- compose` commands"""
1
+ """interpret the output of `docker compose` commands"""
2
2
3
3
import json
4
4
import re
@@ -13,7 +13,7 @@ def parse_docker_compose_up_line(line):
13
13
match = try_match (
14
14
r'(?P<service>\S+)(?P<delimiter>[_-])\d+\s*\| (?P<payload>.*)\n' , line )
15
15
if match is not None :
16
- # Some docker- compose setups (versions?) prefix the service name by the
16
+ # Some docker compose setups (versions?) prefix the service name by the
17
17
# project name, while others don't. The parts of the name are
18
18
# delimited by either underscores or hyphens, and we don't use service
19
19
# names with either delimiter in them, so we can pull apart the name
@@ -34,7 +34,7 @@ def parse_docker_compose_up_line(line):
34
34
})
35
35
36
36
# begin_create_container: {container}
37
- begin_create_container = r'(Rec|C)reating (?P<container>\S+)\s*\.\.\.\s*'
37
+ begin_create_container = r'\s* (Rec|C)reating (?P<container>\S+)\s*\.\.\.\s*'
38
38
match = try_match (begin_create_container , line )
39
39
if match is not None :
40
40
return ('begin_create_container' , {
@@ -48,26 +48,26 @@ def parse_docker_compose_up_line(line):
48
48
'container' : match .groupdict ()['container' ]
49
49
})
50
50
51
- # Different docker- compose setups (versions?) produce different output
51
+ # Different docker compose setups (versions?) produce different output
52
52
# when a container is creating/created. Here are the other flavors of
53
53
# begin_create_container and finish_create_container.
54
54
55
55
# begin_create_container: {container}
56
- match = try_match (r'Container (?P<container>\S+)\s+Creating\s*' , line )
56
+ match = try_match (r'\s* Container (?P<container>\S+)\s+Creating\s*' , line )
57
57
if match is not None :
58
58
return ('begin_create_container' , {
59
59
'container' : match .groupdict ()['container' ]
60
60
})
61
61
62
62
# finish_create_container: {container}
63
- match = try_match (r'Container (?P<container>\S+)\s+Created\s*' , line )
63
+ match = try_match (r'\s* Container (?P<container>\S+)\s+Created\s*' , line )
64
64
if match is not None :
65
65
return ('finish_create_container' , {
66
66
'container' : match .groupdict ()['container' ]
67
67
})
68
68
69
69
# attach_to_logs: {'containers': [container, ...]}
70
- match = try_match (r'Attaching to (?P<containers>\S+(, \S+)*\s*)' , line )
70
+ match = try_match (r'\s* Attaching to (?P<containers>\S+(, \S+)*\s*)' , line )
71
71
if match is not None :
72
72
return ('attach_to_logs' , {
73
73
'containers' : [
@@ -77,19 +77,19 @@ def parse_docker_compose_up_line(line):
77
77
})
78
78
79
79
# image_build_success: {image}
80
- match = try_match (r'Successfully built (?P<image>\S+)\s*' , line )
80
+ match = try_match (r'\s* Successfully built (?P<image>\S+)\s*' , line )
81
81
if match is not None :
82
82
return ('image_build_success' , {'image' : match .groupdict ()['image' ]})
83
83
84
84
return ('other' , {'payload' : line })
85
85
86
86
87
87
def parse_docker_compose_down_line (line ):
88
- match = try_match (r'Removing network (?P<network>\S+)\n' , line )
88
+ match = try_match (r'\s* Removing network (?P<network>\S+)\n' , line )
89
89
if match is not None :
90
90
return ('remove_network' , {'network' : match .groupdict ()['network' ]})
91
91
92
- begin_stop_container = r'Stopping (?P<container>\S+)\s*\.\.\.\s*'
92
+ begin_stop_container = r'\s* Stopping (?P<container>\S+)\s*\.\.\.\s*'
93
93
match = try_match (begin_stop_container , line )
94
94
if match is not None :
95
95
return ('begin_stop_container' , {
@@ -102,7 +102,7 @@ def parse_docker_compose_down_line(line):
102
102
'container' : match .groupdict ()['container' ]
103
103
})
104
104
105
- begin_remove_container = r'Removing (?P<container>\S+)\s*\.\.\.\s*'
105
+ begin_remove_container = r'\s* Removing (?P<container>\S+)\s*\.\.\.\s*'
106
106
match = try_match (begin_remove_container , line )
107
107
if match is not None :
108
108
return ('begin_remove_container' , {
0 commit comments