import click


def detect_config_version(config):
    """Return version of an slo-generator config based on the format.

    Args:
        config (dict): slo-generator configuration.

    Returns:
        str: SLO config version.
    """
    if not isinstance(config, dict):
        click.secho(
            'Config does not correspond to any known SLO config versions.',
            fg='red')
        return None
    api_version = config.get('apiVersion', '')
    kind = config.get('kind', '')
    if not kind:  # old v1 format
        return 'v1'
    return api_version.split('/')[-1]