# orca.registry

> A module of morca's API.

Which architectures a container image has (#267): the pool autoscaler makes a machine only of a type the worker image runs on.

var r = Registry.from_env()
    r.arches("ghcr.io/magmalake/orca:e82807b")   # ["amd64", "arm64"]

An image's tag names a manifest; a multi-architecture image's is an index
(OCI) or a manifest list (Docker), whose entries each name a platform, and
a single-architecture image's has its architecture in its config blob.
This reads the registry's v2 API with a pull token: anonymous, or from
`ORCA_REGISTRY_USER` and the secret `ORCA_REGISTRY_TOKEN_SECRET` names
(`orca.control.fetch_secret`) for a private image, never in an error.
`ORCA_REGISTRY_ENDPOINT` points every image's registry at one URL, for
tests' fake.

## Structs

### `ImageRef`

```mojo
struct ImageRef
```

`host/repo:tag` taken apart.

Implements: `Copyable`, `Movable`

Fields:

- `host: String`
- `repo: String`
- `tag: String`

#### `parse`

```mojo
def parse(image: String) -> Self
```

`ghcr.io/magmalake/orca:tag` (a tag is needed; a host too).

### `Registry`

```mojo
struct Registry
```

Implements: `Movable`

Fields:

- `endpoint: String`: Every registry at this URL (tests), or empty for `https://<host>`.
- `user: String`

#### `__init__`

```mojo
def __init__(out self, endpoint: String, user: String, token: String)
```

#### `from_env`

```mojo
def from_env() -> Self
```

#### `has_credentials`

```mojo
def has_credentials(self) -> Bool
```

#### `credentials`

```mojo
def credentials(self) -> Tuple[String, String]
```

The user and token to log in to pull the image (the pool machines' boot, `orca.pool_boot`); empty for none.

#### `arches`

```mojo
def arches(self, image: String) -> List[String]
```

The Linux architectures `image` has a variant for, Docker's names (`amd64`, `arm64`).

## Functions

### `platform_arches`

```mojo
def platform_arches(manifest: Value) -> List[String]
```

The architectures of an index's or manifest list's entries for Linux, without attestation entries (`unknown`), in order; empty for a single-architecture manifest.
