precommit + update Instance

* add generic Instance way to contact api
* update python using refactoring tool for json2md
This commit is contained in:
Jordan Blasenhauer 2024-03-14 10:51:12 +01:00
parent 64e9bc572b
commit b2deea3aa3
6 changed files with 40 additions and 19 deletions

View file

@ -8,6 +8,7 @@ from pytablewriter import MarkdownTableWriter
import requests
import zipfile
import shutil
from contextlib import suppress
def print_md_table(settings) -> MarkdownTableWriter:
@ -74,12 +75,10 @@ print("## Core settings\n", file=doc)
core_settings = {}
for core in glob("src/common/core/*/plugin.json"):
with open(core, "r") as f:
try:
with suppress(Exception):
core_plugin = loads(f.read())
if len(core_plugin["settings"]) > 0:
core_settings[core_plugin["name"]] = core_plugin
except:
pass
for name, data in dict(sorted(core_settings.items())).items():
print(f"### {data['name']}\n", file=doc)
@ -117,8 +116,7 @@ url = f"https://assets.bunkerity.com/bw-pro/preview/v{version}.zip"
# Download zip
response = requests.get(url)
response.raise_for_status()
with open(f"v{version}.zip", "wb") as f:
f.write(response.content)
Path(f"v{version}.zip").write_bytes(response.content)
# Unzip file
with zipfile.ZipFile(f"v{version}.zip", "r") as zip_ref:
@ -129,12 +127,10 @@ print("## Pro plugins", file=doc)
pro_settings = {}
for pro in glob(f"v{version}/*/plugin.json"):
with open(pro, "r") as f:
try:
with suppress(Exception):
pro_plugin = loads(f.read())
if len(pro_plugin["settings"]) > 0:
pro_settings[pro_plugin["name"]] = pro_plugin
except:
pass
for name, data in dict(sorted(pro_settings.items())).items():
print(pro_title("3", data["name"]), file=doc)

View file

@ -31,7 +31,7 @@
})})
})
</script>
<script defer>
// Lazy load images and embed youtube videos

View file

@ -321,11 +321,11 @@ STREAM support :white_check_mark:
Automatic creation, renewal and configuration of Let's Encrypt certificates.
| Setting |Default| Context |Multiple| Description |
|--------------------------|-------|---------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`AUTO_LETS_ENCRYPT` |`no` |multisite|no |Activate automatic Let's Encrypt mode. |
|`EMAIL_LETS_ENCRYPT` | |multisite|no |Email used for Let's Encrypt notification and in certificate. |
|`USE_LETS_ENCRYPT_STAGING`|`no` |multisite|no |Use the staging environment for Lets Encrypt certificate generation. Useful when you are testing your deployments to avoid being rate limited in the production environment.|
| Setting |Default| Context |Multiple| Description |
|--------------------------|-------|---------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`AUTO_LETS_ENCRYPT` |`no` |multisite|no |Activate automatic Let's Encrypt mode. |
|`EMAIL_LETS_ENCRYPT` | |multisite|no |Email used for Let's Encrypt notification and in certificate. |
|`USE_LETS_ENCRYPT_STAGING`|`no` |multisite|no |Use the staging environment for Let’s Encrypt certificate generation. Useful when you are testing your deployments to avoid being rate limited in the production environment.|
### Limit

View file

@ -129,6 +129,9 @@ class Instance:
def ping(self, plugin_id) -> Tuple[bool, dict[str, Any]]:
return self.apiCaller.send_to_apis("POST", f"/{plugin_id}/ping", response=True)
def data(self, plugin_endpoint) -> Tuple[bool, dict[str, Any]]:
return self.apiCaller.send_to_apis("GET", f"/{plugin_endpoint}", response=True)
class Instances:
def __init__(self, docker_client, kubernetes_client, integration: str):
@ -459,3 +462,25 @@ class Instances:
break
return ping
def get_data(self, plugin_endpoint: str):
# Need at least one instance to get a success ping to return success
data = []
for instance in self.get_instances():
instance_name = instance.name if instance.name != "local" else "127.0.0.1"
try:
resp, instance_data = instance.data(plugin_endpoint)
except:
continue
if not resp:
continue
if instance_data[instance_name].get("status", "error") == "error":
continue
data.append({instance_name: instance_data[instance_name].get("msg", {})})
return data

View file

@ -303,7 +303,7 @@
}
.core-layout-separator {
@apply col-span-12
@apply col-span-12;
}
.core-card-list {

View file

@ -10,7 +10,7 @@
data-id="0"
class="h-[3.5rem] overflow-hidden flex justify-center items-center w-full left-0 transition-all duration-700 absolute px-1 md:px-4 py-1 bg-secondary dark:brightness-95">
<p class="dark:brightness-125 mb-0 text-center text-xs xs:text-sm text-white">
Get the most of BunkerWeb by upgrading to the PRO version. More info and free trial
Get the most of BunkerWeb by upgrading to the PRO version. More info and free trial
<a class="dark:brightness-125 font-medium underline text-gray-100 dark:text-gray-50 hover:no-underline"
href="https://panel.bunkerweb.io/?utm_campaign=self&utm_source=banner#pro">here</a>.
</p>
@ -20,7 +20,7 @@
data-id="1"
class="h-[3.5rem] overflow-hidden left-full flex justify-center items-center w-full transition-all duration-700 absolute px-1 md:px-4 py-1 bg-secondary dark:brightness-95">
<p class="dark:brightness-125 mb-0 text-center text-xs xs:text-sm text-white">
Need premium support or tailored consulting around BunkerWeb ? Check out our
Need premium support or tailored consulting around BunkerWeb ? Check out our
<a class="dark:brightness-125 font-medium underline text-gray-100 dark:text-gray-50 hover:no-underline"
href="https://panel.bunkerweb.io/?utm_campaign=self&utm_source=banner#services">professional services</a>.
</p>
@ -30,10 +30,10 @@
data-id="2"
class="h-[3.5rem] overflow-hidden left-full flex justify-center items-center w-full transition-all duration-700 absolute px-1 md:px-4 py-1 bg-secondary dark:brightness-95">
<p class="dark:brightness-125 mb-0 text-center text-xs xs:text-sm text-white">
Be part of the Bunker community by joining the
Be part of the Bunker community by joining the
<a class="dark:brightness-125 font-medium underline text-gray-100 dark:text-gray-50 hover:no-underline"
href="https://discord.bunkerweb.io">Discord chat</a>
and following us on
and following us on
<a class="dark:brightness-125 font-medium underline text-gray-100 dark:text-gray-50 hover:no-underline"
href="https://www.linkedin.com/company/bunkerity/">LinkedIn</a>.
</p>