mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-20 02:17:44 +08:00
build: fix multi-node merge to read descriptor from result
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> (cherry picked from commit c33b310b48a6b0467f25f89aa941ec4e453460d4)
This commit is contained in:
parent
5a4f80f3ce
commit
7776652a4d
@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
_ "crypto/sha256" // ensure digests can be computed
|
_ "crypto/sha256" // ensure digests can be computed
|
||||||
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -1157,7 +1158,24 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||||||
descs := make([]specs.Descriptor, 0, len(res))
|
descs := make([]specs.Descriptor, 0, len(res))
|
||||||
|
|
||||||
for _, r := range res {
|
for _, r := range res {
|
||||||
s, ok := r.ExporterResponse[exptypes.ExporterImageDigestKey]
|
s, ok := r.ExporterResponse[exptypes.ExporterImageDescriptorKey]
|
||||||
|
if ok {
|
||||||
|
dt, err := base64.StdEncoding.DecodeString(s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var desc specs.Descriptor
|
||||||
|
if err := json.Unmarshal(dt, &desc); err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to unmarshal descriptor %s", s)
|
||||||
|
}
|
||||||
|
descs = append(descs, desc)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// This is fallback for some very old buildkit versions.
|
||||||
|
// Note that the mediatype isn't really correct as most of the time it is image manifest and
|
||||||
|
// not manifest list but actually both are handled because for Docker mediatypes the
|
||||||
|
// mediatype value in the Accpet header does not seem to matter.
|
||||||
|
s, ok = r.ExporterResponse[exptypes.ExporterImageDigestKey]
|
||||||
if ok {
|
if ok {
|
||||||
descs = append(descs, specs.Descriptor{
|
descs = append(descs, specs.Descriptor{
|
||||||
Digest: digest.Digest(s),
|
Digest: digest.Digest(s),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user