Whether the Docker Hub repository for `name` is public (tri-state). Reads repository metadata (`is_private`) via the Hub API rather than the registry, which both avoids the registry's anonymous pull-rate limit (see `mz_image_tag_exists`) and is tag-independent. A 404 means the repo is
(name: str)
| 449 | |
| 450 | |
| 451 | def is_docker_image_public(name: str) -> bool | None: |
| 452 | """Whether the Docker Hub repository for `name` is public (tri-state). |
| 453 | |
| 454 | Reads repository metadata (`is_private`) via the Hub API rather than the |
| 455 | registry, which both avoids the registry's anonymous pull-rate limit (see |
| 456 | `mz_image_tag_exists`) and is tag-independent. A 404 means the repo is |
| 457 | private or absent; transient errors yield None rather than a false "private". |
| 458 | """ |
| 459 | repo = name.rsplit(":", 1)[0] |
| 460 | response = _get_with_retries(f"https://hub.docker.com/v2/repositories/{repo}/") |
| 461 | if response is None: |
| 462 | return None |
| 463 | if response.status_code == 404: |
| 464 | return False |
| 465 | if response.status_code != 200: |
| 466 | return None |
| 467 | body = _json_dict_or_none(response) |
| 468 | return None if body is None else not body.get("is_private", True) |
| 469 | |
| 470 | |
| 471 | def is_ghcr_image_public(name: str) -> bool | None: |
no test coverage detected