Stevedore.Transport behaviour (Stevedore v0.2.0)

Copy Markdown View Source

The seam describing where images live, behind one uniform interface.

A transport instance is a struct (carrying its own config — a registry repository, a layout path, a Store, …) whose module implements this behaviour. The functions in this module dispatch to that module based on the struct, so callers (notably Stevedore.copy/3) work against any transport interchangeably:

Stevedore.Transport.get_manifest(transport, "3.20")

Implementations: Stevedore.Transport.Registry (docker://), Transport.OCILayout (oci:), Transport.Dir (dir:), Transport.Archive (docker-archive:), and Transport.Static.

Spec: containers-transports(5).

Summary

Callbacks

Delete a manifest by tag or digest.

Flush any buffered state (e.g. emit a tar). Called once at the end of a copy.

Fetch a blob by digest.

Fetch a manifest (or index) by tag or digest.

Whether the blob is already present (lets copy skip it).

List tags held by this transport.

Store a blob (the implementation verifies it against digest).

Store raw manifest bytes, optionally tagged as ref. Returns the manifest digest.

Functions

Dispatch finalize/1, or :ok for transports that don't define it.

Dispatch get_manifest/2 to transport's implementation.

Types

fetched()

@type fetched() :: %{
  media_type: String.t(),
  digest: Stevedore.Digest.t(),
  raw: binary(),
  json: map()
}

ref()

@type ref() :: String.t() | Stevedore.Digest.t() | nil

t()

@type t() :: struct()

Callbacks

delete(t, ref)

(optional)
@callback delete(t(), ref()) :: :ok | {:error, term()}

Delete a manifest by tag or digest.

finalize(t)

(optional)
@callback finalize(t()) :: :ok | {:error, term()}

Flush any buffered state (e.g. emit a tar). Called once at the end of a copy.

get_blob(t, t)

@callback get_blob(t(), Stevedore.Digest.t()) :: {:ok, binary()} | {:error, term()}

Fetch a blob by digest.

get_manifest(t, ref)

@callback get_manifest(t(), ref()) :: {:ok, fetched()} | {:error, term()}

Fetch a manifest (or index) by tag or digest.

has_blob?(t, t)

@callback has_blob?(t(), Stevedore.Digest.t()) :: boolean()

Whether the blob is already present (lets copy skip it).

list_tags(t)

(optional)
@callback list_tags(t()) :: {:ok, [String.t()]} | {:error, term()}

List tags held by this transport.

put_blob(t, t, iodata)

@callback put_blob(t(), Stevedore.Digest.t(), iodata()) :: :ok | {:error, term()}

Store a blob (the implementation verifies it against digest).

put_manifest(t, ref, raw, media_type)

@callback put_manifest(t(), ref(), raw :: binary(), media_type :: String.t()) ::
  {:ok, Stevedore.Digest.t()} | {:error, term()}

Store raw manifest bytes, optionally tagged as ref. Returns the manifest digest.

Functions

delete(t, ref)

@spec delete(t(), ref()) :: :ok | {:error, term()}

Dispatch delete/2.

finalize(t)

@spec finalize(t()) :: :ok | {:error, term()}

Dispatch finalize/1, or :ok for transports that don't define it.

get_blob(t, digest)

@spec get_blob(t(), Stevedore.Digest.t()) :: {:ok, binary()} | {:error, term()}

Dispatch get_blob/2.

get_manifest(t, ref)

@spec get_manifest(t(), ref()) :: {:ok, fetched()} | {:error, term()}

Dispatch get_manifest/2 to transport's implementation.

has_blob?(t, digest)

@spec has_blob?(t(), Stevedore.Digest.t()) :: boolean()

Dispatch has_blob?/2.

list_tags(t)

@spec list_tags(t()) :: {:ok, [String.t()]} | {:error, term()}

Dispatch list_tags/1.

put_blob(t, digest, data)

@spec put_blob(t(), Stevedore.Digest.t(), iodata()) :: :ok | {:error, term()}

Dispatch put_blob/3.

put_manifest(t, ref, raw, media_type)

@spec put_manifest(t(), ref(), binary(), String.t()) ::
  {:ok, Stevedore.Digest.t()} | {:error, term()}

Dispatch put_manifest/4.