Cleanup code comments and lint fixes

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2022-11-14 16:21:14 -08:00
parent f1598cf5e8
commit fc2754204f
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB
9 changed files with 18 additions and 34 deletions

View File

@ -38,4 +38,4 @@ message ImageExportStream {
string stream = 1;
string media_type = 2;
}
}

View File

@ -26,4 +26,4 @@ message Progress {
repeated string parents = 3;
int64 progress = 4;
int64 total = 5;
}
}

View File

@ -101,7 +101,6 @@ func (ts *localTransferService) importStream(ctx context.Context, i transfer.Ima
tops.Progress(transfer.Progress{
Event: "saved",
Name: img.Name,
//Digest: img.Target.Digest.String(),
})
}
}

View File

@ -100,10 +100,9 @@ func (j *ProgressTracker) HandleProgress(ctx context.Context, pf transfer.Progre
if ok {
if status.Offset > job.progress {
pf(transfer.Progress{
Event: j.transferState,
Name: job.name,
Parents: job.parents,
//Digest: job.desc.Digest.String(),
Event: j.transferState,
Name: job.name,
Parents: job.parents,
Progress: status.Offset,
Total: status.Total,
})
@ -117,10 +116,9 @@ func (j *ProgressTracker) HandleProgress(ctx context.Context, pf transfer.Progre
log.G(ctx).WithError(err).Error("failed to get statuses for progress")
} else if ok {
pf(transfer.Progress{
Event: "complete",
Name: job.name,
Parents: job.parents,
//Digest: job.desc.Digest.String(),
Event: "complete",
Name: job.name,
Parents: job.parents,
Progress: job.desc.Size,
Total: job.desc.Size,
})

View File

@ -18,6 +18,7 @@ package proxy
import (
"context"
"errors"
"io"
transferapi "github.com/containerd/containerd/api/services/transfer/v1"
@ -61,7 +62,7 @@ func (p *proxyTransferer) Transfer(ctx context.Context, src interface{}, dst int
for {
a, err := stream.Recv()
if err != nil {
if err != io.EOF {
if !errors.Is(err, io.EOF) {
log.G(ctx).WithError(err).Error("progress stream failed to recv")
}
return

View File

@ -113,7 +113,7 @@ func SendStream(ctx context.Context, r io.Reader, stream streaming.Stream) {
b := (*buf)[:max]
n, err := r.Read(b)
if err != nil {
if err != io.EOF {
if !errors.Is(err, io.EOF) {
log.G(ctx).WithError(err).Errorf("failed to read stream source")
// TODO: Send error message on stream before close to allow remote side to return error
}

View File

@ -85,7 +85,7 @@ type ImageExportStreamer interface {
}
type ImageUnpacker interface {
// TODO: Or unpack options?
// TODO: consider using unpack options
UnpackPlatforms() []unpack.Platform
}
@ -103,6 +103,10 @@ func WithProgress(f ProgressFunc) Opt {
}
}
// Progress is used to represent a particular progress event or incremental
// update for the provided named object. The parents represent the names of
// the objects which initiated the progress for the provided named object.
// The name and what object it represents is determined by the implementation.
type Progress struct {
Event string
Name string
@ -111,21 +115,3 @@ type Progress struct {
Total int64
// Descriptor?
}
/*
// Distribution options
// Stream handler
// Progress rate
// Unpack options
// Remote options
// Cases:
// Registry -> Content/ImageStore (pull)
// Registry -> Registry
// Content/ImageStore -> Registry (push)
// Content/ImageStore -> Content/ImageStore (tag)
// Common fetch/push interface for registry, content/imagestore, OCI index
// Always starts with string for source and destination, on client side, does not need to resolve
// Higher level implementation just takes strings and options
// Lower level implementation takes pusher/fetcher?
*/

View File

@ -17,6 +17,7 @@
package streaming
import (
"errors"
"io"
api "github.com/containerd/containerd/api/services/streaming/v1"
@ -107,7 +108,7 @@ func (ss *serviceStream) Send(a typeurl.Any) error {
func (ss *serviceStream) Recv() (a typeurl.Any, err error) {
a, err = ss.s.Recv()
if err != io.EOF {
if !errors.Is(err, io.EOF) {
err = errdefs.FromGRPC(err)
}
return

View File

@ -119,7 +119,6 @@ func (s *service) Transfer(ctx context.Context, req *transferapi.TransferRequest
return nil, errdefs.ToGRPC(err)
}
dst, err := s.convertAny(ctx, req.Destination)
plugins.ResolveType(req.Source)
if err != nil {
return nil, errdefs.ToGRPC(err)
}