Refactor visualize.py to use jinja2
This commit is contained in:
parent
73a1b21cad
commit
20bb2c8fd7
3 changed files with 114 additions and 73 deletions
templates
77
templates/infrastructure.d2.j2
Normal file
77
templates/infrastructure.d2.j2
Normal file
|
@ -0,0 +1,77 @@
|
|||
vars: {
|
||||
d2-config: {
|
||||
layout-engine: elk
|
||||
theme-id: 101
|
||||
}
|
||||
}
|
||||
|
||||
external: {
|
||||
scaleway: {
|
||||
s3
|
||||
}
|
||||
|
||||
restic: {
|
||||
icon: https://cdn.jsdelivr.net/gh/selfhst/icons/webp/restic.webp
|
||||
}
|
||||
}
|
||||
|
||||
{% for host in hosts %}
|
||||
{{ host.key }}: {
|
||||
}
|
||||
{% endfor %}{# host #}
|
||||
|
||||
{% for svc in svcs %}
|
||||
{{ svc.key }}: {
|
||||
label: {{ svc.label }}
|
||||
label.near: top-left
|
||||
icon: {{ svc.icon }}
|
||||
icon.near: top-right
|
||||
}
|
||||
|
||||
{% for backup in svc.backup or [] %}
|
||||
{{ svc.key }} -> external.restic.{{ svc.host }}: backup.name {
|
||||
style: {
|
||||
stroke: "#0f0"
|
||||
stroke-dash: 3
|
||||
}
|
||||
}
|
||||
{% endfor %}{# backup #}
|
||||
|
||||
{% if svc.monitoring %}
|
||||
{{ monitoring_key }} -> {{ svc.key }}: {
|
||||
style.stroke: "#1E9025"
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if svc.database %}
|
||||
{{ svc.key }} -> {{ db_key }}: {
|
||||
style.stroke: "#336791"
|
||||
}
|
||||
{{ db_key }}.{{ svc.name }}
|
||||
{% endif %}
|
||||
|
||||
{% if svc.auth %}
|
||||
{{ svc.key }} -> {{ auth_key }}: {
|
||||
style.stroke: "#FD4B2D"
|
||||
}
|
||||
{{ auth_key }}.{{ svc.name }}
|
||||
{% endif %}
|
||||
|
||||
{% if svc.s3 %}
|
||||
{{ svc.key }} -> external.scaleway.s3: {
|
||||
style: {
|
||||
stroke: "#110B1E"
|
||||
stroke-dash: 3
|
||||
}
|
||||
}
|
||||
external.scaleway.s3.{{ svc.name }}
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}{# svc #}
|
||||
|
||||
{% for svc in grid_svcs %}
|
||||
{{ svc }}: {
|
||||
grid-columns: 3
|
||||
grid-gap: 0
|
||||
}
|
||||
{% endfor %}
|
Loading…
Add table
Add a link
Reference in a new issue