feat(appctl): promote engine v2 to authoritative appctl_engine and complete Milestone P3
- Promote scripts/appctl_engine_v2.py to authoritative scripts/appctl_engine.py - Add full two-axis inspection, Homepage synchronization, and schema v1.0 support - Convert scripts/appctl_engine_v2.py into a backward-compatibility shim - Rename tests/unit/test_appctl_engine_v2.py to test_appctl_engine.py and remove xfail marker - Update README.md, docs/appctl.md, and docs/architecture.md to reference appctl_engine - Synchronize todo.txt and mark Milestone P3 as completed in ROADMAP.md
This commit is contained in:
1 parent
c78550abea
commit
f0e0fc41a1
8 files changed
+709
-1070
No files matched your search
@@ -82,7 +82,7 @@ To maintain clarity during development, this repository explicitly separates wha
|
||||
| :--- | :--- | :--- |
|
||||
| **`appctl` Architecture** | Bash CLI wrapper (`scripts/appctl`) driving local subprocesses (`docker compose`, `git`) and metadata engines. | Dedicated daemon service (`homelab-appctl.service`) exposing one logical API over Unix socket and HTTP. |
|
||||
| **Operational Auth** | Sudo / Unix user permissions on the host. Sourcing secrets from `/run/secrets/`. | LLDAP directory identity. Explicit user-scoped API tokens for all mutating actions; Authelia ForwardAuth for Web. |
|
||||
| **Metadata Engine** | Strongly-typed dataclass engine (`scripts/appctl_engine_v2.py`) with source provenance and Docker label inspection, operating alongside legacy engine. | Single unified engine (`core_manifest.py` / `appctl_engine.py`) embedded directly within the control plane daemon. |
|
||||
| **Metadata Engine** | Authoritative dataclass engine (`scripts/appctl_engine.py`) with two-axis inspection and schema v1.0 parser (`core_manifest.py`). | Single unified engine (`core_manifest.py` / `appctl_engine.py`) embedded directly within the control plane daemon. |
|
||||
| **Deployment Model** | Manual authoring of `app.yaml` and `docker-compose.yml` directly in `~/Sites/<app>/`. | 5-stage lifecycle: AI/human `DeploymentProposal` $\to$ operator-approved `DeploymentModel` committed to Git $\to$ `appctl` materialization. |
|
||||
| **GitOps Engine** | Webhook dispatcher (`scripts/gitops_dispatcher.py`) listening on port 9000 with HMAC-SHA256 authentication and flock serialization. | Fully integrated into control-plane admission, calling central reconciliation endpoints. |
|
||||
| **Secret Distribution** | Static Age-encrypted `nixos/secrets.yaml` decrypted by `sops-nix` to tmpfs `/run/secrets/`. | Host secrets remain in `sops-nix`; workload secrets referenced by key and projected at runtime via `SecretProvider`. |
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ It describes the implementation trajectory and phased engineering milestones for
|
||||
---
|
||||
|
||||
### Milestone P3: Manifest Contract Convergence & Provenance Engine
|
||||
**Status**: 🎯 **Current / Up Next**
|
||||
**Status**: ✅ **Completed**
|
||||
* **Objective**: Establish a single authoritative manifest schema and two-axis inspection engine across the platform.
|
||||
* **Key Deliverables**:
|
||||
1. *Schema v1.0 & Parser Library (`core_manifest.py`)*: Strongly-typed manifest parsing, transport scheme validation (`https://`, `ssh://`, `git@`), and explicit ref semantics (moving branches vs. pinned tags vs. commit SHAs).
|
||||
@@ -87,7 +87,7 @@ It describes the implementation trajectory and phased engineering milestones for
|
||||
---
|
||||
|
||||
### Milestone P4: Appctl Control Plane Daemon & Command-Oriented API
|
||||
**Status**: ⏳ **Planned**
|
||||
**Status**: 🎯 **Current / Up Next**
|
||||
* **Objective**: Evolve `appctl` from a collection of local shell scripts into the authoritative platform daemon.
|
||||
* **Key Deliverables**:
|
||||
1. *Daemon Service (`homelab-appctl.service`)*: Systemd daemon exposing one logical API across dual transports: Unix domain socket (`/run/homelab/appctl.sock`) on host and HTTP listener for network clients.
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
The `appctl` tool is the command-line orchestrator and metadata engine for the **Homelab Core** platform. It coordinates interactions between independent workload repositories in `~/Sites` and platform services in `~/Core`.
|
||||
|
||||
> [!NOTE]
|
||||
> **Implementation Reference**: This document serves as the **current implementation manual** for the `appctl` Bash CLI wrapper (`scripts/appctl`), metadata engines (`scripts/appctl_engine.py` / `scripts/appctl_engine_v2.py`), and currently consumed `app.yaml` manifest fields.
|
||||
> **Implementation Reference**: This document serves as the **current implementation manual** for the `appctl` Bash CLI wrapper (`scripts/appctl`), metadata engine (`scripts/appctl_engine.py`), and currently consumed `app.yaml` manifest fields.
|
||||
> For the platform's overarching control-plane architecture, 5-stage deployment model lifecycle, and phased engineering roadmap, see [`README.md`](../README.md), [`ROADMAP.md`](../ROADMAP.md), and the [Architecture Decision Index](decisions/README.md).
|
||||
|
||||
---
|
||||
|
||||
@@ -50,7 +50,7 @@ The runtime environment consists of four functional layers:
|
||||
|
||||
### C. Cross-Cutting Orchestration
|
||||
Orchestration coordinates operations across the runtime layers without being a runtime layer itself:
|
||||
* **`appctl` CLI & Metadata Engine (`scripts/appctl`, `scripts/appctl_engine.py`, `scripts/appctl_engine_v2.py`)**: Current CLI implementation coordinating discovery, Docker status inspection, and Homepage compilation across workloads and Core. In the target architecture, this evolves into the centralized operational control plane daemon (`homelab-appctl.service`).
|
||||
* **`appctl` CLI & Metadata Engine (`scripts/appctl`, `scripts/appctl_engine.py`)**: Current CLI implementation coordinating discovery, Docker status inspection, and Homepage compilation across workloads and Core. In the target architecture, this evolves into the centralized operational control plane daemon (`homelab-appctl.service`).
|
||||
* **GitOps Webhook Dispatcher (`scripts/gitops_dispatcher.py`)**: Governed by the `homelab-gitops.service` systemd unit, it receives webhooks on port 9000, enforces admission policies, and dispatches serialized deployment actions for workloads or data repositories.
|
||||
|
||||
---
|
||||
|
||||
+688
-615
File diff suppressed because it is too large.
Load diff
Regular → Executable
+11
-445
@@ -1,450 +1,16 @@
|
||||
import os
|
||||
import subprocess
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
appctl_engine_v2.py - Backward-compatibility shim pointing to appctl_engine.py.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from dataclasses import asdict, dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import yaml
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
# Dynamic Environment Paths
|
||||
CORE_DIR = os.environ.get(
|
||||
"CORE_DIR", os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
)
|
||||
from appctl_engine import *
|
||||
from appctl_engine import main
|
||||
|
||||
SITES_DIR = os.environ.get(
|
||||
"SITES_DIR",
|
||||
os.path.join(os.path.dirname(CORE_DIR), "Sites")
|
||||
if os.path.isdir(os.path.join(os.path.dirname(CORE_DIR), "Sites"))
|
||||
else os.path.expanduser("~/Sites"),
|
||||
)
|
||||
|
||||
|
||||
HOMELAB_DOMAIN = os.environ.get("HOMELAB_DOMAIN") or os.environ.get("DOMAIN", "")
|
||||
|
||||
|
||||
def validate_environment() -> None:
|
||||
"""Ensure mandatory environment configuration is valid before CLI execution."""
|
||||
errors: list[str] = []
|
||||
|
||||
if not HOMELAB_DOMAIN:
|
||||
errors.append(
|
||||
"• Missing 'HOMELAB_DOMAIN' (or 'DOMAIN') environment variable.\n"
|
||||
" Please export it (e.g. export HOMELAB_DOMAIN='roadtotech.me') or set it in your environment file."
|
||||
)
|
||||
|
||||
if not os.path.isdir(CORE_DIR):
|
||||
errors.append(f"• Core directory not found at: {CORE_DIR}")
|
||||
|
||||
if errors:
|
||||
print("❌ Environment Validation Failed:\n", file=sys.stderr)
|
||||
for err in errors:
|
||||
print(f" {err}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
class ManifestError(Exception):
|
||||
pass
|
||||
|
||||
@dataclass
|
||||
class HomepageConfig:
|
||||
title: str
|
||||
group: str = "Applications"
|
||||
icon: str = "default.png"
|
||||
container: str = ""
|
||||
weight: int = 50
|
||||
|
||||
@dataclass
|
||||
class SourceConfig:
|
||||
"""Upstream source provenance descriptor."""
|
||||
type: str = "git" # "git"
|
||||
url: str = "" # e.g., "https://git.roadtotech.me/kiskaadee/bitetrack.git"
|
||||
ref: str = "main" # Branch (e.g. "main"), tag (e.g. "v1.0.0"), or commit SHA
|
||||
|
||||
@dataclass
|
||||
class App:
|
||||
name: str # Canonical identified (e.g., "traefik", "jellyfin")
|
||||
description: str # Human-readable summary for dashboards and CLI info
|
||||
domain: str # Routing FQDN (e.g., "auth.roadtotech.me") or "internal".
|
||||
dir_path: str # Filesystem directory (CORE_DIR for Core, or ~/Sites/<app> for Sites).
|
||||
|
||||
@property
|
||||
def is_internal(self) -> bool:
|
||||
"""Returns True if the service does not expose a public TLS endpoint."""
|
||||
return not self.domain or self.domain == "internal" or self.domain.endswith(".local") or ":" in self.domain
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
"""Serialize for JSON consumption by scripts/appctl"""
|
||||
data = asdict(self)
|
||||
data["type"] = getattr(self, "app_type", "app")
|
||||
return data
|
||||
|
||||
@dataclass
|
||||
class CoreService(App):
|
||||
container: str = "" # Target container name inside Core's root docker-compose.yml (e.g., "authelia", "stalwart")
|
||||
weight: int = 50 # Homepage ordering weight (optional, for dashboard synchronization)
|
||||
icon: str = "default.png" # Dashboard icon filename
|
||||
app_type: str = "core_service"
|
||||
dir_path: str = CORE_DIR
|
||||
|
||||
@dataclass
|
||||
class SitesApp(App):
|
||||
dir_name: str = "" # directory name in ~/Sites (e.g., "homelab-vaultwarden")
|
||||
source: SourceConfig | None = None # Upstream source provenance (optional; None indicates Image-Only workload)
|
||||
aliases: list[str] = field(default_factory=list) # CLI resolution aliases (e.g., "vw", "vaultwarden")
|
||||
visible: bool = True # Defines whether the icon is visible in the Homepage Dashboard
|
||||
auth: bool = True # Authelia protection guard indicator; Defaulting to True is safer
|
||||
has_compose: bool = False # Whether a docker-compose.yaml exists at ~/Sites/dir_name.
|
||||
networks: list[str] = field(default_factory=lambda: ["proxy-net"]) # Docker network attachments (def ["proxy-net"])
|
||||
env: dict[str, Any] = field(default_factory=dict) # Dynamic environment variable overrides
|
||||
homepage: HomepageConfig | None = None # Dashboard Card Configuration
|
||||
manifest_error: str | None = None # Captured syntax/loading errors if app.yaml was malformed/absent
|
||||
app_type: str = "app"
|
||||
|
||||
|
||||
|
||||
def load_manifest(manifest_path: str) -> dict[str, Any]:
|
||||
"""Load and parese the app manifest file
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: if the manifest file does not exist.
|
||||
ValueError: if YAML object is malformed.
|
||||
TypeError: If root is not a directory
|
||||
"""
|
||||
if not os.path.isfile(manifest_path):
|
||||
raise FileNotFoundError(f"Manifest file not found at {manifest_path}")
|
||||
|
||||
try:
|
||||
with open(manifest_path, "r", encoding="utf-8") as file:
|
||||
manifest_data = yaml.safe_load(file) or {}
|
||||
except (yaml.YAMLError, OSError) as err:
|
||||
raise ManifestError(f"YAML parsing failed: {err}") from err
|
||||
|
||||
if not isinstance(manifest_data, dict):
|
||||
raise ManifestError(f"Invalid manifest root: expected `dict`, got `{type(manifest_data).__name__}`")
|
||||
|
||||
return manifest_data
|
||||
|
||||
|
||||
|
||||
def sites_app_from_manifest(
|
||||
|
||||
app_dir: str,
|
||||
manifest: dict[str, Any],
|
||||
manifest_error: str | None = None
|
||||
) -> SitesApp:
|
||||
"""Construct and normalize a SitesApp domain model from raw manifest data."""
|
||||
raw_dir_name = os.path.basename(app_dir)
|
||||
canonical_name = str(manifest.get("name") or raw_dir_name.replace("homelab-", ""))
|
||||
|
||||
# Normalize aliases into list[str]
|
||||
raw_aliases = manifest.get("aliases") or []
|
||||
if isinstance(raw_aliases, str):
|
||||
aliases = [raw_aliases]
|
||||
elif isinstance(raw_aliases, list):
|
||||
aliases = [str(alias) for alias in raw_aliases]
|
||||
else:
|
||||
aliases = []
|
||||
|
||||
# Homepage card normalization
|
||||
homepage_config: HomepageConfig | None = None
|
||||
raw_hp = manifest.get("homepage")
|
||||
if isinstance(raw_hp, dict):
|
||||
homepage_config = HomepageConfig(
|
||||
title=str(raw_hp.get("title") or canonical_name),
|
||||
group=str(raw_hp.get("group") or "Applications"),
|
||||
icon=str(raw_hp.get("icon") or "default.png"),
|
||||
container=str(raw_hp.get("container") or canonical_name),
|
||||
weight=int(raw_hp.get("weight", 50))
|
||||
)
|
||||
has_compose = (
|
||||
os.path.isfile(os.path.join(app_dir, "docker-compose.yaml")) or
|
||||
os.path.isfile(os.path.join(app_dir, "docker-compose.yml"))
|
||||
)
|
||||
|
||||
# Manifest Data parsing
|
||||
raw_desc = manifest.get("description")
|
||||
app_desc: str = str(raw_desc) if raw_desc is not None else ""
|
||||
|
||||
raw_dom = manifest.get("domain")
|
||||
app_dom = str(raw_dom) if raw_dom is not None else f"{canonical_name}.{HOMELAB_DOMAIN}"
|
||||
|
||||
app_net = manifest.get("networks")
|
||||
if not isinstance(app_net, list):
|
||||
app_net = ["proxy-net"]
|
||||
|
||||
app_env = manifest.get("env")
|
||||
if not isinstance(app_env, dict):
|
||||
app_env = {}
|
||||
|
||||
def _as_bool(value: Any, default: bool) -> bool:
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
return default
|
||||
|
||||
app_vis = _as_bool(manifest.get("visible"), True)
|
||||
app_auth = _as_bool(manifest.get("auth"), True)
|
||||
|
||||
# Source provenance normalization
|
||||
source_config: SourceConfig | None = None
|
||||
raw_source = manifest.get("source")
|
||||
if isinstance(raw_source, dict):
|
||||
source_url = str(raw_source.get("url") or "")
|
||||
allowed_schemes = ("https://", "ssh://", "git@")
|
||||
if source_url:
|
||||
if not any(source_url.startswith(s) for s in allowed_schemes):
|
||||
err = f"Invalid source.url scheme: must start with {', '.join(allowed_schemes)}"
|
||||
manifest_error = f"{manifest_error}; {err}" if manifest_error else err
|
||||
else:
|
||||
source_config = SourceConfig(
|
||||
type=str(raw_source.get("type") or "git"),
|
||||
url=source_url,
|
||||
ref=str(raw_source.get("ref") or "main"),
|
||||
)
|
||||
|
||||
return SitesApp(
|
||||
name=canonical_name,
|
||||
dir_name=raw_dir_name,
|
||||
source=source_config,
|
||||
description=app_desc,
|
||||
domain=app_dom,
|
||||
dir_path=app_dir,
|
||||
has_compose=has_compose,
|
||||
aliases=aliases,
|
||||
visible=app_vis,
|
||||
auth=app_auth,
|
||||
networks=app_net,
|
||||
env=app_env,
|
||||
homepage=homepage_config,
|
||||
manifest_error=manifest_error,
|
||||
)
|
||||
|
||||
|
||||
|
||||
def get_sites_apps(sites_dir: str | None = None) -> list[SitesApp]:
|
||||
"""
|
||||
Scan the given sites directory (defaulting to SITES_DIR) for application.
|
||||
"""
|
||||
target_dir = sites_dir or SITES_DIR
|
||||
apps: list[SitesApp] = []
|
||||
if not os.path.isdir(target_dir):
|
||||
return apps
|
||||
|
||||
for entry in sorted(os.listdir(target_dir)):
|
||||
app_dir = os.path.join(target_dir, entry)
|
||||
# skip hidden or null directories
|
||||
if entry.startswith(".") or not os.path.isdir(app_dir):
|
||||
continue
|
||||
manifest_path = os.path.join(app_dir, "app.yaml")
|
||||
manifest: dict[str, Any] = {}
|
||||
manifest_error: str | None = None
|
||||
|
||||
if os.path.isfile(manifest_path):
|
||||
try:
|
||||
manifest = load_manifest(manifest_path=manifest_path)
|
||||
except ManifestError as err:
|
||||
manifest_error = str(err)
|
||||
apps.append(sites_app_from_manifest(app_dir, manifest, manifest_error))
|
||||
|
||||
return apps
|
||||
|
||||
def resolve_app(
|
||||
query: str,
|
||||
apps: list[SitesApp] | None = None,
|
||||
sites_dir: str | None = None
|
||||
) -> SitesApp | None:
|
||||
|
||||
if apps is None:
|
||||
apps = get_sites_apps(sites_dir= sites_dir if sites_dir is not None else SITES_DIR)
|
||||
|
||||
query_clean = query.strip().lower()
|
||||
|
||||
# 1. Extract match on canonical name
|
||||
for app in apps:
|
||||
if app.name.lower() == query_clean:
|
||||
return app
|
||||
|
||||
# 2. Match on alias
|
||||
for app in apps:
|
||||
if any(alias.lower() == query_clean for alias in app.aliases):
|
||||
return app
|
||||
|
||||
# 3. Match directory name
|
||||
for app in apps:
|
||||
if app.dir_name.lower() == query_clean:
|
||||
return app
|
||||
# 4. Match stripped 'homelab-' prefix
|
||||
for app in apps:
|
||||
if app.dir_name.lower() == f"homelab-{query_clean}":
|
||||
return app
|
||||
|
||||
return None
|
||||
|
||||
def get_core_services(core_dir: str | None = None) -> list[CoreService]:
|
||||
"""Return the strongly-typed registry of Core platform services."""
|
||||
return [
|
||||
CoreService(
|
||||
name="traefik",
|
||||
domain=f"traefik.{HOMELAB_DOMAIN}",
|
||||
container="traefik",
|
||||
description="Edge Reverse Proxy & ACME TLS",
|
||||
icon="traefik.png",
|
||||
weight=10,
|
||||
),
|
||||
CoreService(
|
||||
name="authelia",
|
||||
domain=f"auth.{HOMELAB_DOMAIN}",
|
||||
container="authelia",
|
||||
description="Identity & SSO Access Control",
|
||||
icon="authelia.png",
|
||||
weight=20,
|
||||
),
|
||||
CoreService(
|
||||
name="lldap",
|
||||
domain=f"users.{HOMELAB_DOMAIN}",
|
||||
container="lldap",
|
||||
description="Lightweight LDAP User Directory",
|
||||
icon="lldap.png",
|
||||
weight=25,
|
||||
),
|
||||
CoreService(
|
||||
name="stalwart",
|
||||
domain=f"smtp.{HOMELAB_DOMAIN}",
|
||||
container="stalwart",
|
||||
description="All-in-one Mail Server",
|
||||
icon="email.png",
|
||||
weight=26,
|
||||
),
|
||||
|
||||
CoreService(
|
||||
name="dozzle",
|
||||
domain=f"logs.{HOMELAB_DOMAIN}",
|
||||
container="dozzle",
|
||||
description="Real-time Log Viewer",
|
||||
icon="dozzle.png",
|
||||
weight=40,
|
||||
),
|
||||
CoreService(
|
||||
name="socket-proxy",
|
||||
domain="internal",
|
||||
container="socket-proxy",
|
||||
description="Docker Socket Security Proxy",
|
||||
),
|
||||
CoreService(
|
||||
name="homepage",
|
||||
domain=f"dashboard.{HOMELAB_DOMAIN}",
|
||||
container="homepage",
|
||||
description="Application Dashboard & System Portal",
|
||||
icon="homepage.png",
|
||||
weight=5,
|
||||
),
|
||||
CoreService(
|
||||
name="diun",
|
||||
domain="internal",
|
||||
container="diun",
|
||||
description="Docker Image Update Notifier",
|
||||
),
|
||||
CoreService(
|
||||
name="watchtower",
|
||||
domain="internal",
|
||||
container="watchtower",
|
||||
description="Automated Container Updates",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def get_docker_status(
|
||||
dir_path: str | Path,
|
||||
container_name: str | None = None,
|
||||
) -> str:
|
||||
"""Get container running status for a docker-compose directory or single Core container."""
|
||||
try:
|
||||
if container_name:
|
||||
inspect_res = subprocess.run(
|
||||
["docker", "inspect", "-f", "{{.State.Running}}", container_name],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
state = inspect_res.stdout.strip()
|
||||
if state.lower() == "true":
|
||||
return "🟢 Running (1)"
|
||||
return "🔴 Stopped"
|
||||
|
||||
path = Path(dir_path)
|
||||
if path.exists() and not (path / "docker-compose.yml").is_file() and not (path / "docker-compose.yaml").is_file():
|
||||
return "⚪ Not Stack"
|
||||
|
||||
res = subprocess.run(
|
||||
["docker", "compose", "ps", "-q"],
|
||||
cwd=str(path),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
container_ids = [c for c in res.stdout.strip().splitlines() if c]
|
||||
if not container_ids:
|
||||
return "🔴 Stopped"
|
||||
|
||||
inspect_res = subprocess.run(
|
||||
["docker", "inspect", "-f", "{{.State.Running}}"] + container_ids,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
running_states = inspect_res.stdout.strip().splitlines()
|
||||
running_count = sum(1 for s in running_states if s.lower() == "true")
|
||||
total_count = len(container_ids)
|
||||
|
||||
if running_count == total_count and total_count > 0:
|
||||
return f"🟢 Running ({running_count})"
|
||||
elif running_count > 0:
|
||||
return f"🟡 Degraded ({running_count}/{total_count})"
|
||||
else:
|
||||
return "🔴 Stopped"
|
||||
except (subprocess.SubprocessError, OSError):
|
||||
return "❓ Unknown"
|
||||
|
||||
|
||||
def get_docker_image_revision(
|
||||
dir_path: str | Path | None = None,
|
||||
container_name: str | None = None,
|
||||
) -> str | None:
|
||||
"""Extract `org.opencontainers.image.revision` label from running container."""
|
||||
try:
|
||||
target: str | None = container_name
|
||||
if not target and dir_path:
|
||||
res = subprocess.run(
|
||||
["docker", "compose", "ps", "-q"],
|
||||
cwd=str(dir_path),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
ids = [c for c in res.stdout.strip().splitlines() if c]
|
||||
if ids:
|
||||
target = ids[0]
|
||||
|
||||
if not target:
|
||||
return None
|
||||
|
||||
inspect_res = subprocess.run(
|
||||
[
|
||||
"docker",
|
||||
"inspect",
|
||||
"-f",
|
||||
'{{ index .Config.Labels "org.opencontainers.image.revision" }}',
|
||||
target,
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
revision = inspect_res.stdout.strip()
|
||||
if revision and revision != "<no value>":
|
||||
return revision
|
||||
return None
|
||||
except (subprocess.SubprocessError, OSError):
|
||||
return None
|
||||
|
||||
def cmd_sync_homepage(args) -> None:
|
||||
pass
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -5,11 +5,11 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
# Import appctl engine v2
|
||||
# Import appctl engine
|
||||
CORE_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
sys.path.insert(0, str(CORE_ROOT / "scripts"))
|
||||
|
||||
import appctl_engine_v2 as engine
|
||||
import appctl_engine as engine
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -291,7 +291,7 @@ def test_docker_image_revision_extraction(monkeypatch):
|
||||
monkeypatch.setattr("subprocess.run", mock_run_empty)
|
||||
assert engine.get_docker_image_revision("/fake/dir") is None
|
||||
|
||||
@pytest.mark.xfail(reason="TDD in progress: cmd_sync_homepage not yet implemented")
|
||||
|
||||
def test_homepage_sync_groups_and_sorts_correctly(
|
||||
mock_core_dir: Path,
|
||||
app_factory: AppFactory,
|
||||
@@ -3,5 +3,5 @@ x 2026-10-13 (A) Implement unit tests for core_manifest.py covering valid manife
|
||||
x 2026-10-13 (B) Implement two-axis inspection engine in appctl evaluating local checkout state independently from upstream provenance +provenance @appctl
|
||||
x 2026-10-13 (B) Implement bounded git ls-remote provenance resolver with 10s timeout for appctl status --fetch +provenance @appctl
|
||||
x 2026-10-13 (B) Add unit tests for provenance resolution and timeout handling with mocked network fixtures in tests/unit/test_provenance.py +test @appctl
|
||||
(C) Promote scripts/appctl_engine_v2.py to authoritative scripts/appctl_engine.py +engine @appctl
|
||||
(C) Verify full test suite and update CLI wrappers for appctl v2 engine promotion +test @appctl
|
||||
x 2026-10-13 (C) Promote scripts/appctl_engine_v2.py to authoritative scripts/appctl_engine.py +engine @appctl
|
||||
x 2026-10-13 (C) Verify full test suite and update CLI wrappers for appctl v2 engine promotion +test @appctl
|
||||
Reference in new issue
Block a user