1
0
mirror of https://github.com/moby/buildkit.git synced 2025-07-27 16:41:49 +03:00

Dedupe "containerd.io/uncompressed" constants and literals

Dedupe the several "containerd.io/uncompressed" constants and literals
into `github.com/containerd/containerd/labels.LabelUncompressed`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2023-07-25 02:55:49 +09:00
parent 8656037191
commit 67f3e79553
18 changed files with 63 additions and 50 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
labelspkg "github.com/containerd/containerd/labels"
"github.com/containerd/containerd/mount"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/compression"
@ -69,7 +70,7 @@ func (sr *immutableRef) tryComputeOverlayBlob(ctx context.Context, lower, upper
if labels == nil {
labels = map[string]string{}
}
labels[containerdUncompressed] = dgstr.Digest().String()
labels[labelspkg.LabelUncompressed] = dgstr.Digest().String()
} else {
if err = overlay.WriteUpperdir(ctx, bufW, upperdir, lower); err != nil {
return emptyDesc, false, errors.Wrap(err, "failed to write diff")
@ -101,9 +102,9 @@ func (sr *immutableRef) tryComputeOverlayBlob(ctx context.Context, lower, upper
cinfo.Labels = make(map[string]string)
}
// Set uncompressed label if digest already existed without label
if _, ok := cinfo.Labels[containerdUncompressed]; !ok {
cinfo.Labels[containerdUncompressed] = labels[containerdUncompressed]
if _, err := sr.cm.ContentStore.Update(ctx, cinfo, "labels."+containerdUncompressed); err != nil {
if _, ok := cinfo.Labels[labelspkg.LabelUncompressed]; !ok {
cinfo.Labels[labelspkg.LabelUncompressed] = labels[labelspkg.LabelUncompressed]
if _, err := sr.cm.ContentStore.Update(ctx, cinfo, "labels."+labelspkg.LabelUncompressed); err != nil {
return emptyDesc, false, errors.Wrap(err, "error setting uncompressed label")
}
}