Stevedore.Config (Stevedore v0.1.0)

Copy Markdown View Source

A parsed OCI image configuration.

The config carries the runtime defaults (entrypoint, cmd, env, user, working dir, labels), the target os/architecture, and the rootfs.diff_ids — the digests of each layer's uncompressed tar, which are distinct from the (compressed) layer descriptor digests in the manifest. The decoded json and raw bytes are retained for digest-stable re-emission.

Spec: OCI image-spec, config.

Summary

Functions

Parses raw image-config bytes.

Types

t()

@type t() :: %Stevedore.Config{
  architecture: String.t() | nil,
  cmd: [String.t()] | nil,
  entrypoint: [String.t()] | nil,
  env: [String.t()] | nil,
  history: [map()] | nil,
  json: map(),
  labels: %{optional(String.t()) => String.t()} | nil,
  os: String.t() | nil,
  raw: binary(),
  rootfs_diff_ids: [Stevedore.Digest.t()],
  user: String.t() | nil,
  working_dir: String.t() | nil
}

Functions

parse(raw)

@spec parse(binary()) :: {:ok, t()} | {:error, {:bad_input, term()}}

Parses raw image-config bytes.

Examples

iex> raw = ~s({"architecture":"amd64","os":"linux",
...>   "config":{"Entrypoint":["/bin/sh"],"Env":["PATH=/bin"]},
...>   "rootfs":{"type":"layers","diff_ids":["sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"]}})
iex> {:ok, config} = Stevedore.Config.parse(raw)
iex> {config.architecture, config.entrypoint, hd(config.rootfs_diff_ids).algorithm}
{"amd64", ["/bin/sh"], :sha256}