package builds import ( "git.novox.be/novox/mesh-sdk/go/keys" ) // The builder says each done build's end itself, as an event on its own stream (design 47 G ยง379, A-96): the stream // BuildsStream carries `build.ended..` (each part escaped), published where the log entry of the end is // written. A part that wants a build's parts or its keeping node hears it (the assigner consumes `mesh-delivery-builder.build.ended`). const ( // BuildsStream is the builder's stream of build ends, named by its manifest's `streams` entry. BuildsStream = "mesh-delivery-builder-builds" // BuildsStreamEvents is the pattern of the events that entry carries. BuildsStreamEvents = BuildEndedEvent + ".**" ) // BuildEnded is the body of the event build.ended: the module, the fingerprint, each artifact made with its digest, the build // node that keeps a kept build (none for one not kept) and the watched branch a build of a candidate is for (none for the trunk). type BuildEnded struct { Module string `json:"module"` Fingerprint string `json:"fingerprint"` Made map[string]string `json:"made,omitempty"` KeptOn string `json:"kept-on,omitempty"` Branch string `json:"branch,omitempty"` } // BuildEndedEventName is the event's name for a module and fingerprint: `build.ended..`, each escaped. func BuildEndedEventName(module, fp string) string { return BuildEndedEvent + "." + keys.EscapeName(module) + "." + keys.EscapeName(fp) } // BuildEndedOf is the event of a log entry of a build's end: false for any entry but the end of a done build, which says no // digest of any part. func BuildEndedOf(e BuildLogEntry) (BuildEnded, bool) { if e.Event != BuildEndedEvent || e.Outcome != BuildDone || e.Module == "" || e.FP == "" { return BuildEnded{}, false } made := map[string]string{} for _, a := range e.Made { made[a.Name] = a.Digest } return BuildEnded{Module: e.Module, Fingerprint: e.FP, Made: made, KeptOn: e.KeptOn, Branch: e.Ref}, true }