|
|
|
@@ -2,10 +2,9 @@ package index
|
|
|
|
|
|
|
|
|
|
// The seat definitions on the bus (novox/hq ADR 0608 §2-§4, design 26 *A seat's definition*; DLV-I17-I20). The indexer
|
|
|
|
|
// reads every seat definition of a contracts module (a module whose package artifact names `generated-from`) at each
|
|
|
|
|
// trunk merge and each pull request's head the forge bridge says changed it, through the forge's get-file tool, parses
|
|
|
|
|
// it with the format's one reader (mesh-sdk seatdef), and keeps it in its own state `seat-definitions`, keyed by seat
|
|
|
|
|
// and source, as its only writer. Only the trunk's entry is the seat's contract; a pull request's entries go when it
|
|
|
|
|
// closes or merges. A trunk definition that does not parse keeps the trunk's entry and writes the finding
|
|
|
|
|
// take-in of its repository, through the forge's get-file tool, parses it with the format's one reader (mesh-sdk
|
|
|
|
|
// seatdef), and keeps it in its own state `seat-definitions`, keyed by seat, as its only writer: the trunk's entry is the
|
|
|
|
|
// seat's contract, and no pull request's is kept (design 47 H §764, H-A-48). A trunk definition that does not parse keeps the trunk's entry and writes the finding
|
|
|
|
|
// seat-definition-unparsed; a trunk defining a seat another repository's trunk already defines is refused with the
|
|
|
|
|
// finding seat-defined-twice naming both (a seat has one definition); a seat of the mesh's own contracts is taken only
|
|
|
|
|
// from its domain's contracts module, and a move there is a handover (ADR 0636 §5, domain.go); generated types out of step on a trunk, said by
|
|
|
|
@@ -21,9 +20,7 @@ import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"maps"
|
|
|
|
|
"path"
|
|
|
|
|
"slices"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
@@ -33,7 +30,6 @@ import (
|
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/seatdefs"
|
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
|
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/views"
|
|
|
|
|
)
|
|
|
|
@@ -60,22 +56,20 @@ const (
|
|
|
|
|
SeatDefinitionsAgainTool = "indexer_seat_definitions_again"
|
|
|
|
|
OutOfStepTool = "indexer_out_of_step"
|
|
|
|
|
|
|
|
|
|
// SourceTrunk and SourcePull are a definition's two sources.
|
|
|
|
|
// SourceTrunk is a definition's source: the trunk's alone (no pull request's, design 47 H §764).
|
|
|
|
|
SourceTrunk = "trunk"
|
|
|
|
|
SourcePull = "pull"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// outOfStepPrefix begins the key of a pull request's out-of-step files in the state: no seat name holds '_'.
|
|
|
|
|
// outOfStepPrefix began the key of a pull request's out-of-step files, which no take-in writes any more; a reader of the
|
|
|
|
|
// state still leaves such a key aside.
|
|
|
|
|
const outOfStepPrefix = "_out-of-step."
|
|
|
|
|
|
|
|
|
|
// SeatDefinitionEntry is one value of the state: a seat's definition from one source, resolved with the parts it
|
|
|
|
|
// includes. Unparsed is why a pull request's head's definition did not parse (it then holds no definition); a trunk's
|
|
|
|
|
// that does not parse is never written over the entry that stands.
|
|
|
|
|
// includes. A trunk's definition that does not parse is never written over the entry that stands.
|
|
|
|
|
type SeatDefinitionEntry struct {
|
|
|
|
|
Seat string `json:"seat"`
|
|
|
|
|
Source string `json:"source"`
|
|
|
|
|
Repository string `json:"repository"`
|
|
|
|
|
Pull int `json:"pull,omitempty"`
|
|
|
|
|
Module string `json:"module"`
|
|
|
|
|
Directory string `json:"directory"`
|
|
|
|
|
Commit string `json:"commit"`
|
|
|
|
@@ -91,34 +85,12 @@ type SeatDefinitionChanged struct {
|
|
|
|
|
Seat string `json:"seat"`
|
|
|
|
|
Source string `json:"source"`
|
|
|
|
|
Repository string `json:"repository"`
|
|
|
|
|
Pull int `json:"pull,omitempty"`
|
|
|
|
|
Digest string `json:"digest"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OutOfStep is a pull request's generated files out of step with their definitions, as its check's verdict said them.
|
|
|
|
|
type OutOfStep struct {
|
|
|
|
|
Repository string `json:"repository"`
|
|
|
|
|
Pull int `json:"pull"`
|
|
|
|
|
Head string `json:"head"`
|
|
|
|
|
Files []string `json:"files"`
|
|
|
|
|
At time.Time `json:"at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SeatDefinitionKey is a seat's key for a source: `<seat>.trunk`, or `<seat>.pull.<repository escaped>.<number>`.
|
|
|
|
|
func SeatDefinitionKey(seat, source, repository string, pull int) string {
|
|
|
|
|
if source == SourceTrunk {
|
|
|
|
|
return seat + "." + SourceTrunk
|
|
|
|
|
}
|
|
|
|
|
return seat + "." + pullSuffix(repository, pull)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func pullSuffix(repository string, pull int) string {
|
|
|
|
|
return SourcePull + "." + keys.EscapeName(repository) + "." + strconv.Itoa(pull)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OutOfStepKey is the key of a pull request's out-of-step files.
|
|
|
|
|
func OutOfStepKey(repository string, pull int) string {
|
|
|
|
|
return outOfStepPrefix + keys.EscapeName(repository) + "." + strconv.Itoa(pull)
|
|
|
|
|
// SeatDefinitionKey is a seat's key: `<seat>.trunk`.
|
|
|
|
|
func SeatDefinitionKey(seat string) string {
|
|
|
|
|
return seat + "." + SourceTrunk
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// errForgeRead is a read the forge did not answer (never a file it does not hold): the message is left for redelivery.
|
|
|
|
@@ -162,21 +134,17 @@ func (ix *Indexer) ApplySeatDefinitions(ctx context.Context, f whole) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewSeatDefinitionsAgain is the value indexer_seat_definitions_again writes: its key in the takeins state and the value.
|
|
|
|
|
// A pull request is named by its number and head together, or neither (the trunk's).
|
|
|
|
|
func NewSeatDefinitionsAgain(module string, pull int, head, why, by string, at time.Time) (string, []byte, error) {
|
|
|
|
|
key, data, err := NewTakeIn(module, why, by, at)
|
|
|
|
|
// It reads the trunk's definitions alone (design 47 H §764: no pull request's is kept).
|
|
|
|
|
func NewSeatDefinitionsAgain(module, why, by string, at time.Time) (string, []byte, error) {
|
|
|
|
|
module = strings.TrimSpace(module)
|
|
|
|
|
if module == "" {
|
|
|
|
|
return "", nil, errors.New("name the contracts module (module)")
|
|
|
|
|
}
|
|
|
|
|
key, err := meshcatalogclient.ModulesKey(module)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", nil, err
|
|
|
|
|
}
|
|
|
|
|
if (pull > 0) != (head != "") {
|
|
|
|
|
return "", nil, errors.New("name a pull request by its number and its head together (pull, head), or neither for the trunk")
|
|
|
|
|
}
|
|
|
|
|
var a TakeInAsk
|
|
|
|
|
if err := json.Unmarshal(data, &a); err != nil {
|
|
|
|
|
return "", nil, err
|
|
|
|
|
}
|
|
|
|
|
a.SeatDefinitions, a.Pull, a.Head = true, pull, head
|
|
|
|
|
data, err = json.Marshal(a)
|
|
|
|
|
data, err := json.Marshal(TakeInAsk{V: 1, Module: module, SeatDefinitions: true, Why: strings.TrimSpace(why), By: by, At: at.UTC()})
|
|
|
|
|
return seatDefinitionsPrefix + key, data, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -184,9 +152,8 @@ func NewSeatDefinitionsAgain(module string, pull int, head, why, by string, at t
|
|
|
|
|
const seatDefinitionsPrefix = "seat-definitions."
|
|
|
|
|
|
|
|
|
|
// SeatDefinitionsAgain reads a contracts module's seat definitions again now (indexer_seat_definitions_again): its
|
|
|
|
|
// trunk's at the commit the modules state holds it at, or a pull request's at the head given, with the head's own manifest
|
|
|
|
|
// (its generated-from as the head has it).
|
|
|
|
|
func (ix *Indexer) SeatDefinitionsAgain(ctx context.Context, module string, pull int, head string) TakenIn {
|
|
|
|
|
// trunk's at the commit the modules state holds it at.
|
|
|
|
|
func (ix *Indexer) SeatDefinitionsAgain(ctx context.Context, module string) TakenIn {
|
|
|
|
|
out := TakenIn{Module: module}
|
|
|
|
|
if ix.SeatDefinitions == nil || ix.ReadFile == nil || ix.Modules == nil {
|
|
|
|
|
out.Answer = "the indexer holds no seat-definitions state or forge reader yet"
|
|
|
|
@@ -217,35 +184,13 @@ func (ix *Indexer) SeatDefinitionsAgain(ctx context.Context, module string, pull
|
|
|
|
|
dir = meshcatalogclient.RootPath
|
|
|
|
|
}
|
|
|
|
|
whose := "its trunk's"
|
|
|
|
|
if pull > 0 {
|
|
|
|
|
// A pull request is read with its head's own manifest, so a change of generated-from is read as the head has it.
|
|
|
|
|
file := "module.json"
|
|
|
|
|
if dir != meshcatalogclient.RootPath {
|
|
|
|
|
file = path.Join(dir, file)
|
|
|
|
|
}
|
|
|
|
|
raw, err := ix.ReadFile(ctx, m.Repository, head, file)
|
|
|
|
|
switch {
|
|
|
|
|
case err != nil:
|
|
|
|
|
out.Answer = fmt.Sprintf("%s at %.12s cannot be read: %v", file, head, err)
|
|
|
|
|
return out
|
|
|
|
|
case raw == nil:
|
|
|
|
|
out.Answer = fmt.Sprintf("%s#%d's head %.12s holds no %s", m.Repository, pull, head, file)
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
manifest, whose = string(raw), fmt.Sprintf("%s#%d's head's", m.Repository, pull)
|
|
|
|
|
}
|
|
|
|
|
cs := contractsModules(map[string]string{dir: manifest})
|
|
|
|
|
if len(cs) == 0 {
|
|
|
|
|
out.Answer = module + " is no contracts module: no package artifact of " + whose + " manifest names generated-from"
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
out.Repository, out.Commit, out.Path = m.Repository, m.Commit, m.Path
|
|
|
|
|
if pull > 0 {
|
|
|
|
|
err, out.Commit = ix.keepPull(ctx, m.Repository, pull, head, cs[0]), head
|
|
|
|
|
} else {
|
|
|
|
|
err = ix.keepTrunk(ctx, m.Repository, m.Commit, cs[0])
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
if err = ix.keepTrunk(ctx, m.Repository, m.Commit, cs[0]); err != nil {
|
|
|
|
|
out.Answer = "read again, not kept: " + err.Error()
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
@@ -351,45 +296,6 @@ func (ix *Indexer) keepTrunk(ctx context.Context, repository, commit string, c c
|
|
|
|
|
return errors.Join(errs...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// keepPull writes a pull request's head definitions of a contracts module: each that parses, and each that does not
|
|
|
|
|
// with its words (its check fails on it; the trunk's entry stays).
|
|
|
|
|
func (ix *Indexer) keepPull(ctx context.Context, repository string, pull int, head string, c contractsModule) error {
|
|
|
|
|
defs, unparsed, err := ix.readDefinitions(ctx, repository, head, c)
|
|
|
|
|
if errors.Is(err, errForgeRead) {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
unparsed = map[string]string{"": err.Error()}
|
|
|
|
|
}
|
|
|
|
|
base := SeatDefinitionEntry{Source: SourcePull, Repository: repository, Pull: pull, Module: c.Module, Directory: c.Dir, Commit: head}
|
|
|
|
|
var errs []error
|
|
|
|
|
for seat, d := range defs {
|
|
|
|
|
if why := seatdefs.Refusal(c.Module, d); why != "" {
|
|
|
|
|
unparsed[seat] = why // its check fails on it, as on a definition that does not parse
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
e := base
|
|
|
|
|
e.Seat = seat
|
|
|
|
|
_, err := ix.putDefinition(ctx, e, d)
|
|
|
|
|
errs = append(errs, err)
|
|
|
|
|
}
|
|
|
|
|
for seat, why := range unparsed {
|
|
|
|
|
e := base
|
|
|
|
|
e.Seat, e.Unparsed, e.At = seat, why, ix.now().UTC()
|
|
|
|
|
if seat == "" {
|
|
|
|
|
e.Seat = c.Module // the module's index did not parse: no seat is known, the entry is named by the module
|
|
|
|
|
}
|
|
|
|
|
data, err := json.Marshal(e)
|
|
|
|
|
if err == nil {
|
|
|
|
|
err = write(ctx, ix.SeatDefinitions, SeatDefinitionKey(e.Seat, SourcePull, repository, pull), func([]byte, bool) ([]byte, bool, error) {
|
|
|
|
|
return data, false, nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
errs = append(errs, err)
|
|
|
|
|
}
|
|
|
|
|
return errors.Join(errs...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// putDefinition writes one parsed definition at its key, said when its digest moved. A trunk's definition of a seat
|
|
|
|
|
// another repository's (or module's) trunk already defines is refused, written nowhere: a seat has one definition, unless
|
|
|
|
|
// the definer is the seat's domain's module taking it over from another module of the mesh's own (a handover, domain.go).
|
|
|
|
@@ -401,7 +307,7 @@ func (ix *Indexer) putDefinition(ctx context.Context, e SeatDefinitionEntry, d s
|
|
|
|
|
}
|
|
|
|
|
e.Definition, e.Digest, e.At = raw, digest, ix.now().UTC()
|
|
|
|
|
moved, holder := false, ""
|
|
|
|
|
err = write(ctx, ix.SeatDefinitions, SeatDefinitionKey(e.Seat, e.Source, e.Repository, e.Pull), func(value []byte, found bool) ([]byte, bool, error) {
|
|
|
|
|
err = write(ctx, ix.SeatDefinitions, SeatDefinitionKey(e.Seat), func(value []byte, found bool) ([]byte, bool, error) {
|
|
|
|
|
var cur SeatDefinitionEntry
|
|
|
|
|
known := found && json.Unmarshal(value, &cur) == nil
|
|
|
|
|
moved, holder = false, ""
|
|
|
|
@@ -417,7 +323,7 @@ func (ix *Indexer) putDefinition(ctx context.Context, e SeatDefinitionEntry, d s
|
|
|
|
|
return data, false, err
|
|
|
|
|
})
|
|
|
|
|
if err == nil && moved {
|
|
|
|
|
ix.sayChanged(ctx, SeatDefinitionChanged{Seat: e.Seat, Source: e.Source, Repository: e.Repository, Pull: e.Pull, Digest: digest})
|
|
|
|
|
ix.sayChanged(ctx, SeatDefinitionChanged{Seat: e.Seat, Source: e.Source, Repository: e.Repository, Digest: digest})
|
|
|
|
|
}
|
|
|
|
|
return holder, err
|
|
|
|
|
}
|
|
|
|
@@ -452,26 +358,6 @@ func (ix *Indexer) outsideFinding(ctx context.Context, module string, outside ma
|
|
|
|
|
"Move the definition there; the next merge of "+module+" without it clears this.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dropPull removes a pull request's entries and its out-of-step files.
|
|
|
|
|
func (ix *Indexer) dropPull(ctx context.Context, repository string, pull int) error {
|
|
|
|
|
keys, err := ix.SeatDefinitions.Keys(ctx)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
suffix, oos := "."+pullSuffix(repository, pull), OutOfStepKey(repository, pull)
|
|
|
|
|
var errs []error
|
|
|
|
|
for _, key := range keys {
|
|
|
|
|
if !strings.HasSuffix(key, suffix) && key != oos {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
errs = append(errs, write(ctx, ix.SeatDefinitions, key, func(_ []byte, found bool) ([]byte, bool, error) { return nil, found, nil }))
|
|
|
|
|
if seat, ok := strings.CutSuffix(key, suffix); ok {
|
|
|
|
|
ix.sayChanged(ctx, SeatDefinitionChanged{Seat: seat, Source: SourcePull, Repository: repository, Pull: pull})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return errors.Join(errs...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ix *Indexer) sayChanged(ctx context.Context, c SeatDefinitionChanged) {
|
|
|
|
|
if ix.SaySeatDefinition == nil || c.Source != SourceTrunk {
|
|
|
|
|
return
|
|
|
|
@@ -536,7 +422,7 @@ func (ix *Indexer) ApplyOutOfStepBuild(ctx context.Context, value []byte) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if !trunkLike[e.Ref] {
|
|
|
|
|
return // a pull request's build: its check's verdict says its files
|
|
|
|
|
return // no other branch's build writes the finding
|
|
|
|
|
}
|
|
|
|
|
switch {
|
|
|
|
|
case len(e.OutOfStep) > 0:
|
|
|
|
@@ -552,37 +438,18 @@ func (ix *Indexer) ApplyOutOfStepBuild(ctx context.Context, value []byte) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ApplyVerdict keeps a pull request's out-of-step files from its check's verdict (the checker's event verdict): a
|
|
|
|
|
// verdict naming files writes them, one naming none (a clean verdict) removes them.
|
|
|
|
|
func (ix *Indexer) ApplyVerdict(ctx context.Context, repository string, pull int, head string, files []string) error {
|
|
|
|
|
if ix.SeatDefinitions == nil || repository == "" || pull <= 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return write(ctx, ix.SeatDefinitions, OutOfStepKey(repository, pull), func(_ []byte, found bool) ([]byte, bool, error) {
|
|
|
|
|
if len(files) == 0 {
|
|
|
|
|
return nil, found, nil
|
|
|
|
|
}
|
|
|
|
|
fs := slices.Clone(files)
|
|
|
|
|
slices.Sort(fs)
|
|
|
|
|
data, err := json.Marshal(OutOfStep{Repository: repository, Pull: pull, Head: head, Files: fs, At: ix.now().UTC()})
|
|
|
|
|
return data, false, err
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SeatDefinitionAnswer is indexer_seat_definition's answer: which source it answered, and the entry.
|
|
|
|
|
type SeatDefinitionAnswer struct {
|
|
|
|
|
Seat string `json:"seat"`
|
|
|
|
|
Answered string `json:"answered"`
|
|
|
|
|
Found bool `json:"found"`
|
|
|
|
|
Entry *SeatDefinitionEntry `json:"entry,omitempty"`
|
|
|
|
|
Trunk *SeatDefinitionEntry `json:"trunk,omitempty"`
|
|
|
|
|
Revision uint64 `json:"revision"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SeatDefinitionOf answers indexer_seat_definition from the state: the trunk's entry, unless a pull request (repository
|
|
|
|
|
// and number) is named, whose entry is answered with the trunk's beside it; Answered says which. A pull request holding
|
|
|
|
|
// no entry for the seat answers the trunk's, saying so. The revision is the views mark the state was said up to.
|
|
|
|
|
func SeatDefinitionOf(defs, marks views.Source, seat, repository string, pull int) (SeatDefinitionAnswer, error) {
|
|
|
|
|
// SeatDefinitionOf answers indexer_seat_definition from the state: the trunk's entry (no pull request's is kept, design 47
|
|
|
|
|
// H §764). The revision is the views mark the state was said up to.
|
|
|
|
|
func SeatDefinitionOf(defs, marks views.Source, seat string) (SeatDefinitionAnswer, error) {
|
|
|
|
|
if seat == "" {
|
|
|
|
|
return SeatDefinitionAnswer{}, fmt.Errorf("%s names the seat", SeatDefinitionTool)
|
|
|
|
|
}
|
|
|
|
@@ -601,22 +468,11 @@ func SeatDefinitionOf(defs, marks views.Source, seat, repository string, pull in
|
|
|
|
|
return &e, nil
|
|
|
|
|
}
|
|
|
|
|
out := SeatDefinitionAnswer{Seat: seat, Answered: SourceTrunk, Revision: markOf(marks)}
|
|
|
|
|
trunk, err := get(SeatDefinitionKey(seat, SourceTrunk, "", 0))
|
|
|
|
|
trunk, err := get(SeatDefinitionKey(seat))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return out, err
|
|
|
|
|
}
|
|
|
|
|
out.Entry, out.Found = trunk, trunk != nil
|
|
|
|
|
if pull > 0 {
|
|
|
|
|
p, err := get(SeatDefinitionKey(seat, SourcePull, repository, pull))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return out, err
|
|
|
|
|
}
|
|
|
|
|
if p != nil {
|
|
|
|
|
out.Answered, out.Entry, out.Trunk, out.Found = fmt.Sprintf("%s#%d", repository, pull), p, trunk, true
|
|
|
|
|
} else {
|
|
|
|
|
out.Answered = SourceTrunk + fmt.Sprintf(" (%s#%d holds no definition of %s)", repository, pull, seat)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return out, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -636,19 +492,16 @@ func markOf(marks views.Source) uint64 {
|
|
|
|
|
return m.Revision
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OutOfStepRow is one row of indexer_out_of_step: a trunk's contracts module (from its finding) or a pull request.
|
|
|
|
|
// OutOfStepRow is one row of indexer_out_of_step: a trunk's contracts module, from its finding.
|
|
|
|
|
type OutOfStepRow struct {
|
|
|
|
|
Source string `json:"source"`
|
|
|
|
|
Module string `json:"module,omitempty"`
|
|
|
|
|
Pull string `json:"pull,omitempty"`
|
|
|
|
|
Head string `json:"head,omitempty"`
|
|
|
|
|
Files []string `json:"files,omitempty"`
|
|
|
|
|
Summary string `json:"summary,omitempty"`
|
|
|
|
|
Source string `json:"source"`
|
|
|
|
|
Module string `json:"module,omitempty"`
|
|
|
|
|
Summary string `json:"summary,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OutOfStepOf answers indexer_out_of_step: every trunk contracts module whose finding generated-types-out-of-step
|
|
|
|
|
// stands, then every pull request whose check's verdict named out-of-step files.
|
|
|
|
|
func OutOfStepOf(own string, defs, findings views.Source) ([]OutOfStepRow, error) {
|
|
|
|
|
// stands.
|
|
|
|
|
func OutOfStepOf(own string, findings views.Source) ([]OutOfStepRow, error) {
|
|
|
|
|
out := []OutOfStepRow{}
|
|
|
|
|
fkeys, err := findings.Keys()
|
|
|
|
|
if err != nil {
|
|
|
|
@@ -666,25 +519,6 @@ func OutOfStepOf(own string, defs, findings views.Source) ([]OutOfStepRow, error
|
|
|
|
|
}
|
|
|
|
|
out = append(out, OutOfStepRow{Source: SourceTrunk, Module: strings.TrimPrefix(f.Subject.ID, own+".out-of-step."), Summary: f.Summary})
|
|
|
|
|
}
|
|
|
|
|
keys, err := defs.Keys()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("the %s state cannot be listed: %w", SeatDefinitionsState, err)
|
|
|
|
|
}
|
|
|
|
|
slices.Sort(keys)
|
|
|
|
|
for _, key := range keys {
|
|
|
|
|
if !strings.HasPrefix(key, outOfStepPrefix) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
v, ok, err := defs.Get(key)
|
|
|
|
|
if err != nil || !ok || v == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
var o OutOfStep
|
|
|
|
|
if json.Unmarshal(v.Value, &o) != nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
out = append(out, OutOfStepRow{Source: SourcePull, Pull: fmt.Sprintf("%s#%d", o.Repository, o.Pull), Head: o.Head, Files: o.Files})
|
|
|
|
|
}
|
|
|
|
|
return out, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -704,10 +538,10 @@ type SeatDefinition struct {
|
|
|
|
|
|
|
|
|
|
// SeatDefinitionsOf answers the verb seat-definitions of the seat mesh-catalog (ADR 0636 §4) from the state: with no
|
|
|
|
|
// seat, every trunk seat with its digest, by seat; with a seat, that seat's trunk definition (found false when the trunk
|
|
|
|
|
// holds none). Never a pull request's: a running part acts on what is merged.
|
|
|
|
|
// holds none).
|
|
|
|
|
func SeatDefinitionsOf(defs, marks views.Source, seat string) (any, error) {
|
|
|
|
|
if seat != "" {
|
|
|
|
|
a, err := SeatDefinitionOf(defs, marks, seat, "", 0)
|
|
|
|
|
a, err := SeatDefinitionOf(defs, marks, seat)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|