Optimize plugin gathering
This commit is contained in:
parent
b3cfc1f01c
commit
73668b476f
|
@ -38,9 +38,10 @@ class Config:
|
|||
|
||||
def reload_plugins(self) -> None:
|
||||
self.__plugins = []
|
||||
self.__plugins_pages = []
|
||||
|
||||
for foldername in iglob("/etc/bunkerweb/plugins/*"):
|
||||
for foldername in list(iglob("/etc/bunkerweb/plugins/*")) + list(
|
||||
iglob("/usr/share/bunkerweb/core/*")
|
||||
):
|
||||
content = listdir(foldername)
|
||||
if "plugin.json" not in content:
|
||||
continue
|
||||
|
@ -48,28 +49,19 @@ class Config:
|
|||
with open(f"{foldername}/plugin.json", "r") as f:
|
||||
plugin = json_load(f)
|
||||
|
||||
self.__plugins.append(plugin)
|
||||
|
||||
plugin.update(
|
||||
{
|
||||
"page": False,
|
||||
"external": foldername.startswith("/etc/bunkerweb/plugins"),
|
||||
}
|
||||
)
|
||||
if "ui" in content:
|
||||
if "template.html" in listdir(f"{foldername}/ui"):
|
||||
self.__plugins_pages.append(plugin["name"])
|
||||
|
||||
for foldername in iglob("/usr/share/bunkerweb/core/*"):
|
||||
content = listdir(foldername)
|
||||
if "plugin.json" not in content:
|
||||
continue
|
||||
|
||||
with open(f"{foldername}/plugin.json", "r") as f:
|
||||
plugin = json_load(f)
|
||||
plugin["page"] = True
|
||||
|
||||
self.__plugins.append(plugin)
|
||||
|
||||
if "ui" in content:
|
||||
if "template.html" in listdir(f"{foldername}/ui"):
|
||||
self.__plugins_pages.append(plugin["name"])
|
||||
|
||||
self.__plugins.sort(key=lambda plugin: plugin.get("name"))
|
||||
self.__plugins_pages.sort()
|
||||
self.__plugins_settings = {
|
||||
**{k: v for x in self.__plugins for k, v in x["settings"].items()},
|
||||
**self.__settings,
|
||||
|
@ -186,9 +178,6 @@ class Config:
|
|||
def get_plugins(self) -> List[dict]:
|
||||
return self.__plugins
|
||||
|
||||
def get_plugins_pages(self) -> List[str]:
|
||||
return self.__plugins_pages
|
||||
|
||||
def get_settings(self) -> dict:
|
||||
return self.__settings
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ class Instances:
|
|||
pod.metadata.uid,
|
||||
pod.metadata.name,
|
||||
pod.status.pod_ip,
|
||||
"container",
|
||||
"pod",
|
||||
status,
|
||||
pod,
|
||||
apiCaller,
|
||||
|
|
Loading…
Reference in New Issue