Example #1
0
def sync_with_auto_publish(repo_id, overrides=None):
    """
    Sync a repository and upon successful completion, publish
    any distributors that are configured for auto publish.

    :param repo_id: id of the repository to create a sync call request list for
    :type repo_id: str
    :param overrides: dictionary of configuration overrides for this sync
    :type overrides: dict or None
    :return: A task result containing the details of the task executed and any spawned tasks
    :rtype: TaskResult
    """
    sync_result = managers.repo_sync_manager().sync(repo_id, sync_config_override=overrides)

    result = TaskResult(sync_result)

    repo_publish_manager = managers.repo_publish_manager()
    auto_distributors = repo_publish_manager.auto_distributors(repo_id)

    spawned_tasks = []
    for distributor in auto_distributors:
        distributor_id = distributor['id']
        spawned_tasks.append(publish(repo_id, distributor_id))

    result.spawned_tasks = spawned_tasks

    return result