From 7677052cb70b25d8a389896077212e867ea9a50b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 17 Feb 2022 21:01:52 +0100 Subject: [PATCH] build: send buildinfo dependencies Signed-off-by: CrazyMax --- build/build.go | 31 +++++++++++++------ .../exporter/containerimage/exptypes/types.go | 28 +++++++++++++++++ vendor/modules.txt | 1 + 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go diff --git a/build/build.go b/build/build.go index 9dcecb58..b7282672 100644 --- a/build/build.go +++ b/build/build.go @@ -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 } diff --git a/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go b/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go new file mode 100644 index 00000000..94f91e85 --- /dev/null +++ b/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go @@ -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 +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 66174f6f..19ad6c25 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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