Files
mesh-delivery/modules/mesh-delivery-checker/internal/check/composition.go
T

43 lines
1.7 KiB
Go

package check
import (
"strings"
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshdeliverycheckerclient"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
)
// withComposition is v with the check's composition taken in: a failed one fails the check, naming its machine.
func withComposition(v *meshdeliverychecker.VerdictsByGroupHeadsValue, comp meshwants.CompositionsByGroupHeadsValue) {
v.Composition = compositionOf(comp)
if v.Took == nil {
v.Took = &meshdeliverychecker.VerdictsByGroupHeadsValueTook{}
}
v.Took.Composition = comp.Took
if comp.State == meshdeliverycheckerclient.CompositionPass && len(comp.Warnings) > 0 && v.Composition != nil {
v.Composition.Words = strings.Join(comp.Warnings, "; ") // passed with a warning (ADR 0593 §9)
}
if comp.State == meshdeliverycheckerclient.CompositionFail {
machine := comp.Machine
if machine == "" {
machine = "the composition"
}
f := FailedFirst{Machine: machine, Words: comp.Words}
if v.State == meshdeliverycheckerclient.VerdictFail {
addFailure(v, f) // the tests failed too: the composition is named after them (the operator, 2026-11-02)
return
}
v.State, v.Failed = meshdeliverycheckerclient.VerdictFail, &f
}
}
// compositionOf is what the checker writes into its verdict from the assigner's composition answer c: nil while c waits (the
// check is still running).
func compositionOf(c meshwants.CompositionsByGroupHeadsValue) *meshdeliverychecker.VerdictsByGroupHeadsValueComposition {
if c.State == compositionWaits {
return nil
}
return &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: c.State, Words: c.Words, Sdk: c.Sdk, Machines: c.Machines}
}