rel

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package rel is the pure release model: versions, digests, tags, and tag plans.

Parse functions construct domain values. PlanTags decides which immutable exact tag and moving channel tags a candidate release may apply. The package performs no I/O and depends only on the standard library.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrImmutableTag reports that an exact version tag already points at
	// another digest.
	ErrImmutableTag = errors.New("immutable tag conflict")
	// ErrChannelCorrupt reports missing version annotation, an out-of-line
	// channel, or equal versions with different digests.
	ErrChannelCorrupt = errors.New("corrupt channel state")
	// ErrStateIncomplete reports that a required channel is missing from
	// [ChannelState.Channels].
	ErrStateIncomplete = errors.New("incomplete channel state")
)

Sentinel errors returned by PlanTags.

Functions

This section is empty.

Types

type Action

type Action string

Action is the planned outcome for one tag.

const (
	// ActionCreate means the tag must be applied to the candidate digest.
	ActionCreate Action = "create"
	// ActionAccept means the tag already resolves to the candidate digest.
	ActionAccept Action = "accept"
	// ActionRetain means the channel stays on a newer release.
	ActionRetain Action = "retain"
)

type Channel

type Channel struct {
	// Scope is the channel's advancement rule.
	Scope Scope
	// Tag is the registry tag for this channel.
	Tag Tag
}

Channel is one moving tag together with its advancement rule.

func ChannelsFor

func ChannelsFor(v Version) []Channel

ChannelsFor returns the moving channels for v, in planning order.

The result is always minor "MAJOR.MINOR", major "MAJOR", then latest "latest". Tags are formatted from decimal version components or the literal "latest", which cannot produce an invalid OCI tag.

type ChannelState

type ChannelState struct {
	// Exact is the observed state of the candidate's exact version tag.
	Exact TagState
	// Channels is the observed state of each moving channel. Every channel
	// from [ChannelsFor] must be present as a key.
	Channels map[Channel]TagState
}

ChannelState is the observed state of the exact tag and every channel.

type Decision

type Decision struct {
	// Tag is the registry tag this decision applies to.
	Tag Tag
	// Scope is the tag's classification.
	Scope Scope
	// Action is the planned outcome.
	Action Action
}

Decision is the planned action for one tag.

type Digest

type Digest string

Digest is a lowercase sha256:<64 hex> image digest.

The only constructor is ParseDigest, which requires the sha256: prefix and normalizes uppercase hex. The zero value is invalid.

func ParseDigest

func ParseDigest(value string) (Digest, error)

ParseDigest constructs a Digest from a sha256:<hex> string.

The sha256: prefix is required. The hex part must be exactly hex.EncodedLen of sha256.Size hexadecimal digits. Uppercase hex is normalized to lowercase. Any other prefix, length, or charset is rejected.

func (Digest) String

func (d Digest) String() string

String returns the canonical sha256:<hex> digest.

type Scope

type Scope string

Scope classifies a planned tag as exact or as a moving channel.

const (
	// ScopeExact is the immutable MAJOR.MINOR.PATCH tag.
	ScopeExact Scope = "exact"
	// ScopeMinor is the MAJOR.MINOR channel.
	ScopeMinor Scope = "minor"
	// ScopeMajor is the MAJOR channel.
	ScopeMajor Scope = "major"
	// ScopeLatest is the latest channel.
	ScopeLatest Scope = "latest"
)

type Secret

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

Secret holds a credential that must not appear in logs or encodings.

Secret.Reveal is the only way to read the payload. String, GoString, and the marshal methods always return [redacted], including for an empty value.

func NewSecret

func NewSecret(value string) Secret

NewSecret constructs a Secret that wraps value.

func (Secret) GoString

func (s Secret) GoString() string

GoString returns [redacted].

func (Secret) IsEmpty

func (s Secret) IsEmpty() bool

IsEmpty reports whether the wrapped payload is empty.

func (Secret) MarshalJSON

func (s Secret) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON string [redacted].

func (Secret) MarshalText

func (s Secret) MarshalText() ([]byte, error)

MarshalText returns [redacted].

func (Secret) Reveal

func (s Secret) Reveal() string

Reveal returns the wrapped payload.

Callers should use Reveal only at adapter composition edges that need the real credential.

func (Secret) String

func (s Secret) String() string

String returns [redacted].

type Tag

type Tag string

Tag is a validated OCI image tag.

The only constructor is ParseTag. The zero value is invalid.

func ParseTag

func ParseTag(value string) (Tag, error)

ParseTag constructs a Tag from an OCI tag string.

The grammar is [A-Za-z0-9_][A-Za-z0-9._-]{0,127}: the first character is alphanumeric or underscore, remaining characters may also be dot or hyphen, and the total length is 1 through 128.

func (Tag) String

func (t Tag) String() string

String returns the tag text.

type TagPlan

type TagPlan struct {
	// Version is the candidate release version.
	Version Version
	// Digest is the candidate image digest.
	Digest Digest
	// Decisions are the exact tag and each channel, in planning order.
	Decisions []Decision
}

TagPlan is the complete set of tag decisions for one candidate.

func PlanTags

func PlanTags(v Version, digest Digest, current ChannelState) (TagPlan, error)

PlanTags decides which tags a candidate release may apply.

The exact tag is decided first, then each channel from ChannelsFor in order. A zero digest is rejected. A channel missing from current.Channels is ErrStateIncomplete. An exact tag on another digest is ErrImmutableTag. A missing version annotation, an out-of-line channel, and equal versions with different digests are ErrChannelCorrupt.

func (TagPlan) Apply

func (p TagPlan) Apply() []Tag

Apply returns the tags that must be written, in decision order.

type TagState

type TagState struct {
	// Present reports whether the tag currently resolves.
	Present bool
	// Digest is the resolved digest. It is meaningful only when Present.
	Digest Digest
	// HasVersion reports whether a version annotation was read.
	HasVersion bool
	// Version is the annotated version. It is meaningful only when HasVersion.
	Version Version
}

TagState is the observed registry state of one tag.

type Version

type Version struct {
	// Major is the leftmost version component.
	Major uint64
	// Minor is the middle version component.
	Minor uint64
	// Patch is the rightmost version component.
	Patch uint64
}

Version is a canonical stable MAJOR.MINOR.PATCH triple.

The only constructor is ParseVersion. The zero value is 0.0.0, which is a valid version.

func ParseVersion

func ParseVersion(value string) (Version, error)

ParseVersion constructs a Version from a stable MAJOR.MINOR.PATCH string.

The grammar is exactly three decimal components with no leading zeros (except the value 0), no v prefix, no sign, no prerelease, and no build metadata. A component that does not fit in uint64 is rejected. Error text names the problem and echoes the input.

func (Version) Compare

func (v Version) Compare(other Version) int

Compare reports the order of v and other.

It returns -1 if v is less, 0 if they are equal, and +1 if v is greater. Components are compared as major, then minor, then patch.

func (Version) String

func (v Version) String() string

String returns the canonical MAJOR.MINOR.PATCH form.

func (Version) Tag

func (v Version) Tag() Tag

Tag returns the exact-version registry tag, which equals Version.String.

A decimal triple always starts with a digit and contains only digits and dots, so the result is a valid OCI tag.

Jump to

Keyboard shortcuts

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