1- """interpret the output of `docker- compose` commands"""
1+ """interpret the output of `docker compose` commands"""
22
33import json
44import re
@@ -13,7 +13,7 @@ def parse_docker_compose_up_line(line):
1313 match = try_match (
1414 r'(?P<service>\S+)(?P<delimiter>[_-])\d+\s*\| (?P<payload>.*)\n' , line )
1515 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
1717 # project name, while others don't. The parts of the name are
1818 # delimited by either underscores or hyphens, and we don't use service
1919 # names with either delimiter in them, so we can pull apart the name
@@ -34,7 +34,7 @@ def parse_docker_compose_up_line(line):
3434 })
3535
3636 # 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*'
3838 match = try_match (begin_create_container , line )
3939 if match is not None :
4040 return ('begin_create_container' , {
@@ -48,26 +48,26 @@ def parse_docker_compose_up_line(line):
4848 'container' : match .groupdict ()['container' ]
4949 })
5050
51- # Different docker- compose setups (versions?) produce different output
51+ # Different docker compose setups (versions?) produce different output
5252 # when a container is creating/created. Here are the other flavors of
5353 # begin_create_container and finish_create_container.
5454
5555 # 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 )
5757 if match is not None :
5858 return ('begin_create_container' , {
5959 'container' : match .groupdict ()['container' ]
6060 })
6161
6262 # 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 )
6464 if match is not None :
6565 return ('finish_create_container' , {
6666 'container' : match .groupdict ()['container' ]
6767 })
6868
6969 # 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 )
7171 if match is not None :
7272 return ('attach_to_logs' , {
7373 'containers' : [
@@ -77,19 +77,19 @@ def parse_docker_compose_up_line(line):
7777 })
7878
7979 # 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 )
8181 if match is not None :
8282 return ('image_build_success' , {'image' : match .groupdict ()['image' ]})
8383
8484 return ('other' , {'payload' : line })
8585
8686
8787def 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 )
8989 if match is not None :
9090 return ('remove_network' , {'network' : match .groupdict ()['network' ]})
9191
92- begin_stop_container = r'Stopping (?P<container>\S+)\s*\.\.\.\s*'
92+ begin_stop_container = r'\s* Stopping (?P<container>\S+)\s*\.\.\.\s*'
9393 match = try_match (begin_stop_container , line )
9494 if match is not None :
9595 return ('begin_stop_container' , {
@@ -102,7 +102,7 @@ def parse_docker_compose_down_line(line):
102102 'container' : match .groupdict ()['container' ]
103103 })
104104
105- begin_remove_container = r'Removing (?P<container>\S+)\s*\.\.\.\s*'
105+ begin_remove_container = r'\s* Removing (?P<container>\S+)\s*\.\.\.\s*'
106106 match = try_match (begin_remove_container , line )
107107 if match is not None :
108108 return ('begin_remove_container' , {
0 commit comments