mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
c8d/builder: Fix missing image tag event with BuildKit
The builder `Named` callback was not called with the containerd image store integration enabled and BuildKit due to wrong imageexporter output key being used. We have a test `TestBuildEmitsEvents` that should have detected the bug, but it wasn't actually working because the CLI version used in the `integration-cli` didn't support BuildKit yet. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -82,21 +82,33 @@ func (i *imageExporterInstanceWrapper) Export(ctx context.Context, src *exporter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if i.callbacks.Named != nil {
|
if i.callbacks.Named != nil {
|
||||||
for _, name := range strings.Split(out[string(exptypes.OptKeyName)], ",") {
|
i.processNamedCallback(ctx, out, desc)
|
||||||
ref, err := reference.ParseNormalizedNamed(name)
|
|
||||||
if err != nil {
|
|
||||||
// Shouldn't happen, but log if it does and continue.
|
|
||||||
log.G(ctx).WithFields(log.Fields{
|
|
||||||
"name": name,
|
|
||||||
"error": err,
|
|
||||||
}).Warn("image named with invalid reference produced by buildkit")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
namedTagged := reference.TagNameOnly(ref).(reference.NamedTagged)
|
|
||||||
i.callbacks.Named(ctx, namedTagged, desc)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out, ref, nil
|
return out, ref, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *imageExporterInstanceWrapper) processNamedCallback(ctx context.Context, out map[string]string, desc ocispec.Descriptor) {
|
||||||
|
// TODO(vvoland): Change to exptypes.ExporterImageNameKey when BuildKit v0.21 is vendored.
|
||||||
|
imageName := out["image.name"]
|
||||||
|
if imageName == "" {
|
||||||
|
log.G(ctx).Warn("image named with empty image.name produced by buildkit")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, name := range strings.Split(imageName, ",") {
|
||||||
|
ref, err := reference.ParseNormalizedNamed(name)
|
||||||
|
if err != nil {
|
||||||
|
// Shouldn't happen, but log if it does and continue.
|
||||||
|
log.G(ctx).WithFields(log.Fields{
|
||||||
|
"name": name,
|
||||||
|
"error": err,
|
||||||
|
}).Warn("image named with invalid reference produced by buildkit")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if namedTagged, ok := reference.TagNameOnly(ref).(reference.NamedTagged); ok {
|
||||||
|
i.callbacks.Named(ctx, namedTagged, desc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user