componentized/directory

componentized:oci

interface dev

WASM components for interacting with resources in OCI image repositories.

interface client componentized:oci/client@0.0.0-dev

Types

use record instant

from wasi:clocks/system-clock@0.3.0

An "instant", or "exact time", is a point in time without regard to any time zone: just the time since a particular external reference point, often called an "epoch".

Here, the epoch is 1970-01-01T00:00:00Z, also known as POSIX's Seconds Since the Epoch, also known as Unix Time.

Note that even if the seconds field is negative, incrementing nanoseconds always represents moving forwards in time. For example, { -1 seconds, 999999999 nanoseconds } represents the instant one nanosecond before the epoch. For more on various different ways to represent time, see https://tc39.es/proposal-temporal/docs/timezone.html

  • seconds: s64
  • nanoseconds: u32

variant retry-after

variant error-code

  • blob-unknown: string

    blob unknown to registry (code-1 BLOB_UNKNOWN)

  • blob-upload-invalid: string

    blob upload invalid (code-2 BLOB_UPLOAD_INVALID)

  • blob-upload-unknown: string

    blob upload unknown to registry (code-3BLOB_UPLOAD_UNKNOWN)

  • digest-invalid: string

    provided digest did not match uploaded content (code-4 DIGEST_INVALID)

  • manifest-blob-unknown: string

    manifest references a manifest or blob unknown to registry (code-5 MANIFEST_BLOB_UNKNOWN)

  • manifest-invalid: string

    manifest invalid (code-6 MANIFEST_INVALID)

  • manifest-unknown: string

    manifest unknown to registry (code-7 MANIFEST_UNKNOWN)

  • name-invalid: string

    invalid repository name (code-8 NAME_INVALID)

  • name-unknown: string

    repository name not known to registry (code-9 NAME_UNKNOWN)

  • size-invalid: string

    provided length did not match content length (code-10 SIZE_INVALID)

  • unauthorized: string

    authentication required (code-11 UNAUTHORIZED)

  • denied: string

    requested access to the resource is denied (code-12 DENIED)

  • unsupported: string

    the operation is unsupported (code-13 UNSUPPORTED)

  • toomanyrequests: option<retry-after>

    too many requests (code-14 TOOMANYREQUESTS)

  • other: option<string>

    other

variant schema-version

  • v2
  • other: option<u8>

variant media-type-suffix

  • json

    json encoded

  • gzip

    compressed with gzip

  • zstd

    compressed with zstd

  • other: option<string>

    other encoding

variant media-type

common media types for oci artifacts

record oci-image-index-manifest-v1-manifest-platform

  • architecture: string

    CPU architecture which the binaries in this image are built to run on

  • os: string

    name of the operating system which the image is built to run on

  • os-version: option<string>

    version of the operating system

  • os-features: option<list<string>>

    mandatory OS features

  • variant: option<string>

    variant of the CPU

record oci-image-config-v1-config

  • user: option<string>

    username or UID which is a platform-specific structure that allows specific control over which user the process run as

  • exposed-ports: option<list<string>>

    set of ports to expose from a container running this image

  • env: option<list<string>>

    values act as defaults and are merged with any specified when creating a container

  • entrypoint: option<list<string>>

    arguments to use as the command to execute when the container starts

  • cmd: option<list<string>>

    arguments to the entrypoint of the container

  • volumes: option<list<string>>

    directories describing where the process is likely to write data specific to a container instance

  • working-dir: option<string>

    current working directory of the entrypoint process in the container

  • labels: option<map<string, string>>

    arbitrary metadata for the container

  • stop-signal: option<string>

    system call signal that will be sent to the container to exit

  • args-escaped: option<bool>

    deprecated: present only for legacy compatibility

record oci-image-config-v1-history-entry

  • created: option<instant>

    combined date and time at which the layer was created

  • author: option<string>

    author of the build point

  • created-by: option<string>

    command which created the layer

  • comment: option<string>

    custom message set when creating the layer

  • empty-layer: option<bool>

    mark if the history item created a filesystem diff

record wasm-config-v0-component

  • exports: list<string>
  • imports: list<string>
  • target: option<string>

record digest

  • algorithm: string
  • encoded: string

record oci-descriptor-v1

  • media-type: media-type

    media type of the referenced content

  • digest: digest

    digest of the targeted content

  • size: u64

    size, in bytes, of the raw content

  • urls: option<list<string>>

    list of URIs from which this object MAY be downloaded

  • annotations: option<map<string, string>>

    arbitrary metadata for this descriptor

  • data: option<string>

    embedded representation of the referenced content

  • artifact-type: option<media-type>

    type of an artifact when the descriptor points to an artifact

