Python control-panel package driving the full provisioning flow from a site's site.yaml (docs/05): - provision: ZFS web dataset + ownership, per-site DB + least-priv user, generated .env encrypted to secrets.enc.yaml (SOPS/age), render the profile templates + persist site.yaml, per-customer chrooted SFTP account, docker compose up. - deprovision (gated: data destroyed only with --purge, after a final backup), backup (ZFS snapshot + mariadb-dump), restore (rollback + import), render (preview), list. Design: one command/file runner with a real --dry-run (prints every action, redacts secrets); idempotent steps; Config + Site validation mirroring docs/03; passwords never logged. Modules: cli, config, naming, context, render, runner, zfs, database, secrets, sftp, compose, provision, backup. Plus pyproject (heleosctl entry point), config.example.yaml, an example site, and a README. Tests: 22 pure-logic unit tests (naming, config validation, template render across all profiles + db on/off) — all passing. Full provision and deprovision verified end-to-end in --dry-run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
1 KiB
Python
31 lines
1 KiB
Python
import pytest
|
|
|
|
from heleos import naming
|
|
from heleos.errors import ValidationError
|
|
|
|
|
|
def test_slug_and_db_identifiers():
|
|
assert naming.slug("acme", "shop") == "acme-shop"
|
|
assert naming.slug_underscored("acme", "my-shop") == "acme_my_shop"
|
|
assert naming.database_name("acme", "shop") == "db_acme_shop"
|
|
assert naming.database_user("acme", "shop") == "u_acme_shop"
|
|
assert naming.sftp_user("acme") == "sftp_acme"
|
|
|
|
|
|
@pytest.mark.parametrize("bad", ["", "A", "1abc", "ab_cd", "-abc", "x" * 40])
|
|
def test_invalid_customer(bad):
|
|
with pytest.raises(ValidationError):
|
|
naming.validate_customer(bad)
|
|
|
|
|
|
@pytest.mark.parametrize("name", ["proxy", "platform", "mariadb", "deployments"])
|
|
def test_reserved_names_rejected(name):
|
|
with pytest.raises(ValidationError):
|
|
naming.validate_customer(name)
|
|
with pytest.raises(ValidationError):
|
|
naming.validate_site(name)
|
|
|
|
|
|
def test_valid_ids():
|
|
assert naming.validate_customer("acme") == "acme"
|
|
assert naming.validate_site("blog-2") == "blog-2"
|