__init__.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. """Docker Compose module."""
  2. import logging
  3. from typing import Annotated
  4. from typer import Argument, Option
  5. from ...core.module import Module
  6. from ...core.module.base_commands import validate_templates
  7. from ...core.registry import registry
  8. from .validate import run_docker_validation
  9. logger = logging.getLogger(__name__)
  10. class ComposeModule(Module):
  11. """Docker Compose module with extended validation."""
  12. name = "compose"
  13. description = "Manage Docker Compose configurations"
  14. def validate( # noqa: PLR0913
  15. self,
  16. template_id: Annotated[
  17. str | None,
  18. Argument(help="Template ID to validate (omit to validate all templates)"),
  19. ] = None,
  20. *,
  21. path: Annotated[
  22. str | None,
  23. Option("--path", help="Path to template directory for validation"),
  24. ] = None,
  25. verbose: Annotated[bool, Option("--verbose", "-v", help="Show detailed validation information")] = False,
  26. semantic: Annotated[
  27. bool,
  28. Option(
  29. "--semantic/--no-semantic",
  30. help="Enable semantic validation (Docker Compose config, YAML structure, etc.)",
  31. ),
  32. ] = True,
  33. docker: Annotated[
  34. bool,
  35. Option(
  36. "--docker/--no-docker",
  37. help="Enable Docker Compose validation using 'docker compose config'",
  38. ),
  39. ] = False,
  40. docker_test_all: Annotated[
  41. bool,
  42. Option(
  43. "--docker-test-all",
  44. help="Test all variable combinations (minimal, maximal, each toggle). Requires --docker",
  45. ),
  46. ] = False,
  47. ) -> None:
  48. """Validate Compose templates."""
  49. validate_templates(self, template_id, path, verbose, semantic)
  50. if docker and (template_id or path):
  51. run_docker_validation(self, template_id, path, docker_test_all, verbose)
  52. registry.register(ComposeModule)