@@ -21,7 +21,7 @@ def link_graph(self, compose):
21
21
result += '[{0}] ..> [{1}] : depends on\n ' .format (source , destination )
22
22
return result .strip ()
23
23
24
- def boundaries (self , compose ):
24
+ def boundaries (self , compose , group = False ):
25
25
result = 'skinparam componentStyle uml2\n '
26
26
27
27
result += 'cloud system {\n '
@@ -31,25 +31,32 @@ def boundaries(self, compose):
31
31
result += '}\n '
32
32
volume_registry = {}
33
33
34
+ volume_uml = ''
34
35
for volume in sorted (self .volumes (compose )):
35
36
if not self .is_volume_used (compose , volume ):
36
37
continue
37
- result += 'database {0}' .format (volume ) + ' {\n '
38
+ volume_uml += 'database {0}' .format (volume ) + ' {\n '
38
39
for path in sorted (self .volume_usage (compose , volume )):
39
40
id = self .volume_identifier (volume , path )
40
41
41
42
if id in volume_registry :
42
43
continue
43
44
volume_registry [id ] = 'volume_{0}' .format (len (volume_registry .keys ()) + 1 )
44
- result += ' [{0}] as {1}\n ' .format (path , volume_registry [id ])
45
+ volume_uml += ' [{0}] as {1}\n ' .format (path , volume_registry [id ])
45
46
46
- result += '}\n '
47
+ volume_uml += '}\n '
48
+ result += self .group ('volumes' , volume_uml ) if group else volume_uml
47
49
50
+ port_uml = ''
51
+ port_links = ''
48
52
for service , host , container in sorted (self .ports (compose )):
49
53
port = host
50
54
if container is not None :
51
55
port = '{0} : {1}' .format (host , container )
52
- result += '[{0}] --> {1}\n ' .format (service , port )
56
+ port_links += '[{0}] --> {1}\n ' .format (service , port )
57
+ port_uml += 'interface {0}\n ' .format (port )
58
+ result += self .group ('ports' , port_uml ) if group else ''
59
+ result += port_links
53
60
54
61
for volume in sorted (self .volumes (compose )):
55
62
for service , volume_path in sorted (self .service_using_path (compose , volume )):
@@ -59,6 +66,12 @@ def boundaries(self, compose):
59
66
result += '[{0}] --> {1}\n ' .format (service , name )
60
67
return result .strip ()
61
68
69
+ @staticmethod
70
+ def group (name , content ):
71
+ if len (content ) == 0 :
72
+ return ''
73
+ return 'package {0} ' .format (name ) + '{\n ' + '\n ' .join (content .split ('\n ' )).strip () + '\n }\n '
74
+
62
75
@staticmethod
63
76
def is_volume_used (compose , volume ):
64
77
components = compose if 'version' not in compose else compose .get ('services' , {})
0 commit comments