record oci-image-manifest-v1

  • schema-version: schema-version

    manifest schema version

  • media-type: media-type

    must contain the media type 'application/vnd.oci.image.manifest.v1+json'.

  • artifact-type: option<media-type>

    type of an artifact when the manifest is used for an artifact

  • config: oci-descriptor-v1

    configuration object for a container

  • layers: list<oci-descriptor-v1>

    list of layer descriptors

  • subject: option<oci-descriptor-v1>

    weak association to another manifest

  • annotations: option<map<string, string>>

    arbitrary metadata for the image manifest

record oci-image-index-manifest-v1-manifest

  • media-type: media-type

    media type of the referenced content

  • digest: digest

    digest of the targeted content

  • size: u64

    size, in bytes, of the raw content

  • urls: option<list<string>>

    list of URIs from which this object MAY be downloaded

  • annotations: option<map<string, string>>

    arbitrary metadata for this descriptor

  • data: option<string>

    embedded representation of the referenced content

  • artifact-type: option<media-type>

    type of an artifact when the descriptor points to an artifact

  • platform: option<oci-image-index-manifest-v1-manifest-platform>

    minimum runtime requirements of the image

  • subject: option<oci-descriptor-v1>

    descriptor of another manifest

record oci-image-index-manifest-v1

  • schema-version: schema-version

    manifest schema version

  • media-type: media-type

    must contain the media type 'application/vnd.oci.image.index.v1+json'.

  • artifact-type: option<media-type>

    type of an artifact when the manifest is used for an artifact

  • manifests: list<oci-image-index-manifest-v1-manifest>

    manifests for specific platforms

  • subject: option<oci-descriptor-v1>

    weak association to another manifest

  • annotations: option<map<string, string>>

    arbitrary metadata for the image manifest

variant manifest

record oci-image-config-v1-content-addresses

  • type: string

    must be 'layers'

  • diff-ids: list<digest>

    layer content hashes, in order from first to last

record oci-image-config-v1

  • created: option<instant>

    combined date and time at which the image was created

  • author: option<string>

    name and/or email address of the person or entity which created and is responsible for maintaining the image

  • architecture: string

    CPU architecture which the binaries in this image are built to run on

  • os: string

    name of the operating system which the image is built to run on

  • os-version: option<string>

    version of the operating system

  • os-features: option<list<string>>

    mandatory OS features

  • variant: option<string>

    variant of the specified CPU architecture

  • config: option<oci-image-config-v1-config>

    execution parameters which should be used as a base when running a container using the image

  • rootfs: oci-image-config-v1-content-addresses

    layer content addresses used by the image

  • history: option<list<oci-image-config-v1-history-entry>>

    history of each layer. The array is ordered from first to last

record wasm-config-v0

  • created: option<instant>

    combined date and time at which the image was created

  • author: option<string>

    name and/or email address of the person or entity which created and is responsible for maintaining the image

  • architecture: string

    must match a GOARCH value

  • os: string

    must match a GOOS value

  • layer-digests: list<digest>

    digests of the layers in the same order

  • component: option<wasm-config-v0-component>

    component metadata

variant config

record reference

  • registry: string
  • repository: string
  • tag: option<string>
  • digest: option<digest>

Functions

functionparse-reference: func( reference: string, ) -> result<reference, error-code>

async functionresolve-digest: async func( reference: reference, ) -> result<digest, error-code>

async functionget-blob: async func( reference: reference, ) -> result<list<u8>, error-code>

async functionget-config: async func( reference: reference, default-media-type: option<media-type>, ) -> result<config, error-code>

async functionget-manifest: async func( reference: reference, ) -> result<manifest, error-code>

WIT

interface client {
  use wasi:clocks/system-clock@0.3.0.{instant};

  variant retry-after {
    date(instant),
    delay-seconds(u32),
  }

