def check_url_mounts()

in utils/preflight_check.py [0:0]


def check_url_mounts():
    text = dedent(
        f"""
        {term.yellow_underline("URL Mounts")}

        Check that mounted URLs, such as pretrained models are valid.
        """
    )
    print(text)

    has_bad_url = False
    has_mounts = False
    for task_name, task in load_taskgraph().items():
        mounts = task.get("task", {}).get("payload", {}).get("mounts", [])

        # Only keep mounts that are external URLs.
        mounts = [
            mount
            for mount in mounts
            if (
                # This could be a cache mount.
                "content" in mount
                # This is an internal URL.
                and not mount["content"]["url"].startswith(
                    "https://firefox-ci-tc.services.mozilla.com"
                )
            )
        ]

        if len(mounts) == 0:
            continue

        has_mounts = True
        print(term.cyan_bold_underline(f'Mounts for "{task_name}"'))

        for mount in mounts:
            if "content" not in mount:
                continue

            url: str = mount["content"]["url"]

            if url.startswith("https://firefox-ci-tc.services.mozilla.com"):
                # This is an internal URL.
                continue

            if is_url_ok(url):
                print(term.green("✓"), term.gray(url))
            else:
                print(term.red(f"❌ {url}"))
                has_bad_url = True

    if not has_mounts:
        print(term.gray("No mounts presents"))

    if has_bad_url:
        sys.exit(1)