Let apps send email through the owner's own mail provider (#26)
This commit is contained in:
1 parent
c7036c04d5
commit
7b6851c023
146 files changed
+737
-179
No files matched your search
@@ -0,0 +1,49 @@
|
||||
"""Checks every recipe's x-harbor.parameters against schema/cottage.schema.json
|
||||
($defs/parameter) and the shared outgoing-mail fields. Needs PyYAML and jsonschema."""
|
||||
|
||||
import glob
|
||||
import json
|
||||
import sys
|
||||
|
||||
import jsonschema
|
||||
import yaml
|
||||
|
||||
schema = json.load(open("schema/cottage.schema.json"))
|
||||
param = dict(schema["$defs"]["parameter"], **{"$schema": schema["$schema"]})
|
||||
validator = jsonschema.Draft202012Validator(param)
|
||||
|
||||
# The standard outgoing-mail fields. Every recipe that offers mail uses these keys, so the
|
||||
# dashboard can show one familiar "Email" section, and maps them onto the app's own settings.
|
||||
MAIL = {
|
||||
"SMTP_HOST": {"type": "string"},
|
||||
"SMTP_PORT": {"type": "int", "default": "587"},
|
||||
"SMTP_USER": {"type": "string"},
|
||||
"SMTP_PASSWORD": {"type": "string", "secret": True},
|
||||
"SMTP_FROM": {"type": "string"},
|
||||
"SMTP_SECURITY": {"type": "choice", "choices": ["starttls", "tls", "none"], "default": "starttls"},
|
||||
}
|
||||
|
||||
bad = []
|
||||
for path in sorted(glob.glob("apps/*/template.yml")):
|
||||
params = (yaml.safe_load(open(path)).get("x-harbor") or {}).get("parameters") or []
|
||||
for p in params:
|
||||
name = p.get("key", "?")
|
||||
for e in validator.iter_errors(p):
|
||||
where = "/".join(str(x) for x in e.path) or "entry"
|
||||
bad.append(f"{path}: parameter {name}: {where}: {e.message}")
|
||||
want = MAIL.get(name)
|
||||
if p.get("group") == "email" and want is None:
|
||||
bad.append(f"{path}: parameter {name}: group email is for the standard SMTP_* fields only")
|
||||
if want is None:
|
||||
continue
|
||||
if p.get("group") != "email":
|
||||
bad.append(f"{path}: parameter {name}: needs group: email")
|
||||
if p.get("editable") is not True or p.get("required"):
|
||||
bad.append(f"{path}: parameter {name}: mail fields are editable and not required")
|
||||
if p.get("generate"):
|
||||
bad.append(f"{path}: parameter {name}: mail fields are never generated")
|
||||
for k, v in want.items():
|
||||
if p.get(k) != v:
|
||||
bad.append(f"{path}: parameter {name}: {k} must be {v!r}")
|
||||
print("\n".join(bad) or "all parameters OK")
|
||||
sys.exit(1 if bad else 0)
|
||||
@@ -1 +1 @@
|
||||
1c42cea53cd56434bdee4c4efea7fb9a3a8ac4b4
|
||||
4968f029cc143be3e4145383e6442f1ec7abd119
|
||||
@@ -28,6 +28,16 @@ jobs:
|
||||
sys.exit(1 if bad else 0)
|
||||
PY
|
||||
|
||||
# Parameters follow schema/cottage.schema.json ($defs/parameter), and recipes that send mail
|
||||
# use the shared SMTP_* fields in group "email".
|
||||
parameters:
|
||||
name: Parameters
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: pip install --quiet jsonschema pyyaml
|
||||
- run: python3 .github/check-parameters.py
|
||||
|
||||
compose:
|
||||
name: Docker Compose test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
Reference in new issue
Block a user