c8d/progress: Show Mounted/Exists status

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-10-03 14:06:00 +02:00
parent 056be8b7b0
commit bcbbd9538f
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -8,9 +8,11 @@ import (
"github.com/containerd/containerd/content"
cerrdefs "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/log"
"github.com/distribution/reference"
"github.com/docker/docker/internal/compatcontext"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/stringid"
@ -209,8 +211,18 @@ func (p *pushProgress) UpdateProgress(ctx context.Context, ongoing *jobs, out pr
}
if status.Committed && status.Offset >= status.Total {
if p.isMountable(j.Digest) {
progress.Update(out, id, "Mounted")
if status.MountedFrom != "" {
from := status.MountedFrom
if ref, err := reference.ParseNormalizedNamed(from); err == nil {
from = reference.Path(ref)
}
progress.Update(out, id, "Mounted from "+from)
} else if status.Exists {
if images.IsLayerType(j.MediaType) {
progress.Update(out, id, "Layer already exists")
} else {
progress.Update(out, id, "Already exists")
}
} else {
progress.Update(out, id, "Pushed")
}