def download_cluster_init()

in bicep/files-to-load/create_cc_param.py [0:0]


def download_cluster_init(outputs, root_folder, locker) -> typing.List[ClusterInitSpec]:
    ret = []
    for record in (outputs['clusterInitSpecs'].get("value") or []):
        url = _strip_tags_from_github_url(record)
        url_hash = hashlib.sha256(url.encode())
        
        folder = os.path.join(root_folder, url_hash.hexdigest())
        if not os.path.exists(folder):
            # download and move to avoid repeated failures with partial downloads/uploads
            check_output(["/usr/local/bin/cyclecloud", "project", "fetch", url, folder + ".tmp"])
            check_output(["/usr/local/bin/cyclecloud", "project", "upload", locker], cwd=folder + ".tmp")
            shutil.move(folder + ".tmp", folder)
            with open(os.path.join(folder, "download-url"), "w") as fw:
                fw.write(url)
        proj_info_raw = check_output(["/usr/local/bin/cyclecloud", "project", "info"], cwd=folder).decode()
        proj_info = {}
        for line in proj_info_raw.splitlines():
            key, rest = line.split(":", 1)
            proj_info[key.lower()] = rest.strip()
        ret.append(ClusterInitSpec(proj_info["name"],
                                   proj_info["version"],
                                   record.get("spec") or "default",
                                   record["target"]))
    return ret