package build import ( "fmt" "time" stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/delivery" ) // BuildsSinceLimit is how many entries one answer of BuildsSinceTool reads of the log; More says the log held more. const BuildsSinceLimit = 500 // LogSince is one page of the builder's log from a time on: stdio.Log(BuilderLog).Since. type LogSince func(at time.Time, keys string, limit int) (*stdio.LogPage, error) // BuildsSince answers delivery.BuildsSinceTool (ADR 0571 clause 9): every ended build in the builder's log from since on, // oldest first, read through the runtime's log verbs; More when the page was not the log's last, so the caller asks again // from the last build's time. An entry the log holds that does not read is refused, naming its sequence: a reader that // skipped it would register too little. func BuildsSince(read LogSince, since time.Time) (delivery.BuildsSince, error) { out := delivery.BuildsSince{Since: since.UTC(), Builds: []delivery.BuildLogEntry{}} page, err := read(since, "", BuildsSinceLimit) if err != nil { return out, fmt.Errorf("the builder's log %s from %s: %w", delivery.BuilderLog, since.Format(time.RFC3339), err) } if page == nil { return out, nil } var entries []delivery.BuildLogEntry for _, le := range page.Entries { e, err := delivery.DecodeBuildLogEntry(le.Value) if err != nil { return out, fmt.Errorf("the builder's log %s, entry %d: %w", delivery.BuilderLog, le.Sequence, err) } entries = append(entries, e) } if ended := delivery.EndedSince(entries, since); ended != nil { out.Builds = ended } out.More = page.Next != 0 return out, nil }