Esempio n. 1
0
def mirror_container_images(topic, component, settings):
    if "registry" in topic["data"]:
        images_list = get_container_images_list(get_base_url(topic, component),
                                                settings)
        skopeo_yaml = dci_images_list_yaml_to_skopeo_format(
            images_list,
            topic["data"]["registry"]["login"],
            topic["data"]["registry"]["password"],
        )
        skopeo_sync(skopeo_yaml, settings["registry"])
Esempio n. 2
0
def download_component(topic, component, settings):
    print("Download component %s" % component["name"])
    base_url = get_base_url(topic, component)
    files_list = get_files_list(base_url, settings)
    if component["type"].lower() == "compose":
        files_list = filter_files_list(files_list, settings)
    download_folder = get_component_folder(settings, component)
    clean_download_folder(files_list, download_folder)
    files_to_download = get_files_to_download(base_url, download_folder, files_list)
    check_download_folder_size(files_to_download, download_folder)
    download_files(files_to_download["files"], settings)
    recreate_symlinks(files_list["symlinks"], download_folder)
    if settings.get("registry", None):
        mirror_container_images(topic, component, settings)
Esempio n. 3
0
def download_component(topic, component, settings, cert, key):
    print("Download component %s" % component["name"])
    base_url = get_base_url(topic, component)
    files_list = get_files_list(base_url, cert, key)
    download_folder = build_download_folder(topic, component,
                                            settings["download_folder"])
    clean_download_folder(files_list, download_folder)
    files_list = filter_files_list(files_list, settings)
    check_download_folder_size(files_list, download_folder)
    files_to_download = get_files_to_download(base_url, download_folder,
                                              files_list)
    nb_files = len(files_to_download)
    for index, file in enumerate(files_to_download):
        print("(%d/%d): %s" % (index, nb_files, file["destination"]))
        create_parent_dir(file["destination"])
        download_file(file, cert, key)
    recreate_symlinks(files_list["symlinks"], download_folder)
Esempio n. 4
0
def test_get_base_url():
    topic = {"id": "t1", "product_id": "p1"}
    component = {"id": "c1"}
    assert get_base_url(topic, component) == "https://repo.distributed-ci.io/p1/t1/c1"