  variant error-code {
    /// blob unknown to registry (code-1 `BLOB_UNKNOWN`)
    blob-unknown(string),
    /// blob upload invalid (code-2 `BLOB_UPLOAD_INVALID`)
    blob-upload-invalid(string),
    /// blob upload unknown to registry (code-3`BLOB_UPLOAD_UNKNOWN`)
    blob-upload-unknown(string),
    /// provided digest did not match uploaded content (code-4 `DIGEST_INVALID`)
    digest-invalid(string),
    /// manifest references a manifest or blob unknown to registry (code-5 `MANIFEST_BLOB_UNKNOWN`)
    manifest-blob-unknown(string),
    /// manifest invalid (code-6 `MANIFEST_INVALID`)
    manifest-invalid(string),
    /// manifest unknown to registry (code-7 `MANIFEST_UNKNOWN`)
    manifest-unknown(string),
    /// invalid repository name (code-8 `NAME_INVALID`)
    name-invalid(string),
    /// repository name not known to registry (code-9 `NAME_UNKNOWN`)
    name-unknown(string),
    /// provided length did not match content length (code-10 `SIZE_INVALID`)
    size-invalid(string),
    /// authentication required (code-11 `UNAUTHORIZED`)
    unauthorized(string),
    /// requested access to the resource is denied (code-12 `DENIED`)
    denied(string),
    /// the operation is unsupported (code-13 `UNSUPPORTED`)
    unsupported(string),
    /// too many requests (code-14 `TOOMANYREQUESTS`)
    toomanyrequests(option<retry-after>),
    /// other
    other(option<string>),
  }

  variant schema-version {
    v2,
    other(option<u8>),
  }

  variant media-type-suffix {
    /// json encoded
    json,
    /// compressed with gzip
    gzip,
    /// compressed with zstd
    zstd,
    /// other encoding
    other(option<string>),
  }

  /// common media types for oci artifacts
  variant media-type {
    /// content descriptor
    application-vnd-oci-descriptor-v1(media-type-suffix),
    /// oci layout
    application-vnd-oci-layout-header-v1(media-type-suffix),
    /// image index
    application-vnd-oci-image-index-v1(media-type-suffix),
    /// image manifest
    application-vnd-oci-image-manifest-v1(media-type-suffix),
    /// image config
    application-vnd-oci-image-config-v1(media-type-suffix),
    /// layer, as a tar archive
    application-vnd-oci-image-layer-v1-tar(media-type-suffix),
    /// empty for unused descriptors
    application-vnd-oci-empty-v1(media-type-suffix),
    /// layer, as a tar archive
    application-vnd-oci-image-layer-nondistributable-v1-tar(media-type-suffix),
    /// wasm config
    application-vnd-wasm-config-v0(media-type-suffix),
    /// wasm
    application-wasm,
    /// other
    other(string),
  }

  record oci-image-index-manifest-v1-manifest-platform {
    /// CPU architecture which the binaries in this image are built to run on
    architecture: string,
    /// name of the operating system which the image is built to run on
    os: string,
    /// version of the operating system
    os-version: option<string>,
    /// mandatory OS features
    os-features: option<list<string>>,
    /// variant of the CPU
    %variant: option<string>,
  }

  record oci-image-config-v1-config {
    /// username or UID which is a platform-specific structure that allows specific control over which user the process run as
    user: option<string>,
    /// set of ports to expose from a container running this image
    exposed-ports: option<list<string>>,
    /// values act as defaults and are merged with any specified when creating a container
    env: option<list<string>>,
    /// arguments to use as the command to execute when the container starts
    entrypoint: option<list<string>>,
    /// arguments to the entrypoint of the container
    cmd: option<list<string>>,
    /// directories describing where the process is likely to write data specific to a container instance
    volumes: option<list<string>>,
    /// current working directory of the entrypoint process in the container
    working-dir: option<string>,
    /// arbitrary metadata for the container
    labels: option<map<string, string>>,
    /// system call signal that will be sent to the container to exit
    stop-signal: option<string>,
    /// deprecated: present only for legacy compatibility
    args-escaped: option<bool>,
  }

  record oci-image-config-v1-history-entry {
    /// combined date and time at which the layer was created
    created: option<instant>,
    /// author of the build point
    author: option<string>,
    /// command which created the layer
    created-by: option<string>,
    /// custom message set when creating the layer
    comment: option<string>,
    /// mark if the history item created a filesystem diff
    empty-layer: option<bool>,
  }

  record wasm-config-v0-component {
    exports: list<string>,
    imports: list<string>,
    target: option<string>,
  }

  record digest {
    algorithm: string,
    encoded: string,
  }

  record oci-descriptor-v1 {
    /// media type of the referenced content
    media-type: media-type,
    /// digest of the targeted content
    digest: digest,
    /// size, in bytes, of the raw content
    size: u64,
    /// list of URIs from which this object MAY be downloaded
    urls: option<list<string>>,
    /// arbitrary metadata for this descriptor
    annotations: option<map<string, string>>,
    /// embedded representation of the referenced content
    data: option<string>,
    /// type of an artifact when the descriptor points to an artifact
    artifact-type: option<media-type>,
  }

