diff --git a/sdk/buildstep/toolchains.go b/sdk/buildstep/toolchains.go index 6dc878f7..00d49555 100644 --- a/sdk/buildstep/toolchains.go +++ b/sdk/buildstep/toolchains.go @@ -13,15 +13,7 @@ import ( // ToolchainNoReport is the reason AgreedToolchain gives when no node has reported a language's toolchain. const ToolchainNoReport = "toolchain not yet reported" -// Toolchain is what a toolchain is identified by: the language, the installed version and the build module's recipe -// version. It has the fields of the mesh-catalog client's Toolchain2, which a caller converts it to. -type Toolchain struct { - Language string - Version string - Recipe string -} - -// NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains. +// NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains (the entry is Toolchain). type NodeToolchain struct { Node string Toolchain @@ -35,7 +27,8 @@ type SittingOut struct { Recipe string } -// Agreement is what the nodes' entries of one language come to. Toolchain is the agreed one, set when Wait is empty. +// Agreement is what the nodes' entries of one language come to. Toolchain is the agreed one (its language, version and +// recipe), set when Wait is empty. // Wait is why nothing is agreed: "toolchain not yet reported" with no entries, or "builders disagree" naming each version // and recipe with the nodes reporting it, when no version has a strict majority. SittingOut lists, sorted by node, the // nodes that report another version than the agreed one. @@ -52,14 +45,15 @@ func ToolchainAgreement(entries []NodeToolchain) Agreement { if len(entries) == 0 { return Agreement{Wait: ToolchainNoReport} } - groups := map[Toolchain][]string{} + type identity struct{ Language, Version, Recipe string } + groups := map[identity][]string{} for _, e := range entries { - k := Toolchain{Language: e.Language, Version: e.Version, Recipe: e.Recipe} + k := identity{e.Language, e.Version, e.Recipe} groups[k] = append(groups[k], e.Node) } for k, nodes := range groups { if 2*len(nodes) > len(entries) { - a := Agreement{Toolchain: k} + a := Agreement{Toolchain: Toolchain{Language: k.Language, Version: k.Version, Recipe: k.Recipe}} for _, e := range entries { if e.Version != k.Version || e.Recipe != k.Recipe { a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: e.Version, Recipe: e.Recipe})