Skip to content

Commit d783902

Browse files
authored
Merge pull request #34 from alexanderpetrenz/master
command property: replace string concatenation by taking over given list
2 parents b9c096d + e6badd3 commit d783902

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

autocompose.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ def main():
1010
args = parser.parse_args()
1111

1212
struct = {}
13-
networks = []
13+
networks = set()
1414
for cname in args.cnames:
15-
cfile, networks = generate(cname)
15+
cfile, c_networks = generate(cname)
16+
1617
struct.update(cfile)
18+
networks.update(c_networks)
1719

18-
render(struct, args, networks)
20+
render(struct, args, list(networks))
1921

2022

2123
def render(struct, args, networks):
@@ -94,12 +96,12 @@ def generate(cname):
9496
networks[network.attrs['Name']] = {'external': (not network.attrs['Internal'])}
9597

9698
# Check for command and add it if present.
97-
if cattrs['Config']['Cmd'] != None:
98-
values['command'] = " ".join(cattrs['Config']['Cmd']),
99+
if cattrs['Config']['Cmd'] is not None:
100+
values['command'] = cattrs['Config']['Cmd']
99101

100102
# Check for exposed/bound ports and add them if needed.
101103
try:
102-
expose_value = list(cattrs['Config']['ExposedPorts'].keys())
104+
expose_value = list(cattrs['Config']['ExposedPorts'].keys())
103105
ports_value = [cattrs['HostConfig']['PortBindings'][key][0]['HostIp']+':'+cattrs['HostConfig']['PortBindings'][key][0]['HostPort']+':'+key for key in cattrs['HostConfig']['PortBindings']]
104106

105107
# If bound ports found, don't use the 'expose' value.

0 commit comments

Comments
 (0)