  record oci-image-manifest-v1 {
    /// manifest schema version
    schema-version: schema-version,
    /// must contain the media type 'application/vnd.oci.image.manifest.v1+json'.
    media-type: media-type,
    /// type of an artifact when the manifest is used for an artifact
    artifact-type: option<media-type>,
    /// configuration object for a container
    config: oci-descriptor-v1,
    /// list of layer descriptors
    layers: list<oci-descriptor-v1>,
    /// weak association to another manifest
    subject: option<oci-descriptor-v1>,
    /// arbitrary metadata for the image manifest
    annotations: option<map<string, string>>,
  }

  record oci-image-index-manifest-v1-manifest {
    /// media type of the referenced content
    media-type: media-type,
    /// digest of the targeted content
    digest: digest,
    /// size, in bytes, of the raw content
    size: u64,
    /// list of URIs from which this object MAY be downloaded
    urls: option<list<string>>,
    /// arbitrary metadata for this descriptor
    annotations: option<map<string, string>>,
    /// embedded representation of the referenced content
    data: option<string>,
    /// type of an artifact when the descriptor points to an artifact
    artifact-type: option<media-type>,
    /// minimum runtime requirements of the image
    platform: option<oci-image-index-manifest-v1-manifest-platform>,
    /// descriptor of another manifest
    subject: option<oci-descriptor-v1>,
  }

  record oci-image-index-manifest-v1 {
    /// manifest schema version
    schema-version: schema-version,
    /// must contain the media type 'application/vnd.oci.image.index.v1+json'.
    media-type: media-type,
    /// type of an artifact when the manifest is used for an artifact
    artifact-type: option<media-type>,
    /// manifests for specific platforms
    manifests: list<oci-image-index-manifest-v1-manifest>,
    /// weak association to another manifest
    subject: option<oci-descriptor-v1>,
    /// arbitrary metadata for the image manifest
    annotations: option<map<string, string>>,
  }

  variant manifest {
    /// oci image
    oci-image-v1(oci-image-manifest-v1),
    /// oci image index
    oci-image-index-v1(oci-image-index-manifest-v1),
    /// other
    other(list<u8>),
  }

  record oci-image-config-v1-content-addresses {
    /// must be 'layers'
    %type: string,
    /// layer content hashes, in order from first to last
    diff-ids: list<digest>,
  }

  record oci-image-config-v1 {
    /// combined date and time at which the image was created
    created: option<instant>,
    /// name and/or email address of the person or entity which created and is responsible for maintaining the image
    author: option<string>,
    /// CPU architecture which the binaries in this image are built to run on
    architecture: string,
    /// name of the operating system which the image is built to run on
    os: string,
    /// version of the operating system
    os-version: option<string>,
    /// mandatory OS features
    os-features: option<list<string>>,
    /// variant of the specified CPU architecture
    %variant: option<string>,
    /// execution parameters which should be used as a base when running a container using the image
    config: option<oci-image-config-v1-config>,
    /// layer content addresses used by the image
    rootfs: oci-image-config-v1-content-addresses,
    /// history of each layer. The array is ordered from first to last
    history: option<list<oci-image-config-v1-history-entry>>,
  }

  record wasm-config-v0 {
    /// combined date and time at which the image was created
    created: option<instant>,
    /// name and/or email address of the person or entity which created and is responsible for maintaining the image
    author: option<string>,
    /// must match a GOARCH value
    architecture: string,
    /// must match a GOOS value
    os: string,
    /// digests of the layers in the same order
    layer-digests: list<digest>,
    /// component metadata
    component: option<wasm-config-v0-component>,
  }

  variant config {
    /// oci iamge
    oci-image-v1(oci-image-config-v1),
    /// wasm module
    wasm-v0(wasm-config-v0),
    /// other
    other(list<u8>),
  }

  record reference {
    registry: string,
    repository: string,
    tag: option<string>,
    digest: option<digest>,
  }

  parse-reference: func(reference: string) -> result<reference, error-code>;

  resolve-digest: async func(reference: reference) -> result<digest, error-code>;

  get-blob: async func(reference: reference) -> result<list<u8>, error-code>;

  get-config: async func(reference: reference, default-media-type: option<media-type>) -> result<config, error-code>;

  get-manifest: async func(reference: reference) -> result<manifest, error-code>;
}