assigner: read an entry's fp-src, and key a release's parts by the reference it names
The candidate placing mesh-delivery-pipeline 0.1.6 on novox carried no parts, though its version-released was heard: the assigner's module value of a catalog entry dropped the entry's inputs, so every trunk entry had fp-src 0 and A-419 never matched; and a release's parts were keyed <module>:<artifact> by prefixing the module to the artifact the event names, which the contract gives whole (mesh-delivery-pipeline:program), so every release's parts read mesh-delivery-pipeline:mesh-delivery-pipeline:program and A-421's match by digests missed too. The value now carries the entry's src and fp-src, and a release's part is keyed by its reference as named. Builds: design 47 G A-419, A-421, A-96
This commit is contained in:
@@ -100,7 +100,7 @@ func (r *releasedVersions) put(data []byte) error {
|
||||
}
|
||||
parts := map[string]string{}
|
||||
for _, a := range e.Artifacts {
|
||||
parts[e.Module+":"+a.Artifact] = a.Digest
|
||||
parts[partRef(e.Module, a.Artifact)] = a.Digest
|
||||
}
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
@@ -224,3 +224,12 @@ func compareVersion(a, b string) int {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// partRef is a release's artifact as a part's key, `<module>:<artifact>`: the contract's VersionArtifact names the artifact
|
||||
// reference whole (an ArtifactRef), as the catalog's version-released says it; a bare name is taken as the module's (A-96).
|
||||
func partRef(module, artifact string) string {
|
||||
if strings.Contains(artifact, ":") {
|
||||
return artifact
|
||||
}
|
||||
return module + ":" + artifact
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestAVersionReleasedHeardNamesItsVersionAndPartsBySource(t *testing.T) {
|
||||
// revision kept, another fingerprint, an fp-src with no release or none names none, and an unheard release is said once.
|
||||
func TestATrunkEntryTakesItsVersionFromTheReleaseOfItsFingerprintsSource(t *testing.T) {
|
||||
w := newWorld()
|
||||
raw, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "image", Digest: "sha256:9"}}})
|
||||
raw, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "mail:image", Digest: "sha256:9"}}})
|
||||
if err := w.released.put(raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -92,6 +92,11 @@ func TestATrunkEntryTakesItsVersionFromTheReleaseOfItsFingerprintsSource(t *test
|
||||
if _, ok := p.namedBuild("mail", "t", 0)("t"); ok {
|
||||
t.Error("an entry naming no fp-src, whose build.ended is not heard, names a version")
|
||||
}
|
||||
// The release names each artifact by its whole reference, as the catalog says it, and the parts are keyed so (A-96); the
|
||||
// assigner reads the entry's fp-src from its inputs (A-419).
|
||||
if v, _, _ := fromEntry(meshcatalog.CatalogEntry{Module: "mail", Fp: "t", Inputs: &meshcatalog.EntryInputs{Src: 9, FpSrc: 7}}); v.FpSrc != 7 || v.Src != 9 {
|
||||
t.Errorf("the entry's module value carries fp-src %d and src %d, want 7 and 9", v.FpSrc, v.Src)
|
||||
}
|
||||
// A-421: an entry naming no fp-src takes the release whose parts are what its build.ended made.
|
||||
made, _ := json.Marshal(builds.BuildEnded{Module: "mail", Fingerprint: "t", Made: map[string]string{"image": "sha256:9"}})
|
||||
if err := w.ends.put(made); err != nil {
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestACandidateThatAddsAModuleCarriesItsParts(t *testing.T) {
|
||||
w.putModule("main", m, meshcatalog.ModulesByModuleValue{Fp2: "fp-" + m, FpSrc: 7}, graph.Node{}, nil)
|
||||
}
|
||||
w.first = "main"
|
||||
rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "image", Digest: "sha256:9"}}})
|
||||
rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "mail:image", Digest: "sha256:9"}}})
|
||||
if err := w.released.put(rel); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -148,6 +148,11 @@ func (h *halves) changed(branch, module string, raw json.RawMessage, deleted boo
|
||||
func fromEntry(e meshcatalog.CatalogEntry) (meshcatalog.ModulesByModuleValue, graph.Node, *parsed) {
|
||||
v := meshcatalog.ModulesByModuleValue{Commit: e.Commit, Fp2: e.Fp, Needs: e.Needs, None2: e.None, Packages: e.Packages,
|
||||
Path: e.Path, Repository: e.Repository, Verdict: e.Verdict}
|
||||
// The source revisions it was taken in at and its fingerprint was built at: the release of a trunk build is matched by the
|
||||
// latter (design 47 G A-419).
|
||||
if e.Inputs != nil {
|
||||
v.Src, v.FpSrc = e.Inputs.Src, e.Inputs.FpSrc
|
||||
}
|
||||
n := graph.Node{FP: e.Fp, None: e.None, Repository: e.Repository, Path: e.Path, Bases: e.Bases, Provides: e.Provides, Requires: e.Requires,
|
||||
Awaits: e.Awaits, Invokes: e.Invokes, Serves: e.Serves, LeftOut: e.LeftOut}
|
||||
for p := range e.Packages {
|
||||
|
||||
Reference in New Issue
Block a user