from pathlib import Path

from harbor.constants import DEFAULT_REGISTRY_URL
from harbor.registry.client.base import BaseRegistryClient
from harbor.registry.client.harbor.harbor import HarborRegistryClient
from harbor.registry.client.json import JsonRegistryClient


class RegistryClientFactory:
    @staticmethod
    def create(
        registry_url: str | None = None,
        registry_path: Path | None = None,
    ) -> BaseRegistryClient:
        if registry_path is not None:
            return JsonRegistryClient(path=registry_path)
        elif registry_url is not None:
            if registry_url == DEFAULT_REGISTRY_URL:
                return HarborRegistryClient()
            return JsonRegistryClient(url=registry_url)
        else:
            return HarborRegistryClient()
