91e75e620b
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Parse OCI image references into (registry, org, name, tag)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def parse_ref(ref: str) -> tuple[str, str, str, str]:
|
|
"""Parse a full or short image reference.
|
|
|
|
Handles:
|
|
ghcr.io/trycua/macos-sequoia-cua:latest → (ghcr.io, trycua, macos-sequoia-cua, latest)
|
|
trycua/cua-xfce:latest → (ghcr.io, trycua, cua-xfce, latest)
|
|
cua-xfce:latest → (ghcr.io, trycua, cua-xfce, latest)
|
|
cua-xfce → (ghcr.io, trycua, cua-xfce, latest)
|
|
"""
|
|
if ":" in ref:
|
|
ref_no_tag, tag = ref.rsplit(":", 1)
|
|
else:
|
|
ref_no_tag, tag = ref, "latest"
|
|
|
|
parts = ref_no_tag.split("/")
|
|
|
|
if len(parts) >= 3:
|
|
registry = parts[0]
|
|
org = parts[1]
|
|
name = "/".join(parts[2:])
|
|
elif len(parts) == 2:
|
|
registry = "ghcr.io"
|
|
org = parts[0]
|
|
name = parts[1]
|
|
else:
|
|
registry = "ghcr.io"
|
|
org = "trycua"
|
|
name = parts[0]
|
|
|
|
# Docker Hub: docker.io → registry-1.docker.io (the actual API host)
|
|
if registry == "docker.io":
|
|
registry = "registry-1.docker.io"
|
|
|
|
return registry, org, name, tag
|