Remove special handling of common services and refactor getting service attributes

This commit is contained in:
Tobias Reisinger 2024-10-21 01:29:01 +02:00
parent 0347efcb38
commit ff92241ddb
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
13 changed files with 92 additions and 49 deletions

View file

@ -8,10 +8,12 @@ import hcl2
icon_overrides = {
"acme_dns": "lets-encrypt",
"backup": "restic",
"extra_services": None,
"faas": None,
"forgejo_runner": "forgejo",
"healthcheck": "healthchecks",
"lego": "lets-encrypt",
"mailcowdockerized": "mailcow",
"reitanlage_oranienburg": "grav",
"tandoor": "tandoor-recipes",
@ -22,9 +24,11 @@ icon_overrides = {
}
icon_format = {
"restic": "webp",
"linkwarden": "webp",
"telegraf": "webp",
"tiny-tiny-rss": "webp",
"watchtower": "webp", # TODO revert when icon is fixed
}
def get_icon(svc):
@ -52,6 +56,20 @@ def parse_hosts(hosts):
})
return result
def parse_service(svc, data, hosts):
svc_key = service_key(svc, data, hosts)
domains = []
for dns in data.get("dns") or []:
domains.append(f"- {dns['domain']}")
data['key'] = svc_key
data['host_key'] = host_key(data["host"], hosts)
data['label'] = "\\n".join([svc] + domains)
data['icon'] = get_icon(svc)
return dict(data)
def parse_services(services, hosts):
result = []
@ -59,17 +77,12 @@ def parse_services(services, hosts):
authentik_key = service_key_find("authentik", services, hosts)
for svc, data in services.items():
svc_key = service_key(svc, data, hosts)
domains = []
for dns in data.get("dns") or []:
domains.append(f"- {dns['domain']}")
data['key'] = svc_key
data['label'] = "\\n".join([svc] + domains)
data['icon'] = get_icon(svc)
result.append(data)
if data["host"] == "*":
for host in hosts.keys():
data["host"] = host
result.append(parse_service(svc, data, hosts))
else:
result.append(parse_service(svc, data, hosts))
return result