Documentation
¶
Overview ¶
Package registry holds the domain aggregates: buckets, versions, builds, artifacts and channels.
Nothing here may import a wire model. Completion is a bool, not the "v0" sentinel; not-found is one domain error, not a per-endpoint gRPC code. Adapters under internal/compat translate. Enforced by depguard — see docs/architecture.md.
Index ¶
- Variables
- type AncestryStatus
- type Build
- type BuildStatus
- type ID
- type Revocation
- type RevokedAncestor
- type TemplateType
- type Version
- func (v *Version) AssignableToChannel() error
- func (v *Version) Complete() bool
- func (v *Version) EnsureTemplateType(tt TemplateType) error
- func (v *Version) MarkComplete(sequence int, at time.Time) error
- func (v *Version) ReadyToComplete() bool
- func (v *Version) Restore(at time.Time) error
- func (v *Version) Revocation() *Revocation
- func (v *Version) Revoke(rev Revocation, at time.Time) error
- func (v *Version) Sequence() (int, bool)
- type VersionParents
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrInvalid = errors.New("invalid") ErrConflict = errors.New("conflict") ErrRestoreInherited = errors.New("restore inherited revocation") )
The domain has one not-found error. Compatibility adapters map it to whatever each endpoint's client demands — code 5 for a missing bucket, code 10 for a missing version — because those codes are transport accidents, not domain facts. See docs/architecture.md.
Functions ¶
This section is empty.
Types ¶
type AncestryStatus ¶
type AncestryStatus string
AncestryStatus describes whether a version still follows its recorded parents.
const ( AncestryUndetermined AncestryStatus = "undetermined" AncestryUpToDate AncestryStatus = "up_to_date" AncestryOutOfDate AncestryStatus = "out_of_date" )
type Build ¶
type Build struct {
ID ID
ComponentType string
Status BuildStatus
Platform string
MetadataSeen bool
}
Build is one component's contribution to a version.
type BuildStatus ¶
type BuildStatus string
BuildStatus is the lifecycle state of one component build.
const ( BuildPending BuildStatus = "pending" BuildRunning BuildStatus = "running" BuildDone BuildStatus = "done" BuildFailed BuildStatus = "failed" BuildCancelled BuildStatus = "cancelled" )
type ID ¶
type ID string
ID identifies a registry resource.
ULID, not UUID: both published HCP specs document resource ids as "Universally Unique Lexicographically Sortable Identifier (ULID)". Ids are wire-visible and referenced everywhere, so the choice is not ours to make.
func NewID ¶
NewID mints a ULID for the given instant. Ids minted within the same millisecond still sort in creation order, since ULID sort order is lexicographic and callers may rely on it.
type Revocation ¶
type Revocation struct {
RevokeAt time.Time
Message string
Author string
InheritedFrom *RevokedAncestor
}
Revocation is a version's revocation state.
RevokeAt is the effect time, not the record time: a future value is a scheduled revocation, and readers derive whether it has taken effect rather than any job flipping state. InheritedFrom is nil for a manual revocation; the wire's manual/inherited type is derived from it, never stored.
type RevokedAncestor ¶
type RevokedAncestor struct {
VersionID ID
BucketName string
Fingerprint string
VersionName string
}
RevokedAncestor identifies the ancestor a revocation was inherited from.
The identity is denormalized at revocation time: bucket names and version names are fixed by then, and carrying them keeps rendering join-free.
type TemplateType ¶
type TemplateType string
TemplateType is the kind of Packer template a version was built from.
It must be known at creation and can never change: Packer refuses to add a build to a version created from a different template type.
const ( TemplateHCL2 TemplateType = "HCL2" TemplateJSON TemplateType = "JSON" )
type Version ¶
type Version struct {
ID ID
BucketName string
Fingerprint string
TemplateType TemplateType
AuthorID string
HasDescendants bool
Parents *VersionParents
Builds []Build
CreatedAt time.Time
UpdatedAt time.Time
// contains filtered or unexported fields
}
Version is a set of builds sharing a fingerprint.
Completion is a bool and a sequence number here, deliberately. The 2023-01-01 wire model collapses both into a single "name" string — "v0" while incomplete, "v<n>" once complete — which is a lossy migration of the two well-designed fields the 2021-04-30 model carried. The compatibility adapters re-derive that string; the domain never sees it.
func NewVersion ¶
NewVersion creates an incomplete version.
func RestoreVersion ¶
func RestoreVersion(v Version, complete bool, sequence int, revocation *Revocation) (*Version, error)
RestoreVersion rebuilds a Version from persisted state, bypassing the creation invariants. For the store layer only.
func (*Version) AssignableToChannel ¶
AssignableToChannel reports whether a channel may point at this version.
Only complete versions may be assigned: the 2021-04-30 spec states a complete iteration "is considered ready to use, and can have channels assigned to it".
func (*Version) Complete ¶
Complete reports whether every build succeeded and reported its metadata.
func (*Version) EnsureTemplateType ¶
func (v *Version) EnsureTemplateType(tt TemplateType) error
EnsureTemplateType rejects a run whose template type differs from the one the version was created with.
func (*Version) MarkComplete ¶
MarkComplete assigns the version its sequence number.
sequence is allocated per bucket and monotonic, and is assigned at completion rather than creation — an incomplete version has no number.
func (*Version) ReadyToComplete ¶
ReadyToComplete reports whether every build has succeeded and reported metadata. A version with no builds is never ready.
func (*Version) Revocation ¶
func (v *Version) Revocation() *Revocation
Revocation is the version's revocation state, nil when never revoked.
func (*Version) Revoke ¶
func (v *Version) Revoke(rev Revocation, at time.Time) error
Revoke records a revocation, manual or inherited.
An already-revoked version is refused rather than overwritten: a manual revocation must not be silently replaced by an inherited one arriving later. A caller that means to replace a revocation must restore, then revoke again.
type VersionParents ¶
type VersionParents struct {
Status AncestryStatus
}
VersionParents is the ancestry summary for a version that names a parent.