mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-12 13:47:01 +00:00
- Move iter_role_images + all helpers + ImageRef from cli/mirror/util.py and
cli/mirror/model.py into utils/docker/image_discovery.py; add source_file field
to ImageRef to distinguish config/main.yml vs vars/main.yml entries
- Delete cli/mirror/util.py; update all callers to import from utils.docker.image_discovery
- Move utils into subpackages: utils/docker/ (image_ref, paths_utils, hadolint) and
utils/roles/ (dependency_resolver, resource_validation); update all imports
- Reorganise tests into subpackages: tests/lint/docker/dockerfile/, tests/integration/docker/,
tests/unit/utils/docker/, tests/unit/utils/roles/; fix parents[N] offsets after relocation
- tests/lint/docker/test_image_versions.py now uses iter_role_images (same SPOT as mirror)
- Add vars/main.yml images.<name>.{image,version} support for non-application roles
(test-e2e-playwright, sys-ctl-hlth-csp); eliminate hardcoded duplicates in defaults/tasks
- Add web-app-matrix matrix-chatgpt-bot and web-app-mini-qr mini-qr entries in config/main.yml;
replace hardcoded image strings in vars/templates with lookup('config', ...) references
- Fix sync/__main__.py log line to use correct registry prefix for non-Docker-Hub images
- Update docs/contributing/code/role/dockerfile.md with image declaration rules and SPOT reference
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
import unittest
|
|
import yaml
|
|
from pathlib import Path
|
|
|
|
|
|
class TestDockerRoleServicesConfiguration(unittest.TestCase):
|
|
def test_services_keys_and_templates(self):
|
|
"""
|
|
For each web-app-* role, check that:
|
|
- roles/web-app-*/config/main.yml contains 'services' as a dict with keys/values
|
|
"""
|
|
repo_root = Path(__file__).resolve().parent.parent.parent.parent
|
|
roles_dir = repo_root / "roles"
|
|
errors = []
|
|
warnings = []
|
|
|
|
for role_path in roles_dir.iterdir():
|
|
if not (role_path.is_dir() and role_path.name.startswith("web-app-")):
|
|
continue
|
|
|
|
cfg_file = role_path / "config" / "main.yml"
|
|
if not cfg_file.exists():
|
|
continue # No configuration to check
|
|
|
|
try:
|
|
config = yaml.safe_load(cfg_file.read_text("utf-8")) or {}
|
|
main_file = role_path / "vars" / "main.yml"
|
|
yaml.safe_load(main_file.read_text("utf-8")) or {}
|
|
except yaml.YAMLError as e:
|
|
errors.append(f"{role_path.name}: YAML parse error: {e}")
|
|
continue
|
|
|
|
services = config.get("compose", {}).get("services", {})
|
|
if not services:
|
|
warnings.append(
|
|
f"[WARNING] {role_path.name}: No 'compose.services' key in config/main.yml"
|
|
)
|
|
continue
|
|
|
|
if not isinstance(services, dict):
|
|
errors.append(
|
|
f"{role_path.name}: 'services' must be a dict in config/main.yml"
|
|
)
|
|
continue
|
|
if warnings:
|
|
print(
|
|
"\nWarnings in docker role services configuration:\n"
|
|
+ "\n".join(warnings)
|
|
)
|
|
if errors:
|
|
self.fail(
|
|
"Errors in docker role services configuration:\n" + "\n".join(errors)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|