build: send buildinfo dependencies

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-02-17 21:01:52 +01:00
parent 893d505803
commit 7677052cb7
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 51 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import (
"github.com/docker/docker/pkg/urlutil"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
gateway "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/upload/uploadprovider"
@ -1218,15 +1219,20 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
}
so.FrontendInputs[k+"::"+platform] = st
so.FrontendAttrs[v+"::"+platform] = "input:" + k + "::" + platform
dt, ok := rr.Metadata["containerimage.config/"+platform]
if !ok {
continue
metadata := make(map[string][]byte)
if dt, ok := rr.Metadata[exptypes.ExporterImageConfigKey+"/"+platform]; ok {
metadata[exptypes.ExporterImageConfigKey] = dt
}
dt, err = json.Marshal(map[string][]byte{"containerimage.config": dt})
if err != nil {
return err
if dt, ok := rr.Metadata[exptypes.ExporterBuildInfo+"/"+platform]; ok {
metadata[exptypes.ExporterBuildInfo] = dt
}
if len(metadata) > 0 {
dt, err := json.Marshal(metadata)
if err != nil {
return err
}
so.FrontendAttrs["input-metadata:"+k+"::"+platform] = string(dt)
}
so.FrontendAttrs["input-metadata:"+k+"::"+platform] = string(dt)
}
}
if rr.Ref != nil {
@ -1236,8 +1242,15 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
}
so.FrontendInputs[k] = st
so.FrontendAttrs[v] = "input:" + k
if dt, ok := rr.Metadata["containerimage.config"]; ok {
dt, err = json.Marshal(map[string][]byte{"containerimage.config": dt})
metadata := make(map[string][]byte)
if dt, ok := rr.Metadata[exptypes.ExporterImageConfigKey]; ok {
metadata[exptypes.ExporterImageConfigKey] = dt
}
if dt, ok := rr.Metadata[exptypes.ExporterBuildInfo]; ok {
metadata[exptypes.ExporterBuildInfo] = dt
}
if len(metadata) > 0 {
dt, err := json.Marshal(metadata)
if err != nil {
return err
}

View File

@ -0,0 +1,28 @@
package exptypes
import (
digest "github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
)
const (
ExporterConfigDigestKey = "config.digest"
ExporterImageDigestKey = "containerimage.digest"
ExporterImageConfigKey = "containerimage.config"
ExporterImageConfigDigestKey = "containerimage.config.digest"
ExporterImageDescriptorKey = "containerimage.descriptor"
ExporterInlineCache = "containerimage.inlinecache"
ExporterBuildInfo = "containerimage.buildinfo"
ExporterPlatformsKey = "refs.platforms"
)
const EmptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
type Platforms struct {
Platforms []Platform
}
type Platform struct {
ID string
Platform ocispecs.Platform
}

1
vendor/modules.txt vendored
View File

@ -303,6 +303,7 @@ github.com/moby/buildkit/client/connhelper
github.com/moby/buildkit/client/llb
github.com/moby/buildkit/client/ociindex
github.com/moby/buildkit/cmd/buildkitd/config
github.com/moby/buildkit/exporter/containerimage/exptypes
github.com/moby/buildkit/frontend/gateway/client
github.com/moby/buildkit/frontend/gateway/grpcclient
github.com/moby/buildkit/frontend/gateway/pb