abstract.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """Abstract base class for registries."""
  2. from abc import ABC, abstractmethod
  3. from typing_extensions import Self
  4. class AbstractRegistry(ABC):
  5. """Abstract base class for registries."""
  6. uri: str
  7. async def get_username_password(self) -> tuple[str, str]:
  8. """Get the username and password for the registry.
  9. Returns:
  10. (str, str): The username and password.
  11. """
  12. raise NotImplementedError
  13. @abstractmethod
  14. async def get_repo_uri(self) -> str:
  15. """Get the URI for a repository.
  16. Returns:
  17. str: The URI.
  18. """
  19. raise NotImplementedError
  20. @abstractmethod
  21. async def check_image_exists(self, image_uri: str) -> bool:
  22. """Check if an image exists in the registry.
  23. Arguments:
  24. image_uri (str): The URI of the image.
  25. Returns:
  26. bool: True if the image exists.
  27. """
  28. raise NotImplementedError
  29. @classmethod
  30. @abstractmethod
  31. def from_config(
  32. cls,
  33. config: dict,
  34. ) -> Self:
  35. """Create a registry from a config."""
  36. raise NotImplementedError