Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt

Use this file to discover all available pages before exploring further.

The Go SDK exposes local OCI image-cache operations through the package-level Image value. These APIs inspect and prune images that have already been pulled by sandbox creation.
import m "github.com/superradcompany/microsandbox/sdk/go"

Image


Image.Get()

func (imageFactory) Get(ctx context.Context, reference string) (*ImageHandle, error)
Fetch one cached image by reference. Returns ErrImageNotFound when the image is not present in the local cache.

Image.List()

func (imageFactory) List(ctx context.Context) ([]*ImageHandle, error)
Return every cached image, ordered newest first.
images, err := m.Image.List(ctx)
if err != nil {
    return err
}
for _, img := range images {
    fmt.Println(img.Reference(), img.LayerCount())
}

Image.Inspect()

func (imageFactory) Inspect(ctx context.Context, reference string) (*ImageDetail, error)
Return handle metadata plus parsed OCI config and layer details.

Image.Remove()

func (imageFactory) Remove(ctx context.Context, reference string, force bool) error
Delete a cached image. When force is false, sandboxes still referencing the image cause ErrImageInUse.

Image.GCLayers()

func (imageFactory) GCLayers(ctx context.Context) (uint32, error)
Garbage-collect orphaned layers and return the count reclaimed.

Image.GC()

func (imageFactory) GC(ctx context.Context) (uint32, error)
Garbage-collect everything reclaimable from the image cache and return the count reclaimed.

ImageHandle

Returned by Image.Get and Image.List.
MethodReturnsDescription
Reference()stringImage reference
ManifestDigest()stringContent-addressable manifest digest, or empty
Architecture()stringResolved architecture, or empty
OS()stringResolved operating system, or empty
LayerCount()uintNumber of layers
SizeBytes()*int64Total size, or nil when unknown
CreatedAt()time.TimeFirst-pulled time, or zero
LastUsedAt()time.TimeLast referenced time, or zero
Remove(ctx, force)errorDelete this image
Inspect(ctx)(*ImageDetail, error)Fetch full detail for this image

ImageDetail

type ImageDetail struct {
    *ImageHandle
    Config *ImageConfig
    Layers []ImageLayer
}

ImageConfig

Parsed OCI config block.
FieldType
Digeststring
Env[]string
Cmd[]string
Entrypoint[]string
WorkingDirstring
Userstring
Labelsmap[string]string
StopSignalstring

ImageLayer

One layer in the image manifest.
FieldType
DiffIDstring
BlobDigeststring
MediaTypestring
CompressedSizeBytes*int64
ErofsSizeBytes*int64
Positionint32