@@ -29,58 +29,66 @@ def link_graph(self, compose, notes=False):
29
29
result += 'note top of [{0}]\n {1}\n end note\n ' .format (component_name , '\n ' .join (labels ))
30
30
return result .strip ()
31
31
32
- def boundaries (self , compose , group = False , notes = False ):
32
+ def boundaries (self , compose , group = False , ports = True , volumes = True , notes = False ):
33
33
result = 'skinparam componentStyle uml2\n '
34
34
35
35
result += 'cloud system {\n '
36
36
for component in sorted (self .components (compose )):
37
- if self .has_service_external_ports (compose , component ) or self .has_service_volumes (compose , component ):
38
- result += ' [{0}]\n ' .format (component )
39
- result += '}\n '
40
- volume_registry = {}
41
-
42
- volume_uml = ''
43
- for volume in sorted (self .volumes (compose )):
44
- if not self .is_volume_used (compose , volume ):
37
+ relevant = False
38
+ if ports and self .has_service_external_ports (compose , component ):
39
+ relevant = True
40
+ if volumes and self .has_service_volumes (compose , component ):
41
+ relevant = True
42
+ if not relevant :
45
43
continue
46
- volume_uml += 'database {0}' .format (volume ) + ' {\n '
47
- for path in sorted (self .volume_usage (compose , volume )):
48
- id = self .volume_identifier (volume , path )
49
-
50
- if id in volume_registry :
51
- continue
52
- volume_registry [id ] = 'volume_{0}' .format (len (volume_registry .keys ()) + 1 )
53
- volume_uml += ' [{0}] as {1}\n ' .format (path , volume_registry [id ])
54
-
55
- volume_uml += '}\n '
56
- result += self .group ('volumes' , volume_uml ) if group else volume_uml
57
-
58
- port_uml = ''
59
- port_links = ''
60
- for service , host , container in sorted (self .ports (compose )):
61
- port = host if container is None else '{0} : {1}' .format (host , container )
62
- port_links += '[{0}] --> {1}\n ' .format (service , port )
63
- port_uml += 'interface {0}\n ' .format (host )
64
- result += self .group ('ports' , port_uml ) if group else ''
65
- result += port_links
66
-
67
- for volume in sorted (self .volumes (compose )):
68
- for service , volume_path in sorted (self .service_using_path (compose , volume )):
69
- name = volume_path
70
- if '{0}.{1}' .format (volume , volume_path ) in volume_registry :
71
- name = volume_registry ['{0}.{1}' .format (volume , volume_path )]
72
- result += '[{0}] --> {1}\n ' .format (service , name )
44
+ result += ' [{0}]\n ' .format (component )
45
+ if not notes :
46
+ continue
47
+ if not self .labels (compose , component ):
48
+ continue
49
+ labels = []
50
+ for key , value in self .labels (compose , component ).items ():
51
+ labels .append ('{0}={1}' .format (key , value ))
52
+ result += ' note top of [{0}]\n {1}\n end note\n ' .format (component , '\n ' .join (labels ))
53
+ result += '}\n '
54
+ if volumes :
55
+ volume_registry = {}
73
56
74
- if notes :
75
- for component_name in sorted (self .components (compose )):
76
- if not (self .has_service_external_ports (compose , component_name ) or self .has_service_volumes (compose , component_name )):
77
- continue
78
- if not self .labels (compose , component_name ):
57
+ volume_uml = ''
58
+ for volume in sorted (self .volumes (compose )):
59
+ if not self .is_volume_used (compose , volume ):
79
60
continue
80
- labels = []
81
- for key , value in self .labels (compose , component_name ).items ():
82
- labels .append ('{0}={1}' .format (key , value ))
83
- result += 'note top of [{0}]\n {1}\n end note\n ' .format (component_name , '\n ' .join (labels ))
61
+ volume_uml += 'database {0}' .format (volume ) + ' {\n '
62
+ for path in sorted (self .volume_usage (compose , volume )):
63
+ id = self .volume_identifier (volume , path )
64
+
65
+ if id in volume_registry :
66
+ continue
67
+ volume_registry [id ] = 'volume_{0}' .format (len (volume_registry .keys ()) + 1 )
68
+ volume_uml += ' [{0}] as {1}\n ' .format (path , volume_registry [id ])
69
+
70
+ volume_uml += '}\n '
71
+ result += self .group ('volumes' , volume_uml ) if group else volume_uml
72
+
73
+ if ports :
74
+ port_uml = ''
75
+ port_links = ''
76
+ for service , host , container in sorted (self .ports (compose )):
77
+ port = host
78
+ if container is not None :
79
+ port = '{0} : {1}' .format (host , container )
80
+ port_links += '[{0}] --> {1}\n ' .format (service , port )
81
+ port_uml += 'interface {0}\n ' .format (port )
82
+ result += self .group ('ports' , port_uml ) if group else ''
83
+ result += port_links
84
+
85
+ if volumes :
86
+ for volume in sorted (self .volumes (compose )):
87
+ for service , volume_path in sorted (self .service_using_path (compose , volume )):
88
+ name = volume_path
89
+ if '{0}.{1}' .format (volume , volume_path ) in volume_registry :
90
+ name = volume_registry ['{0}.{1}' .format (volume , volume_path )]
91
+ result += '[{0}] --> {1}\n ' .format (service , name )
84
92
85
93
return result .strip ()
86
94
0 commit comments