ocidoc-go

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT

README

ocidoc-go

ocidoc-go is the reference Go SDK for building, reading, verifying and publishing OCIDoc documentation artifacts in OCI registries and OCI Image Layouts.

The current artifact format is v1beta. The module is pre-1.0; public APIs and the format may change before OCIDoc v1 is frozen.

Install

go get github.com/ocidoc/ocidoc-go

Build an archive

artifact.BuildArchive reads ocidoc.yaml or ocidoc.json from the source tree and writes a deterministic .ocidoc archive.

result, err := artifact.BuildArchive(ctx, artifact.BuildArchiveOptions{
    Root: "./project",
    Output: artifact.Destination{Path: "project.ocidoc"},
})
if err != nil {
    return err
}

fmt.Println(result.Output)

Use artifact.BuildReader when the caller needs a graph reader for committing to a local store or publishing to a registry without an archive. Use artifact.BuildLayout when the caller needs an unpacked OCI Image Layout.

Read and verify an artifact

reader, err := artifact.OpenArchive("project.ocidoc")
if err != nil {
    return err
}
defer reader.Close()

verification, err := artifact.Verify(ctx, reader, artifact.VerifyOptions{})
if err != nil {
    return err
}
if !verification.Valid {
    return errors.New("invalid OCIDoc artifact")
}

artifact.OpenLayout opens an unpacked OCI Image Layout. The same Reader can be inspected, listed, extracted, diffed or published.

Attach to an OCI subject

reader, err := artifact.OpenArchive("project.ocidoc")
if err != nil {
    return err
}
defer reader.Close()

client := registry.NewClient(registry.ClientOptions{})
attached, err := client.Attach(
    ctx, reader, "registry.example/app:1.2.3", registry.AttachOptions{
    Publication: registry.PublicationBoth,
    })
if err != nil {
    return err
}

fmt.Println(attached.Reference)

PublicationReferrer is the preferred discovery mechanism. PublicationTag uses the deterministic .doc tag; PublicationBoth publishes both views of the same artifact for compatibility.

For explicit registry credentials and transport options, see the Go package documentation for registry.ClientOptions. The SDK accepts OCI registry references and does not expose ORAS types in its public API.

Packages

  • artifact builds and operates on local artifacts and OCI layouts.
  • registry publishes, resolves, discovers, copies and removes artifacts.
  • spec defines format constants, configuration types and validation.
  • store provides an experimental local artifact store API.

The full format specification, CLI documentation and generated configuration schema reference are published at ocidoc.org.

Directories

Path Synopsis
Package artifact implements local OCIDoc artifact operations: parsing build config, building artifacts from a source tree, and opening, inspecting, listing, extracting, verifying and diffing existing artifacts (OCI layout or ".ocidoc" archive).
Package artifact implements local OCIDoc artifact operations: parsing build config, building artifacts from a source tree, and opening, inspecting, listing, extracting, verifying and diffing existing artifacts (OCI layout or ".ocidoc" archive).
internal
archive
Package archive builds deterministic POSIX component tars: regular files only, sorted by bundle path, fixed ownership/mode/mtime.
Package archive builds deterministic POSIX component tars: regular files only, sorted by bundle path, fixed ownership/mode/mtime.
atomicfile
Package atomicfile writes files so that other processes only ever observe either the previous content or the fully written new content, never a partial write.
Package atomicfile writes files so that other processes only ever observe either the previous content or the fully written new content, never a partial write.
compression
Package compression wraps gzip and zstd component-layer compression with deterministic settings: a fixed gzip header, and pinned zstd encoder options that do not depend on the build host (CPU count in particular).
Package compression wraps gzip and zstd component-layer compression with deterministic settings: a fixed gzip header, and pinned zstd encoder options that do not depend on the build host (CPU count in particular).
digestio
Package digestio provides a streaming writer that computes the canonical (sha256) digest and byte count of everything written to it, so callers never need to buffer a whole blob in memory just to learn its digest and size.
Package digestio provides a streaming writer that computes the canonical (sha256) digest and byte count of everything written to it, so callers never need to buffer a whole blob in memory just to learn its digest and size.
markdown
Package markdown extracts local document and asset references from Markdown content.
Package markdown extracts local document and asset references from Markdown content.
ociblob
Package ociblob provides the validation boundary for OCIDoc OCI blobs.
Package ociblob provides the validation boundary for OCIDoc OCI blobs.
ociclone
Package ociclone copies OCI metadata before it crosses a public Reader boundary.
Package ociclone copies OCI metadata before it crosses a public Reader boundary.
orasrepo
Package orasrepo isolates oras-go's remote registry client behind a small module-internal interface.
Package orasrepo isolates oras-go's remote registry client behind a small module-internal interface.
pathplan
Package pathplan compiles a spec.BuildConfig's ignore and component rules with github.com/woozymasta/pathrules and walks a source tree to resolve component ownership.
Package pathplan compiles a spec.BuildConfig's ignore and component rules with github.com/woozymasta/pathrules and walks a source tree to resolve component ownership.
sourcepath
Package sourcepath resolves source-tree paths without allowing symlink or junction targets to escape the source root.
Package sourcepath resolves source-tree paths without allowing symlink or junction targets to escape the source root.
testfixture
Package testfixture builds local OCI Image Layout test artifacts shared by registry and store's test suites, so both build the same minimal artifact shape from one implementation instead of two independently hand-synced copies.
Package testfixture builds local OCI Image Layout test artifacts shared by registry and store's test suites, so both build the same minimal artifact shape from one implementation instead of two independently hand-synced copies.
Package registry publishes and resolves OCIDoc artifacts against an OCI-compliant registry, on top of the ORAS-backed adapter in internal/orasrepo.
Package registry publishes and resolves OCIDoc artifacts against an OCI-compliant registry, on top of the ORAS-backed adapter in internal/orasrepo.
Package spec defines the OCIDoc v1beta artifact format: media types, managed annotations, standard component types, build/artifact config structures and format-level validation.
Package spec defines the OCIDoc v1beta artifact format: media types, managed annotations, standard component types, build/artifact config structures and format-level validation.
Package store implements OCIDoc's persistent local content-addressed store: the normal working representation for a locally built or pulled artifact, distinct from the portable .ocidoc export/import format.
Package store implements OCIDoc's persistent local content-addressed store: the normal working representation for a locally built or pulled artifact, distinct from the portable .ocidoc export/import format.

Jump to

Keyboard shortcuts

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