"""Config service cons"""
from typing import Literal
from azure.identity import DefaultAzureCredential
from savcfg.keyvault import KeyVaultReader
from .read import ConfigService


def get_savia_config_service(env: Literal['prod', 'pre', 'devel'], app_name: str) -> ConfigService:
    """Construct the config service for
    """
    readers = []
    credential = DefaultAzureCredential()
    match env:
        case 'prod':
            readers = [  KeyVaultReader('savia-production', credential),
                         KeyVaultReader('savia-common', credential)]
        case 'pre':
            readers = [  KeyVaultReader('savia-preproduction', credential),
                         KeyVaultReader('savia-common', credential)]
        case 'devel':
            readers = [KeyVaultReader('savia-development', credential)]


    return ConfigService(app_name, *readers)
