musubi-framework 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. musubi_framework-0.1.0/PKG-INFO +56 -0
  2. musubi_framework-0.1.0/README.md +43 -0
  3. musubi_framework-0.1.0/pyproject.toml +30 -0
  4. musubi_framework-0.1.0/setup.cfg +4 -0
  5. musubi_framework-0.1.0/src/musubi/__init__.py +3 -0
  6. musubi_framework-0.1.0/src/musubi/__main__.py +4 -0
  7. musubi_framework-0.1.0/src/musubi/cli.py +65 -0
  8. musubi_framework-0.1.0/src/musubi/core.py +123 -0
  9. musubi_framework-0.1.0/src/musubi/profiles/dev.toml +11 -0
  10. musubi_framework-0.1.0/src/musubi/profiles/prod.toml +11 -0
  11. musubi_framework-0.1.0/src/musubi/profiles/stage.toml +11 -0
  12. musubi_framework-0.1.0/src/musubi/templates/project/README.md.tmpl +20 -0
  13. musubi_framework-0.1.0/src/musubi/templates/project/caddy/Caddyfile.tmpl +23 -0
  14. musubi_framework-0.1.0/src/musubi/templates/project/compose.yaml.tmpl +60 -0
  15. musubi_framework-0.1.0/src/musubi/templates/project/dot-env.example.tmpl +7 -0
  16. musubi_framework-0.1.0/src/musubi/templates/project/dot-gitignore.tmpl +8 -0
  17. musubi_framework-0.1.0/src/musubi/templates/project/scripts/backup.sh.tmpl +9 -0
  18. musubi_framework-0.1.0/src/musubi/templates/project/zato/enmasse/enmasse.yaml.tmpl +13 -0
  19. musubi_framework-0.1.0/src/musubi/templates/project/zato/services/health.py.tmpl +15 -0
  20. musubi_framework-0.1.0/src/musubi_framework.egg-info/PKG-INFO +56 -0
  21. musubi_framework-0.1.0/src/musubi_framework.egg-info/SOURCES.txt +24 -0
  22. musubi_framework-0.1.0/src/musubi_framework.egg-info/dependency_links.txt +1 -0
  23. musubi_framework-0.1.0/src/musubi_framework.egg-info/entry_points.txt +2 -0
  24. musubi_framework-0.1.0/src/musubi_framework.egg-info/top_level.txt +1 -0
  25. musubi_framework-0.1.0/tests/test_cli.py +22 -0
  26. musubi_framework-0.1.0/tests/test_core.py +32 -0
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: musubi-framework
3
+ Version: 0.1.0
4
+ Summary: Framework for converging systems, APIs and AI on Zato 4.1
5
+ Author: MangroveX
6
+ Keywords: zato,integration,api,ai,devops
7
+ Classifier: Development Status :: 2 - Pre-Alpha
8
+ Classifier: Environment :: Console
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Musubi
15
+
16
+ ![Musubi](assets/brand/musubi-mark.png)
17
+
18
+ **Musubi** (結び) significa “nudo” o “unión”: sistemas, APIs e IA distintos
19
+ confluyen en un solo punto, se conectan de forma explícita y conservan su
20
+ identidad. El framework ofrece un punto de partida reproducible para proyectos
21
+ de integración sobre **Zato 4.1**.
22
+
23
+ ## Inicio rápido
24
+
25
+ ```bash
26
+ python -m pip install -e .
27
+ musubi profiles
28
+ musubi init pagos --profile dev --output ./pagos
29
+ musubi validate ./pagos
30
+ cd pagos && cp .env.example .env && docker compose up -d
31
+ ```
32
+
33
+ ## Qué incluye
34
+
35
+ - CLI sin dependencias de ejecución: `init`, `profiles`, `validate` y `doctor`.
36
+ - Plantilla Docker Compose con Zato 4.1 y Caddy.
37
+ - Configuración Enmasse y servicio inicial de salud.
38
+ - Perfiles `dev`, `stage` y `prod` con políticas progresivas.
39
+ - Sitio estático de presentación en `site/` y workflow de GitHub Pages.
40
+ - CI para Python 3.11/3.12, render de los tres perfiles y validación del sitio.
41
+
42
+ ## Perfiles
43
+
44
+ | Perfil | Uso | TLS | Réplicas | Política de imagen |
45
+ |---|---|---:|---:|---|
46
+ | `dev` | desarrollo local | interno | 1 | etiqueta Zato 4.1 |
47
+ | `stage` | preproducción | automático | 1 | etiqueta configurable |
48
+ | `prod` | producción | automático | 2 | digest obligatorio con `--strict` |
49
+
50
+ Las plantillas fijan `zatosource/zato-4.1:latest` como valor inicial. En
51
+ producción debe reemplazarse por una referencia inmutable con digest.
52
+
53
+ ## Estado
54
+
55
+ Estructura inicial `0.1.0`. La licencia aún debe ser elegida por el propietario
56
+ antes de publicar el paquete para terceros.
@@ -0,0 +1,43 @@
1
+ # Musubi
2
+
3
+ ![Musubi](assets/brand/musubi-mark.png)
4
+
5
+ **Musubi** (結び) significa “nudo” o “unión”: sistemas, APIs e IA distintos
6
+ confluyen en un solo punto, se conectan de forma explícita y conservan su
7
+ identidad. El framework ofrece un punto de partida reproducible para proyectos
8
+ de integración sobre **Zato 4.1**.
9
+
10
+ ## Inicio rápido
11
+
12
+ ```bash
13
+ python -m pip install -e .
14
+ musubi profiles
15
+ musubi init pagos --profile dev --output ./pagos
16
+ musubi validate ./pagos
17
+ cd pagos && cp .env.example .env && docker compose up -d
18
+ ```
19
+
20
+ ## Qué incluye
21
+
22
+ - CLI sin dependencias de ejecución: `init`, `profiles`, `validate` y `doctor`.
23
+ - Plantilla Docker Compose con Zato 4.1 y Caddy.
24
+ - Configuración Enmasse y servicio inicial de salud.
25
+ - Perfiles `dev`, `stage` y `prod` con políticas progresivas.
26
+ - Sitio estático de presentación en `site/` y workflow de GitHub Pages.
27
+ - CI para Python 3.11/3.12, render de los tres perfiles y validación del sitio.
28
+
29
+ ## Perfiles
30
+
31
+ | Perfil | Uso | TLS | Réplicas | Política de imagen |
32
+ |---|---|---:|---:|---|
33
+ | `dev` | desarrollo local | interno | 1 | etiqueta Zato 4.1 |
34
+ | `stage` | preproducción | automático | 1 | etiqueta configurable |
35
+ | `prod` | producción | automático | 2 | digest obligatorio con `--strict` |
36
+
37
+ Las plantillas fijan `zatosource/zato-4.1:latest` como valor inicial. En
38
+ producción debe reemplazarse por una referencia inmutable con digest.
39
+
40
+ ## Estado
41
+
42
+ Estructura inicial `0.1.0`. La licencia aún debe ser elegida por el propietario
43
+ antes de publicar el paquete para terceros.
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "musubi-framework"
7
+ version = "0.1.0"
8
+ description = "Framework for converging systems, APIs and AI on Zato 4.1"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ authors = [{ name = "MangroveX" }]
12
+ keywords = ["zato", "integration", "api", "ai", "devops"]
13
+ classifiers = [
14
+ "Development Status :: 2 - Pre-Alpha",
15
+ "Environment :: Console",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ ]
19
+
20
+ [project.scripts]
21
+ musubi = "musubi.cli:main"
22
+
23
+ [tool.setuptools]
24
+ package-dir = {"" = "src"}
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+
29
+ [tool.setuptools.package-data]
30
+ musubi = ["profiles/*.toml", "templates/project/**/*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Musubi framework."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,65 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ from . import __version__
8
+ from .core import MusubiError, PROFILES, create_project, doctor, load_profile, validate_project
9
+
10
+
11
+ def parser() -> argparse.ArgumentParser:
12
+ root = argparse.ArgumentParser(prog="musubi", description="Conecta sistemas, APIs e IA sobre Zato 4.1")
13
+ root.add_argument("--version", action="version", version=f"musubi {__version__}")
14
+ commands = root.add_subparsers(dest="command", required=True)
15
+
16
+ init = commands.add_parser("init", help="crea un proyecto desde una plantilla")
17
+ init.add_argument("name")
18
+ init.add_argument("--profile", choices=PROFILES, default="dev")
19
+ init.add_argument("--output", type=Path)
20
+ init.add_argument("--domain")
21
+ init.add_argument("--force", action="store_true")
22
+
23
+ commands.add_parser("profiles", help="lista los perfiles incluidos")
24
+ for command in ("validate", "doctor"):
25
+ check = commands.add_parser(command, help=f"{command} un proyecto generado")
26
+ check.add_argument("path", type=Path, nargs="?", default=Path.cwd())
27
+ if command == "validate":
28
+ check.add_argument("--strict", action="store_true")
29
+ return root
30
+
31
+
32
+ def print_checks(checks: list[object]) -> int:
33
+ failed = False
34
+ for check in checks:
35
+ marker = "OK" if check.ok else "FAIL"
36
+ print(f"[{marker}] {check.message}")
37
+ failed = failed or not check.ok
38
+ return 1 if failed else 0
39
+
40
+
41
+ def run(argv: list[str] | None = None) -> int:
42
+ args = parser().parse_args(argv)
43
+ try:
44
+ if args.command == "profiles":
45
+ for name in PROFILES:
46
+ profile = load_profile(name)
47
+ print(f"{name:5} {profile['description']}")
48
+ return 0
49
+ if args.command == "init":
50
+ destination = args.output or Path(args.name)
51
+ files = create_project(destination, args.name, args.profile, args.domain, args.force)
52
+ print(f"Proyecto {args.name} creado en {destination} ({len(files)} archivos, perfil {args.profile})")
53
+ return 0
54
+ if args.command == "validate":
55
+ return print_checks(validate_project(args.path, args.strict))
56
+ if args.command == "doctor":
57
+ return print_checks(doctor(args.path))
58
+ except MusubiError as exc:
59
+ print(f"musubi: {exc}", file=sys.stderr)
60
+ return 2
61
+ return 0
62
+
63
+
64
+ def main() -> None:
65
+ raise SystemExit(run())
@@ -0,0 +1,123 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ import shutil
5
+ import tomllib
6
+ from dataclasses import dataclass
7
+ from importlib.resources import files
8
+ from pathlib import Path
9
+
10
+
11
+ TOKEN = re.compile(r"{{\s*([a-zA-Z0-9_]+)\s*}}")
12
+ PROFILES = ("dev", "stage", "prod")
13
+ SPECIAL_TEMPLATE_NAMES = {
14
+ "dot-env.example.tmpl": ".env.example",
15
+ "dot-gitignore.tmpl": ".gitignore",
16
+ }
17
+
18
+
19
+ class MusubiError(RuntimeError):
20
+ pass
21
+
22
+
23
+ def profile_path(name: str) -> Path:
24
+ if name not in PROFILES:
25
+ raise MusubiError(f"Perfil desconocido: {name}")
26
+ return Path(str(files("musubi").joinpath("profiles", f"{name}.toml")))
27
+
28
+
29
+ def load_profile(name: str) -> dict[str, object]:
30
+ with profile_path(name).open("rb") as stream:
31
+ return tomllib.load(stream)
32
+
33
+
34
+ def render_text(source: str, context: dict[str, object]) -> str:
35
+ missing: set[str] = set()
36
+
37
+ def replace(match: re.Match[str]) -> str:
38
+ key = match.group(1)
39
+ if key not in context:
40
+ missing.add(key)
41
+ return match.group(0)
42
+ value = context[key]
43
+ if isinstance(value, bool):
44
+ return "true" if value else "false"
45
+ return str(value)
46
+
47
+ rendered = TOKEN.sub(replace, source)
48
+ if missing:
49
+ raise MusubiError(f"Variables sin resolver: {', '.join(sorted(missing))}")
50
+ return rendered
51
+
52
+
53
+ def create_project(
54
+ destination: Path,
55
+ name: str,
56
+ profile_name: str,
57
+ domain: str | None = None,
58
+ force: bool = False,
59
+ ) -> list[Path]:
60
+ if destination.exists() and any(destination.iterdir()) and not force:
61
+ raise MusubiError(f"El destino no está vacío: {destination}")
62
+ destination.mkdir(parents=True, exist_ok=True)
63
+ profile = load_profile(profile_name)
64
+ context = {
65
+ **profile,
66
+ "project_name": name,
67
+ "profile": profile_name,
68
+ "domain": domain or str(profile["default_domain"]),
69
+ }
70
+ template_root = Path(str(files("musubi").joinpath("templates", "project")))
71
+ created: list[Path] = []
72
+ for source in sorted(template_root.rglob("*")):
73
+ if not source.is_file():
74
+ continue
75
+ relative = source.relative_to(template_root)
76
+ target_name = SPECIAL_TEMPLATE_NAMES.get(
77
+ relative.name, relative.name.removesuffix(".tmpl")
78
+ )
79
+ target = destination / relative.with_name(target_name)
80
+ target.parent.mkdir(parents=True, exist_ok=True)
81
+ target.write_text(render_text(source.read_text(), context))
82
+ if target.suffix == ".sh":
83
+ target.chmod(0o755)
84
+ created.append(target)
85
+ return created
86
+
87
+
88
+ @dataclass(frozen=True)
89
+ class Check:
90
+ ok: bool
91
+ message: str
92
+
93
+
94
+ def validate_project(root: Path, strict: bool = False) -> list[Check]:
95
+ required = (
96
+ "compose.yaml",
97
+ ".env.example",
98
+ "caddy/Caddyfile",
99
+ "zato/enmasse/enmasse.yaml",
100
+ "zato/services/health.py",
101
+ )
102
+ checks = [Check((root / item).is_file(), f"archivo {item}") for item in required]
103
+ compose = (root / "compose.yaml")
104
+ if compose.is_file():
105
+ text = compose.read_text()
106
+ checks.append(Check("zatosource/zato-4.1" in text, "imagen base Zato 4.1"))
107
+ checks.append(Check("{{" not in text, "sin variables de plantilla pendientes"))
108
+ env_file = root / ".env.example"
109
+ if env_file.is_file():
110
+ env_text = env_file.read_text()
111
+ checks.append(Check("CHANGE_ME" in env_text, "secretos marcados para reemplazo"))
112
+ if strict:
113
+ image_line = next((line for line in env_text.splitlines() if line.startswith("ZATO_IMAGE=")), "")
114
+ checks.append(Check("@sha256:" in image_line, "imagen fijada por digest"))
115
+ return checks
116
+
117
+
118
+ def doctor(root: Path) -> list[Check]:
119
+ return [
120
+ Check(shutil.which("docker") is not None, "Docker disponible"),
121
+ Check(shutil.which("git") is not None, "Git disponible"),
122
+ *validate_project(root),
123
+ ]
@@ -0,0 +1,11 @@
1
+ description = "Desarrollo local con puertos visibles y logs detallados"
2
+ environment = "Development"
3
+ default_domain = "localhost"
4
+ zato_image = "zatosource/zato-4.1:latest"
5
+ zato_port = 17010
6
+ caddy_http_port = 8080
7
+ caddy_https_port = 8443
8
+ replicas = 1
9
+ log_level = "DEBUG"
10
+ tls_mode = "internal"
11
+ audit_log = true
@@ -0,0 +1,11 @@
1
+ description = "Producción con TLS, auditoría y política de imagen inmutable"
2
+ environment = "Production"
3
+ default_domain = "api.example.com"
4
+ zato_image = "zatosource/zato-4.1:latest"
5
+ zato_port = 17010
6
+ caddy_http_port = 80
7
+ caddy_https_port = 443
8
+ replicas = 2
9
+ log_level = "INFO"
10
+ tls_mode = "{$CADDY_EMAIL}"
11
+ audit_log = true
@@ -0,0 +1,11 @@
1
+ description = "Preproducción semejante a producción y TLS automático"
2
+ environment = "Staging"
3
+ default_domain = "stage.example.com"
4
+ zato_image = "zatosource/zato-4.1:latest"
5
+ zato_port = 17010
6
+ caddy_http_port = 80
7
+ caddy_https_port = 443
8
+ replicas = 1
9
+ log_level = "INFO"
10
+ tls_mode = "{$CADDY_EMAIL}"
11
+ audit_log = true
@@ -0,0 +1,20 @@
1
+ # {{ project_name }}
2
+
3
+ Proyecto Musubi para Zato 4.1, generado con el perfil `{{ profile }}`.
4
+
5
+ ```bash
6
+ cp .env.example .env
7
+ # Reemplaza todos los valores CHANGE_ME antes de continuar.
8
+ docker compose config --quiet
9
+ docker compose up -d
10
+ docker compose ps
11
+ ```
12
+
13
+ Endpoint público: `https://{{ domain }}/musubi/health`.
14
+
15
+ Antes de un despliegue de producción:
16
+
17
+ 1. Fija `ZATO_IMAGE` con digest (`imagen@sha256:...`).
18
+ 2. Exporta Enmasse y prueba su restauración.
19
+ 3. Guarda secretos fuera del repositorio.
20
+ 4. Verifica TLS, logs, auditoría y rollback.
@@ -0,0 +1,23 @@
1
+ {
2
+ email {$CADDY_EMAIL}
3
+ admin off
4
+ }
5
+
6
+ {{ domain }} {
7
+ tls {{ tls_mode }}
8
+ encode zstd gzip
9
+
10
+ header {
11
+ Strict-Transport-Security "max-age=31536000; includeSubDomains"
12
+ X-Content-Type-Options "nosniff"
13
+ X-Frame-Options "DENY"
14
+ Referrer-Policy "strict-origin-when-cross-origin"
15
+ -Server
16
+ }
17
+
18
+ reverse_proxy zato:{{ zato_port }}
19
+ log {
20
+ output stdout
21
+ format json
22
+ }
23
+ }
@@ -0,0 +1,60 @@
1
+ name: {{ project_name }}
2
+
3
+ services:
4
+ zato:
5
+ image: ${ZATO_IMAGE:-{{ zato_image }}}
6
+ restart: unless-stopped
7
+ env_file: .env
8
+ environment:
9
+ Zato_Environment: {{ environment }}
10
+ Zato_Log_Level: {{ log_level }}
11
+ Zato_Project_Root: /opt/zato/project
12
+ Zato_Secret_Key: ${ZATO_SECRET_KEY:?ZATO_SECRET_KEY is required}
13
+ volumes:
14
+ - ./zato/enmasse:/opt/zato/project/enmasse:ro
15
+ - ./zato/services:/opt/zato/project/services:ro
16
+ - zato-data:/opt/zato/data
17
+ - ./logs:/opt/zato/logs
18
+ expose:
19
+ - "{{ zato_port }}"
20
+ healthcheck:
21
+ test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:{{ zato_port }}/zato/ping || exit 1"]
22
+ interval: 30s
23
+ timeout: 5s
24
+ retries: 5
25
+ start_period: 60s
26
+ deploy:
27
+ replicas: {{ replicas }}
28
+ networks: [integration]
29
+ security_opt:
30
+ - no-new-privileges:true
31
+
32
+ caddy:
33
+ image: caddy:2-alpine
34
+ restart: unless-stopped
35
+ depends_on:
36
+ zato:
37
+ condition: service_healthy
38
+ environment:
39
+ PUBLIC_DOMAIN: ${PUBLIC_DOMAIN:-{{ domain }}}
40
+ CADDY_EMAIL: ${CADDY_EMAIL:-ops@example.com}
41
+ ports:
42
+ - "{{ caddy_http_port }}:80"
43
+ - "{{ caddy_https_port }}:443"
44
+ - "{{ caddy_https_port }}:443/udp"
45
+ volumes:
46
+ - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
47
+ - caddy-data:/data
48
+ - caddy-config:/config
49
+ networks: [integration]
50
+ security_opt:
51
+ - no-new-privileges:true
52
+
53
+ networks:
54
+ integration:
55
+ driver: bridge
56
+
57
+ volumes:
58
+ zato-data:
59
+ caddy-data:
60
+ caddy-config:
@@ -0,0 +1,7 @@
1
+ COMPOSE_PROJECT_NAME={{ project_name }}
2
+ MUSUBI_PROFILE={{ profile }}
3
+ ZATO_IMAGE={{ zato_image }}
4
+ ZATO_SECRET_KEY=CHANGE_ME_WITH_AT_LEAST_32_RANDOM_CHARACTERS
5
+ ZATO_ADMIN_PASSWORD=CHANGE_ME
6
+ PUBLIC_DOMAIN={{ domain }}
7
+ CADDY_EMAIL=ops@example.com
@@ -0,0 +1,8 @@
1
+ .env
2
+ data/
3
+ logs/
4
+ backups/
5
+ .DS_Store
6
+ .idea/
7
+ *.iml
8
+ __pycache__/
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env sh
2
+ set -eu
3
+
4
+ backup_dir=${1:-./backups}
5
+ timestamp=$(date -u +%Y%m%dT%H%M%SZ)
6
+ mkdir -p "$backup_dir"
7
+ docker compose exec -T zato zato enmasse --export --path /tmp/enmasse-export.yaml
8
+ docker compose cp zato:/tmp/enmasse-export.yaml "$backup_dir/enmasse-$timestamp.yaml"
9
+ echo "Backup written to $backup_dir/enmasse-$timestamp.yaml"
@@ -0,0 +1,13 @@
1
+ zato: 3.0
2
+
3
+ security:
4
+ - name: musubi-health-apikey
5
+ type: apikey
6
+ username: musubi-health
7
+
8
+ channel_rest:
9
+ - name: musubi-health
10
+ url_path: /musubi/health
11
+ service: musubi.health
12
+ security: musubi-health-apikey
13
+ active: true
@@ -0,0 +1,15 @@
1
+ from zato.server.service import Service
2
+
3
+
4
+ class Health(Service):
5
+ """Minimal liveness endpoint generated by Musubi."""
6
+
7
+ name = "musubi.health"
8
+
9
+ def handle(self):
10
+ self.response.payload = {
11
+ "status": "ok",
12
+ "framework": "musubi",
13
+ "profile": "{{ profile }}",
14
+ "zato": "4.1",
15
+ }
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: musubi-framework
3
+ Version: 0.1.0
4
+ Summary: Framework for converging systems, APIs and AI on Zato 4.1
5
+ Author: MangroveX
6
+ Keywords: zato,integration,api,ai,devops
7
+ Classifier: Development Status :: 2 - Pre-Alpha
8
+ Classifier: Environment :: Console
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Musubi
15
+
16
+ ![Musubi](assets/brand/musubi-mark.png)
17
+
18
+ **Musubi** (結び) significa “nudo” o “unión”: sistemas, APIs e IA distintos
19
+ confluyen en un solo punto, se conectan de forma explícita y conservan su
20
+ identidad. El framework ofrece un punto de partida reproducible para proyectos
21
+ de integración sobre **Zato 4.1**.
22
+
23
+ ## Inicio rápido
24
+
25
+ ```bash
26
+ python -m pip install -e .
27
+ musubi profiles
28
+ musubi init pagos --profile dev --output ./pagos
29
+ musubi validate ./pagos
30
+ cd pagos && cp .env.example .env && docker compose up -d
31
+ ```
32
+
33
+ ## Qué incluye
34
+
35
+ - CLI sin dependencias de ejecución: `init`, `profiles`, `validate` y `doctor`.
36
+ - Plantilla Docker Compose con Zato 4.1 y Caddy.
37
+ - Configuración Enmasse y servicio inicial de salud.
38
+ - Perfiles `dev`, `stage` y `prod` con políticas progresivas.
39
+ - Sitio estático de presentación en `site/` y workflow de GitHub Pages.
40
+ - CI para Python 3.11/3.12, render de los tres perfiles y validación del sitio.
41
+
42
+ ## Perfiles
43
+
44
+ | Perfil | Uso | TLS | Réplicas | Política de imagen |
45
+ |---|---|---:|---:|---|
46
+ | `dev` | desarrollo local | interno | 1 | etiqueta Zato 4.1 |
47
+ | `stage` | preproducción | automático | 1 | etiqueta configurable |
48
+ | `prod` | producción | automático | 2 | digest obligatorio con `--strict` |
49
+
50
+ Las plantillas fijan `zatosource/zato-4.1:latest` como valor inicial. En
51
+ producción debe reemplazarse por una referencia inmutable con digest.
52
+
53
+ ## Estado
54
+
55
+ Estructura inicial `0.1.0`. La licencia aún debe ser elegida por el propietario
56
+ antes de publicar el paquete para terceros.
@@ -0,0 +1,24 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/musubi/__init__.py
4
+ src/musubi/__main__.py
5
+ src/musubi/cli.py
6
+ src/musubi/core.py
7
+ src/musubi/profiles/dev.toml
8
+ src/musubi/profiles/prod.toml
9
+ src/musubi/profiles/stage.toml
10
+ src/musubi/templates/project/README.md.tmpl
11
+ src/musubi/templates/project/compose.yaml.tmpl
12
+ src/musubi/templates/project/dot-env.example.tmpl
13
+ src/musubi/templates/project/dot-gitignore.tmpl
14
+ src/musubi/templates/project/caddy/Caddyfile.tmpl
15
+ src/musubi/templates/project/scripts/backup.sh.tmpl
16
+ src/musubi/templates/project/zato/enmasse/enmasse.yaml.tmpl
17
+ src/musubi/templates/project/zato/services/health.py.tmpl
18
+ src/musubi_framework.egg-info/PKG-INFO
19
+ src/musubi_framework.egg-info/SOURCES.txt
20
+ src/musubi_framework.egg-info/dependency_links.txt
21
+ src/musubi_framework.egg-info/entry_points.txt
22
+ src/musubi_framework.egg-info/top_level.txt
23
+ tests/test_cli.py
24
+ tests/test_core.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ musubi = musubi.cli:main
@@ -0,0 +1,22 @@
1
+ from contextlib import redirect_stdout
2
+ from io import StringIO
3
+ from pathlib import Path
4
+ from tempfile import TemporaryDirectory
5
+ from unittest import TestCase
6
+
7
+ from musubi.cli import run
8
+
9
+
10
+ class CliTests(TestCase):
11
+ def test_profiles(self):
12
+ output = StringIO()
13
+ with redirect_stdout(output):
14
+ code = run(["profiles"])
15
+ self.assertEqual(code, 0)
16
+ self.assertIn("prod", output.getvalue())
17
+
18
+ def test_init_and_validate(self):
19
+ with TemporaryDirectory() as directory:
20
+ target = Path(directory) / "demo"
21
+ self.assertEqual(run(["init", "demo", "--output", str(target)]), 0)
22
+ self.assertEqual(run(["validate", str(target)]), 0)
@@ -0,0 +1,32 @@
1
+ from pathlib import Path
2
+ from tempfile import TemporaryDirectory
3
+ from unittest import TestCase
4
+
5
+ from musubi.core import PROFILES, create_project, load_profile, validate_project
6
+
7
+
8
+ class ProfileTests(TestCase):
9
+ def test_all_profiles_target_zato_41(self):
10
+ for name in PROFILES:
11
+ profile = load_profile(name)
12
+ self.assertIn("zatosource/zato-4.1", profile["zato_image"])
13
+
14
+
15
+ class ProjectTests(TestCase):
16
+ def test_renders_each_profile(self):
17
+ for profile in PROFILES:
18
+ with self.subTest(profile=profile), TemporaryDirectory() as directory:
19
+ root = Path(directory)
20
+ created = create_project(root, "demo", profile)
21
+ self.assertGreaterEqual(len(created), 7)
22
+ self.assertTrue((root / ".env.example").is_file())
23
+ self.assertTrue((root / ".gitignore").is_file())
24
+ checks = validate_project(root)
25
+ self.assertTrue(all(check.ok for check in checks), checks)
26
+
27
+ def test_refuses_non_empty_directory(self):
28
+ with TemporaryDirectory() as directory:
29
+ root = Path(directory)
30
+ (root / "keep.txt").write_text("keep")
31
+ with self.assertRaisesRegex(RuntimeError, "no está vacío"):
32
+ create_project(root, "demo", "dev")