feat: add env_file, expose, porfilem, cgroup graph
This commit is contained in:
parent
1f2d7ff136
commit
7a4a050b5c
1 changed files with 33 additions and 4 deletions
|
@ -11,7 +11,7 @@ def apply_vertex_style(type) -> dict:
|
||||||
"shape": "component",
|
"shape": "component",
|
||||||
},
|
},
|
||||||
"volume": {
|
"volume": {
|
||||||
"shape": "folder",
|
"shape": "cylinder",
|
||||||
},
|
},
|
||||||
"network": {
|
"network": {
|
||||||
"shape": "pentagon",
|
"shape": "pentagon",
|
||||||
|
@ -19,6 +19,15 @@ def apply_vertex_style(type) -> dict:
|
||||||
"port": {
|
"port": {
|
||||||
"shape": "circle",
|
"shape": "circle",
|
||||||
},
|
},
|
||||||
|
"env_file": {
|
||||||
|
"shape": "tab",
|
||||||
|
},
|
||||||
|
"porfile": {
|
||||||
|
"shape": "invhouse",
|
||||||
|
},
|
||||||
|
"cgroup": {
|
||||||
|
"shape": "diamond",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return style[type]
|
return style[type]
|
||||||
|
@ -26,7 +35,7 @@ def apply_vertex_style(type) -> dict:
|
||||||
|
|
||||||
def apply_edge_style(type) -> dict:
|
def apply_edge_style(type) -> dict:
|
||||||
style = {
|
style = {
|
||||||
"ports": {
|
"expose": {
|
||||||
"style": "solid",
|
"style": "solid",
|
||||||
"dir": "both",
|
"dir": "both",
|
||||||
},
|
},
|
||||||
|
@ -45,6 +54,9 @@ def apply_edge_style(type) -> dict:
|
||||||
"arrowhead": "inv",
|
"arrowhead": "inv",
|
||||||
"arrowtail": "dot",
|
"arrowtail": "dot",
|
||||||
},
|
},
|
||||||
|
"env_file": {
|
||||||
|
"style": "solid",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return style[type]
|
return style[type]
|
||||||
|
@ -71,19 +83,33 @@ class Graph:
|
||||||
def render(self, format: str, cleanup: bool = True) -> None:
|
def render(self, format: str, cleanup: bool = True) -> None:
|
||||||
for service in self.compose.services:
|
for service in self.compose.services:
|
||||||
if service.image is not None:
|
if service.image is not None:
|
||||||
self.add_vertex(service.name, "service", lable=f"{service.name}\n({service.image})")
|
self.add_vertex(
|
||||||
|
service.name,
|
||||||
|
"service",
|
||||||
|
lable=f"{service.container_name if service.container_name else service.name}\n({service.image})",
|
||||||
|
)
|
||||||
if service.extends is not None:
|
if service.extends is not None:
|
||||||
self.add_vertex(service.name, "service", lable=f"{service.name}\n")
|
self.add_vertex(service.name, "service", lable=f"{service.name}\n")
|
||||||
self.add_edge(service.extends.service_name, service.name, "extends")
|
self.add_edge(service.extends.service_name, service.name, "extends")
|
||||||
|
if service.cgroup_parent is not None:
|
||||||
|
self.add_vertex(service.cgroup_parent, "cgroup")
|
||||||
|
self.add_edge(service.cgroup_parent, service.name, "links")
|
||||||
|
|
||||||
for network in service.networks:
|
for network in service.networks:
|
||||||
self.add_vertex(network, "network", lable=f"net:{network}")
|
self.add_vertex(network, "network", lable=f"net:{network}")
|
||||||
self.add_edge(service.name, network, "links")
|
self.add_edge(service.name, network, "links")
|
||||||
for volume in service.volumes:
|
for volume in service.volumes:
|
||||||
self.add_vertex(volume.source, "volume")
|
self.add_vertex(volume.source, "volume")
|
||||||
self.add_edge(service.name, volume.source, "volumes", lable=volume.target)
|
self.add_edge(service.name, volume.source, "volumes", lable=volume.target)
|
||||||
|
for expose in service.expose:
|
||||||
|
self.add_vertex(expose, "port")
|
||||||
|
self.add_edge(expose, service.name, "expose")
|
||||||
for port in service.ports:
|
for port in service.ports:
|
||||||
self.add_vertex(port.host_port, "port", lable=port.host_port)
|
self.add_vertex(port.host_port, "port", lable=port.host_port)
|
||||||
self.add_edge(port.host_port, service.name, "ports", lable=port.container_port)
|
self.add_edge(port.host_port, service.name, "links", lable=port.container_port)
|
||||||
|
for env_file in service.env_file:
|
||||||
|
self.add_vertex(env_file, "env_file")
|
||||||
|
self.add_edge(env_file, service.name, "env_file")
|
||||||
for link in service.links:
|
for link in service.links:
|
||||||
if ":" in link:
|
if ":" in link:
|
||||||
service_name, alias = link.split(":", 1)
|
service_name, alias = link.split(":", 1)
|
||||||
|
@ -92,5 +118,8 @@ class Graph:
|
||||||
self.add_edge(link, service.name, "links")
|
self.add_edge(link, service.name, "links")
|
||||||
for depends_on in service.depends_on:
|
for depends_on in service.depends_on:
|
||||||
self.add_edge(service.name, depends_on, "depends_on")
|
self.add_edge(service.name, depends_on, "depends_on")
|
||||||
|
for porfile in service.profiles:
|
||||||
|
self.add_vertex(porfile, "porfile")
|
||||||
|
self.add_edge(porfile, service.name, "links")
|
||||||
|
|
||||||
self.dot.render(outfile=f"{self.filename}.{format}", format=format, cleanup=cleanup)
|
self.dot.render(outfile=f"{self.filename}.{format}", format=format, cleanup=cleanup)
|
||||||
|
|
Loading…
Reference in a new issue