def create_git_config_synchronizer()

in config_operator/config_operator/main.py [0:0]


def create_git_config_synchronizer(spec, namespace):
    if 'git-url' not in spec.keys():
        raise kopf.HandlerFatalError(f"git-url must be set.")
    if 'config-map' not in spec.keys():
        raise kopf.HandlerFatalError(f"config-map must be set.")

    git_url = spec['git-url']
    logger.info(f'git-url = {git_url}')
    config_map = spec['config-map']
    logger.info(f'config-map = {config_map}')

    _kwargs = {}
    for k in {'git-branch', 'git-username', 'git-token', UPDATE_EVERY_SECOND_PROPERTY}:
        if k in spec:
            logger.info(f'{k} = {spec[k]}')
            _kwargs[k.replace('-', '_')] = spec[k]

    config = RemoteGitConfig(git_url, **_kwargs)

    config_map = K8sConfigMap(config_map, namespace, config)

    asyncio.run(config.when_updated(config_map.publish))

    msg = f"configmap {config_map} created from git repo {git_url}"

    return msg