// Code generated by seatgen from the seat definitions; DO NOT EDIT. // Package containerimageregistry is the contract of the seat "container-image-registry", defined whole (seats/container-image-registry/seat.json): The mesh's container images, in the one artifact store: the OCI distribution protocol's read side, an image's tags and mirroring an outside image. package containerimageregistry import ( "bytes" "encoding/json" "errors" "strings" ) // Seat is the seat's name. const Seat = "container-image-registry" const ( VerbPublish = "publish" VerbPublishPart = "publish-part" VerbVersions = "versions" VerbRemove = "remove" VerbMirror = "mirror" VerbTags = "tags" VerbHold = "hold" VerbRelease = "release" VerbList = "list" ) const ( EventPublished = "published" EventRefused = "refused" EventRemoved = "removed" EventKept = "kept" EventHeld = "held" EventReleased = "released" ) // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { return []string{VerbPublish, VerbPublishPart, VerbVersions, VerbRemove, VerbMirror, VerbTags, VerbHold, VerbRelease, VerbList} } // Events is every event published on the seat's subject: a new copy each call. func Events() []string { return []string{EventPublished, EventRefused, EventRemoved, EventKept, EventHeld, EventReleased} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. const ( Family = "container-image-registry.events" FamilyMaxAgeDays = 7 ) // SubjectPublished is where published is published. const SubjectPublished = "mesh.seat.container-image-registry.event.published" // SubjectRefused is where refused is published. const SubjectRefused = "mesh.seat.container-image-registry.event.refused" // SubjectRemoved is where removed is published. const SubjectRemoved = "mesh.seat.container-image-registry.event.removed" // SubjectKept is where kept is published. const SubjectKept = "mesh.seat.container-image-registry.event.kept" // SubjectHeld is where held is published. const SubjectHeld = "mesh.seat.container-image-registry.event.held" // SubjectReleased is where released is published. const SubjectReleased = "mesh.seat.container-image-registry.event.released" const ( StateHolds = "holds" StateWindows = "windows" ) // HoldsBySeatNameDigestKey is the key of one value of the state holds under the form "..". func HoldsBySeatNameDigestKey(seat, name, digest string) string { return seat + "." + name + "." + digest } // ParseHoldsBySeatNameDigestKey reads the parts of a key of the form "..", in the order of the form; the last result is false for a key of another form. func ParseHoldsBySeatNameDigestKey(key string) (string, string, string, bool) { rest := key v0, after0, found0 := strings.Cut(rest, ".") if !found0 || v0 == "" { return "", "", "", false } rest = after0 v2, after2, found2 := strings.Cut(rest, ".") if !found2 || v2 == "" { return "", "", "", false } rest = after2 if rest == "" { return "", "", "", false } v4 := rest rest = "" if rest != "" { return "", "", "", false } return v0, v2, v4, true } // DecodeHoldsBySeatNameDigestValue reads one value of the state holds under the form "..", refusing a field HoldsBySeatNameDigestValue does not know and any text after the value. func DecodeHoldsBySeatNameDigestValue(raw []byte) (HoldsBySeatNameDigestValue, error) { var v HoldsBySeatNameDigestValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { return v, err } if dec.More() { return v, errors.New("text after the value") } return v, nil } // WindowsByCallerKey is the key of one value of the state windows under the form "". func WindowsByCallerKey(caller string) string { return caller } // ParseWindowsByCallerKey reads the parts of a key of the form "", in the order of the form; the last result is false for a key of another form. func ParseWindowsByCallerKey(key string) (string, bool) { rest := key if rest == "" { return "", false } v0 := rest rest = "" if rest != "" { return "", false } return v0, true } // DecodeWindowsByCallerValue reads one value of the state windows under the form "", refusing a field WindowsByCallerValue does not know and any text after the value. func DecodeWindowsByCallerValue(raw []byte) (WindowsByCallerValue, error) { var v WindowsByCallerValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { return v, err } if dec.More() { return v, errors.New("text after the value") } return v, nil } // Artifact is one published thing, as every registry event and answer names it. type Artifact struct { // the source commit it was built from Commit string `json:"commit,omitempty"` // its digest, sha256: (a Go package's h1: hash beside it in the version's record) Digest string `json:"digest"` // the build's fingerprint Fingerprint string `json:"fingerprint,omitempty"` // what it is Kind string `json:"kind"` // the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk) Name string `json:"name"` // the tag it carries, for a tagged version Tag string `json:"tag,omitempty"` // the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone Version string `json:"version,omitempty"` } // The values of Artifact's kind. const ( ArtifactKindPackage = "package" ArtifactKindImage = "image" ArtifactKindBundle = "bundle" ArtifactKindArchive = "archive" ArtifactKindUpstream = "upstream" ) // Hold is the body of held and released. type Hold struct { // when, RFC 3339 At string `json:"at,omitempty"` // the caller the holder proved By string `json:"by,omitempty"` // the digest Digest string `json:"digest"` // the module holding the seat Holder string `json:"holder"` // the name Name string `json:"name"` // why Reason string `json:"reason,omitempty"` } // Listed is a type of the contract. type Listed struct { // for a manifest keeping one bundle or archive, the digest of that blob: what a reference names it by Artifact string `json:"artifact,omitempty"` // the manifest's digest, sha256: Digest string `json:"digest"` // a hold keeps it from retention Held bool `json:"held"` // it is an index, naming a manifest per platform Index bool `json:"index"` // for an index, the digests of the manifests it names Platforms []string `json:"platforms,omitempty"` // its bytes: its own content and every blob it names Size int64 `json:"size"` // the tags naming it, none for an untagged one Tags []string `json:"tags,omitempty"` } // Outcome is the body of published, refused and removed. type Outcome struct { // the source commit it was built from Commit string `json:"commit,omitempty"` // its digest, sha256: (a Go package's h1: hash beside it in the version's record) Digest string `json:"digest"` // the build's fingerprint Fingerprint string `json:"fingerprint,omitempty"` // the module holding the seat that said it Holder string `json:"holder"` // what it is Kind string `json:"kind"` // the Go module path a Go package is fetched under, equal to name for a Go package (go-package-registry's published); empty for every other kind of artifact Module string `json:"module,omitempty"` // the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk) Name string `json:"name"` // why: a refusal's cause, a removal's (retention, tag-gone, by-hand), or why a removal was kept (shared-digest) Reason string `json:"reason,omitempty"` // the reference the seat answers: //@sha256:, or @ for a package (ADR 0605 ยง9) Reference string `json:"reference,omitempty"` // the tag it carries, for a tagged version Tag string `json:"tag,omitempty"` // for kept: the other tags still naming its digest Tags []string `json:"tags,omitempty"` // the transfer it ends, when it ended one Transfer string `json:"transfer,omitempty"` // the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone Version string `json:"version,omitempty"` } // The values of Outcome's kind. const ( OutcomeKindPackage = "package" OutcomeKindImage = "image" OutcomeKindBundle = "bundle" OutcomeKindArchive = "archive" OutcomeKindUpstream = "upstream" ) // Part is one part of a transfer. type Part struct { // the part's digest, sha256:: an image's layer or config, a package's file, a bundle's blob Digest string `json:"digest"` // its size in bytes Size int64 `json:"size"` } // Repository is a type of the contract. type Repository struct { // each manifest it holds, by digest Manifests []Listed `json:"manifests"` // the repository Name string `json:"name"` } // PublishInput is what publish takes. type PublishInput struct { // the source commit it was built from Commit string `json:"commit,omitempty"` // its digest, sha256: (a Go package's h1: hash beside it in the version's record) Digest string `json:"digest"` // the build's fingerprint Fingerprint string `json:"fingerprint,omitempty"` // what it is Kind string `json:"kind"` // the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk) Name string `json:"name"` // every part's digest and size; none when the digest is already held Parts []Part `json:"parts,omitempty"` // the tag it carries, for a tagged version Tag string `json:"tag,omitempty"` // the transfer's name, the caller's own; the same name opens the same transfer again Transfer string `json:"transfer"` // the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone Version string `json:"version,omitempty"` } // The values of PublishInput's kind. const ( PublishInputKindPackage = "package" PublishInputKindImage = "image" PublishInputKindBundle = "bundle" PublishInputKindArchive = "archive" PublishInputKindUpstream = "upstream" ) // PublishAnswer is what publish answers. type PublishAnswer struct { // the digest is held already: nothing to send; the outcome follows as an event Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part Lacks []string `json:"lacks,omitempty"` // the transfer Transfer string `json:"transfer"` } // PublishPartInput is what publish-part takes. type PublishPartInput struct { // the chunk's bytes, base64 (at most 760 KiB before encoding) Data string `json:"data"` // this chunk is the part's last Last bool `json:"last"` // the part's digest Part string `json:"part"` // the chunk's place in its part, from 0 Sequence int64 `json:"sequence"` // the transfer Transfer string `json:"transfer"` } // PublishPartAnswer is what publish-part answers. type PublishPartAnswer struct { // the part is whole and its bytes match its digest Complete bool `json:"complete,omitempty"` // the part Part string `json:"part"` // the chunks of the part held so far Received int64 `json:"received,omitempty"` // the transfer Transfer string `json:"transfer"` } // VersionsInput is what versions takes. type VersionsInput struct { // narrowed to one kind (optional) Kind string `json:"kind,omitempty"` // the name Name string `json:"name"` } // VersionsAnswer is what versions answers. type VersionsAnswer struct { // the name Name string `json:"name"` // newest first Versions []Artifact `json:"versions"` } // RemoveInput is what remove takes. type RemoveInput struct { // the digest (for a bundle, archive or copied base) Digest string `json:"digest,omitempty"` // the name Name string `json:"name"` // why it goes Reason string `json:"reason"` // the tag (for a tagged version) Tag string `json:"tag,omitempty"` // the version Version string `json:"version,omitempty"` } // The values of RemoveInput's reason. const ( RemoveInputReasonTagGone = "tag-gone" RemoveInputReasonRetention = "retention" ) // RemoveAnswer is what remove answers. type RemoveAnswer struct { Artifact *Artifact `json:"artifact,omitempty"` // it stays whole, its tag and its bytes: the store cannot remove the tag alone while another tag names its digest (reason, tags) Kept bool `json:"kept,omitempty"` // why it was kept: shared-digest, another tag names its digest Reason string `json:"reason,omitempty"` // it is gone Removed bool `json:"removed"` // the other tags still naming its digest, when kept Tags []string `json:"tags,omitempty"` } // The values of RemoveAnswer's reason. const ( RemoveAnswerReasonSharedDigest = "shared-digest" ) // MirrorInput is what mirror takes. type MirrorInput struct { // its pinned digest, sha256: Digest string `json:"digest"` // the name it is kept under Name string `json:"name"` // the outside image's reference Source string `json:"source"` } // MirrorAnswer is what mirror answers. type MirrorAnswer struct { // the digest stored Digest string `json:"digest"` // the reference the seat answers Reference string `json:"reference"` } // TagsInput is what tags takes. type TagsInput struct { // the image Name string `json:"name"` } // TagsAnswerTagsItem is a type of the contract. type TagsAnswerTagsItem struct { // its digest Digest string `json:"digest"` // the tag Tag string `json:"tag"` } // TagsAnswer is what tags answers. type TagsAnswer struct { // the image Name string `json:"name"` // every tag Tags []TagsAnswerTagsItem `json:"tags"` } // HoldInput is what hold takes. type HoldInput struct { // the digest Digest string `json:"digest"` // the name Name string `json:"name"` // which of the sweep's rules keeps it Reason string `json:"reason"` } // HoldAnswer is what hold answers. type HoldAnswer struct { // it is held Held bool `json:"held"` // when the hold began, RFC 3339 Since string `json:"since,omitempty"` } // ReleaseInput is what release takes. type ReleaseInput struct { // the digest Digest string `json:"digest"` // the name Name string `json:"name"` // why it is let go Reason string `json:"reason"` } // ReleaseAnswer is what release answers. type ReleaseAnswer struct { // a hold was let go; false when there was none Released bool `json:"released"` } // ListInput is what list takes. type ListInput struct { // the repository, /; every repository of the seat when not given Name string `json:"name,omitempty"` } // ListAnswer is what list answers. type ListAnswer struct { // each repository named, in order of its name Repositories []Repository `json:"repositories"` } // PublishedEvent is the body of the event published. type PublishedEvent = Outcome // RefusedEvent is the body of the event refused. type RefusedEvent = Outcome // RemovedEvent is the body of the event removed. type RemovedEvent = Outcome // KeptEvent is the body of the event kept. type KeptEvent = Outcome // HeldEvent is the body of the event held. type HeldEvent = Hold // ReleasedEvent is the body of the event released. type ReleasedEvent = Hold // HoldsBySeatNameDigestValue is one value of the state holds under the key ... type HoldsBySeatNameDigestValue struct { By string `json:"by"` Digest string `json:"digest"` Kind string `json:"kind"` Name string `json:"name"` Seat string `json:"seat"` // when (RFC 3339 time) Since string `json:"since"` Why string `json:"why,omitempty"` } // WindowsByCallerValueDroppedItem is a type of the contract. type WindowsByCallerValueDroppedItem struct { // when (RFC 3339 time) At string `json:"at,omitempty"` By string `json:"by,omitempty"` Node string `json:"node"` Why string `json:"why,omitempty"` } // WindowsByCallerValue is one value of the state windows under the key . type WindowsByCallerValue struct { // when it last closed (RFC 3339 time) Closed string `json:"closed,omitempty"` // retired nodes dropped by hand Dropped []WindowsByCallerValueDroppedItem `json:"dropped,omitempty"` // the nodes holding it open Holding []string `json:"holding,omitempty"` LastHolding []string `json:"last_holding,omitempty"` // the caller whose window it is Name string `json:"name"` Open bool `json:"open,omitempty"` // node to when it began to hold Since map[string]string `json:"since,omitempty"` // of each node holding the window, why it holds it Why map[string]string `json:"why,omitempty"` }