diff --git a/go/delivery/builder.go b/go/delivery/builder.go index 981bca7..447196d 100644 --- a/go/delivery/builder.go +++ b/go/delivery/builder.go @@ -184,10 +184,10 @@ type BuilderBuild struct { // does not yet hold: the key is not claimed until that package's trunk key is done and published (novox/hq ADR 0500 // clause 6). A reader that does not know the field reads the key as queued. Waits string `json:"waits,omitempty"` - // Asks are, on a building key, the ids of the asks the builder put for it (novox/hq ADR 0525 §1; issue 1887 A4b): a - // builder that takes the key over at its start waits for those asks' steps and never puts them again. A reader that - // does not know the field reads the key as before. - Asks []string `json:"asks,omitempty"` + // Asks are, on a building key, the asks the builder put for it by build seat language (AskGo, AskNode, AskImage), each + // its id (novox/hq ADR 0525 §1; issue 1887 A4b): a builder that takes the key over at its start waits for those asks' + // steps and never puts them again. A reader that does not know the field reads the key as before. + Asks map[string]string `json:"asks,omitempty"` } func (b BuilderBuild) check() error { @@ -220,10 +220,13 @@ func (b BuilderBuild) check() error { return fmt.Errorf("delivery: the reference %q of the %s %q %s", a.Reference, a.Kind, a.Name, p) } } - for _, id := range b.Asks { + for language, id := range b.Asks { if b.State != BuildBuilding { return fmt.Errorf("delivery: a %s build names the ask %s; only a building key does", b.State, id) } + if err := checkAskLanguage(language); err != nil { + return err + } if err := checkAskID(id); err != nil { return err } diff --git a/go/delivery/stepasks_test.go b/go/delivery/stepasks_test.go index a8d2d11..1cf1ad6 100644 --- a/go/delivery/stepasks_test.go +++ b/go/delivery/stepasks_test.go @@ -127,18 +127,19 @@ func TestAskSubjects(t *testing.T) { // 1887/A4b: a building key names the asks put for it; a done key or a name that is no ask id is refused. func TestABuildingKeyNamesItsAsks(t *testing.T) { - b := BuilderBuild{State: BuildBuilding, By: "novox.builder", Asks: []string{"mh3k2x9qa1b2c3"}} + b := BuilderBuild{State: BuildBuilding, By: "novox.builder", Asks: map[string]string{AskGo: "mh3k2x9qa1b2c3"}} raw, err := EncodeBuilderBuild(b) if err != nil { t.Fatal(err) } got, err := DecodeBuilderBuild(raw) - if err != nil || len(got.Asks) != 1 || got.Asks[0] != "mh3k2x9qa1b2c3" { + if err != nil || len(got.Asks) != 1 || got.Asks[AskGo] != "mh3k2x9qa1b2c3" { t.Fatalf("decoded %+v, %v", got, err) } for _, bad := range []BuilderBuild{ - {State: BuildBuilding, Asks: []string{"postgres"}}, - {State: BuildFailed, Error: "x", Asks: []string{"mh3k2x9qa1b2c3"}}, + {State: BuildBuilding, Asks: map[string]string{AskGo: "postgres"}}, + {State: BuildBuilding, Asks: map[string]string{"typescript": "mh3k2x9qa1b2c3"}}, + {State: BuildFailed, Error: "x", Asks: map[string]string{AskGo: "mh3k2x9qa1b2c3"}}, } { if _, err := EncodeBuilderBuild(bad); err == nil { t.Errorf("encoded %+v", bad)