transfer: add OCI descriptors to Progress structure

The index media type and the digest are now shown in `ctr images pull --local=false`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2024-01-11 23:29:50 +09:00
parent a2f167e836
commit a2472c0b5a
10 changed files with 97 additions and 26 deletions

View File

@@ -25,11 +25,13 @@ import (
transferapi "github.com/containerd/containerd/v2/api/services/transfer/v1"
transfertypes "github.com/containerd/containerd/v2/api/types/transfer"
"github.com/containerd/containerd/v2/oci"
"github.com/containerd/containerd/v2/pkg/streaming"
"github.com/containerd/containerd/v2/pkg/transfer"
tstreaming "github.com/containerd/containerd/v2/pkg/transfer/streaming"
"github.com/containerd/log"
"github.com/containerd/typeurl/v2"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
type proxyTransferrer struct {
@@ -74,12 +76,18 @@ func (p *proxyTransferrer) Transfer(ctx context.Context, src interface{}, dst in
}
switch v := i.(type) {
case *transfertypes.Progress:
var descp *ocispec.Descriptor
if v.Desc != nil {
desc := oci.DescriptorFromProto(v.Desc)
descp = &desc
}
o.Progress(transfer.Progress{
Event: v.Event,
Name: v.Name,
Parents: v.Parents,
Progress: v.Progress,
Total: v.Total,
Desc: descp,
})
default:
log.G(ctx).Warnf("unhandled progress object %T: %v", i, a.GetTypeUrl())