digest

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package digest defines the canonical OCI digest type used across Gantry.

All Gantry-internal APIs that identify cached or in-flight content use a Digest, not a raw string. This package centralizes parsing and validation so the format is enforced exactly once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm string

Algorithm identifies a digest hash algorithm.

v1 supports SHA-256 only - that is what the OCI Distribution API uses for `blobs/sha256:<hex>` and `manifests/sha256:<hex>` (the only digest-keyed endpoints in the agent's API surface, per architecture.md the API contract).

const (
	// SHA256 is the only digest algorithm Gantry accepts (per OCI spec
	// alignment in the design doc of detailed-design.md).
	SHA256 Algorithm = "sha256"
)

type Digest

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

Digest is a parsed OCI content digest, e.g. "sha256:abc...".

The zero value is invalid; construct via Parse.

func MustParse

func MustParse(s string) Digest

MustParse is Parse but panics on error. Intended for test fixtures and compile-time constants only.

func Parse

func Parse(s string) (Digest, error)

Parse validates s as an OCI digest in the form "<algo>:<hex>" and returns the parsed Digest. Unknown algorithms are rejected.

func (Digest) Algorithm

func (d Digest) Algorithm() Algorithm

Algorithm returns the digest's hash algorithm.

func (Digest) Hex

func (d Digest) Hex() string

Hex returns the lower-case hex-encoded digest body.

func (Digest) IsZero

func (d Digest) IsZero() bool

IsZero reports whether d is the zero Digest (invalid).

func (Digest) String

func (d Digest) String() string

String returns the canonical "<algo>:<hex>" form.

Jump to

Keyboard shortcuts

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