oci

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package oci provides functionality for working with OCI (Open Container Initiative) registries and WASM (WebAssembly) artifacts according to the CNCF TAG Runtime WASM OCI Artifact specification.

This package implements:

  • WASM OCI image creation with proper layerDigests field for Spin compatibility
  • Registry push/pull operations for WASM components
  • ECR (Elastic Container Registry) authentication support
  • Caching for pulled WASM artifacts

The implementation follows the WASM OCI artifact specification used by tools like wkg (WebAssembly Package Manager) and Spin Framework, ensuring compatibility with the broader WASM ecosystem.

Example usage:

// Push a WASM component to a registry
auth := &oci.ECRAuth{
    Registry: "123456.dkr.ecr.us-east-1.amazonaws.com",
    Username: "AWS",
    Password: "token",
}
pusher := oci.NewWASMPusher(auth)
err := pusher.Push(ctx, "component.wasm", "namespace/component", "1.0.0")

// Pull a WASM component from a registry
puller := oci.NewWASMPuller()
source := &types.RegistrySource{
    Registry: "ghcr.io",
    Package:  "org/component",
    Version:  "1.0.0",
}
wasmPath, err := puller.Pull(ctx, source)

Index

Constants

View Source
const (
	// WASMLayerMediaType is the media type for WASM layers
	WASMLayerMediaType = "application/wasm"

	// WASMConfigMediaType is the media type for WASM config blobs
	WASMConfigMediaType = "application/vnd.wasm.config.v0+json"

	// WASMManifestMediaType is the media type for WASM manifests
	WASMManifestMediaType = "application/vnd.oci.image.manifest.v1+json"

	// WASMArchitecture is the architecture field value for WASM artifacts
	WASMArchitecture = "wasm"

	// WASMOS is the OS field value for WASM components (wasip2)
	WASMOS = "wasip2"
)

WASM OCI media types as defined by the CNCF TAG Runtime WASM OCI Artifact specification https://tag-runtime.cncf.io/wgs/wasm/deliverables/wasm-oci-artifact/

Variables

This section is empty.

Functions

This section is empty.

Types

type ECRAuth

type ECRAuth struct {
	Registry string
	Username string
	Password string
}

ECRAuth holds parsed ECR authentication details

func ParseECRToken

func ParseECRToken(registryURI, authToken string) (*ECRAuth, error)

ParseECRToken parses an ECR authorization token from AWS The token is base64 encoded in the format "AWS:password"

type WASMConfig

type WASMConfig struct {
	Created      string   `json:"created"`
	Architecture string   `json:"architecture"`
	OS           string   `json:"os"`
	LayerDigests []string `json:"layerDigests"` // Critical field for Spin compatibility - must be camelCase!
	RootFS       struct {
		Type    string   `json:"type"`
		DiffIDs []string `json:"diff_ids"`
	} `json:"rootfs"`
	Config struct{} `json:"config"`
}

WASMConfig represents the config for a WASM OCI artifact This matches the structure expected by oci-wasm and Spin

type WASMPuller

type WASMPuller struct {
	// contains filtered or unexported fields
}

WASMPuller handles pulling WASM components from OCI registries

func NewWASMPuller

func NewWASMPuller() *WASMPuller

NewWASMPuller creates a new WASM component puller

func NewWASMPullerWithCache

func NewWASMPullerWithCache(cacheDir string) *WASMPuller

NewWASMPullerWithCache creates a new WASM component puller with a custom cache directory

func (*WASMPuller) Pull

func (p *WASMPuller) Pull(ctx context.Context, registry, packageName, version string) (string, error)

Pull downloads a WASM component from a registry Parameters are now explicit instead of using a types package

type WASMPusher

type WASMPusher struct {
	// contains filtered or unexported fields
}

WASMPusher handles pushing WASM components to OCI registries

func NewWASMPusher

func NewWASMPusher(auth *ECRAuth) *WASMPusher

NewWASMPusher creates a new WASM component pusher

func (*WASMPusher) Push

func (p *WASMPusher) Push(ctx context.Context, wasmPath, packageName, version string) error

Push uploads a WASM component to a registry as an OCI artifact Following the CNCF TAG Runtime WASM OCI Artifact specification

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL