Node-engine: a digest the want's parts name always counts as fetched (A-454a)
Builds: design 47 G A-454a
This commit is contained in:
@@ -380,6 +380,14 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) {
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{upstream}); !strings.Contains(got, "in the want's parts and not fetched: "+d3) || strings.Contains(got, d2) {
|
||||
t.Fatalf("with only an upstream image the mesh-built one is not missing, or the upstream one is named: %q", got)
|
||||
}
|
||||
// A-454a: a mesh-built image whose seat holder is not on record carries no image-seat; its digest is in the parts, so it is fetched.
|
||||
noSeat := json.RawMessage(`{"id":"web.n","type":"container","name":"web-n","image":"store/web@` + d3 + `","module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat}); got != "" {
|
||||
t.Fatalf("a mesh-built image with no image-seat, named by the parts, is not fetched: %q", got)
|
||||
}
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat, upstream}); got != "" {
|
||||
t.Fatalf("an upstream image beside it is a part: %q", got)
|
||||
}
|
||||
// A-432: a runtime of its own runs the tool runner's program, which the module's parts do not name.
|
||||
ownRuntime := json.RawMessage(`{"id":"web.own-runtime","type":"process","name":"web-runtime","source":"store/node-tools","digest":"` + d1 + `","run":["./node-tools"],"module":"web"}`)
|
||||
if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, ownRuntime}); got != "" {
|
||||
|
||||
+17
-7
@@ -64,6 +64,10 @@ func partsDifference(parts map[string]string, resources []json.RawMessage) strin
|
||||
if len(parts) == 0 {
|
||||
return ""
|
||||
}
|
||||
inParts := map[string]bool{}
|
||||
for _, d := range parts {
|
||||
inParts[d] = true
|
||||
}
|
||||
fetched := map[string]bool{}
|
||||
for _, raw := range resources {
|
||||
r, err := declaration.ParseResource(raw)
|
||||
@@ -81,16 +85,22 @@ func partsDifference(parts map[string]string, resources []json.RawMessage) strin
|
||||
fetched[res.Digest] = true
|
||||
}
|
||||
case *declaration.Container:
|
||||
// Only an image the mesh built is a part: the composition names the seat it came through (the artifact store or a
|
||||
// registry seat) beside it. An image the manifest pins from outside, by its digest, is no part (design 47 G A-454).
|
||||
if res.ImageSeat == "" || upstreamCopy(res.Image) {
|
||||
// A digest the want's parts name always counts as fetched, whatever marks the resource carries; one they do not
|
||||
// name counts only when it is the mesh's own: an image the manifest pins from outside, or the registry seat's
|
||||
// copy of an upstream image, is no part (design 47 G A-454, A-454a).
|
||||
digest := ""
|
||||
if strings.HasPrefix(res.Image, "sha256:") {
|
||||
digest = res.Image
|
||||
} else if _, d, ok := strings.Cut(res.Image, "@"); ok {
|
||||
digest = d
|
||||
}
|
||||
if digest == "" {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(res.Image, "sha256:") {
|
||||
fetched[res.Image] = true
|
||||
} else if _, digest, ok := strings.Cut(res.Image, "@"); ok {
|
||||
fetched[digest] = true
|
||||
if !inParts[digest] && (res.ImageSeat == "" || upstreamCopy(res.Image)) {
|
||||
continue
|
||||
}
|
||||
fetched[digest] = true
|
||||
}
|
||||
}
|
||||
named := map[string]bool{}
|
||||
|
||||
Reference in New Issue
Block a user