| @@ -41,6 +41,10 @@ linters-settings: | |||||||
|       - G306 |       - G306 | ||||||
|       - G402 |       - G402 | ||||||
|       - G404 |       - G404 | ||||||
|  |   misspell: | ||||||
|  |     ignore-words: | ||||||
|  |       - transferer | ||||||
|  |       - transferers | ||||||
|  |  | ||||||
| run: | run: | ||||||
|   timeout: 8m |   timeout: 8m | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	// TODO: Move this to seperate package? | 	// TODO: Move this to separate package? | ||||||
| 	plugins.Register(&transfertypes.ImageExportStream{}, &ImageExportStream{}) | 	plugins.Register(&transfertypes.ImageExportStream{}, &ImageExportStream{}) | ||||||
| 	plugins.Register(&transfertypes.ImageImportStream{}, &ImageImportStream{}) | 	plugins.Register(&transfertypes.ImageImportStream{}, &ImageImportStream{}) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -34,11 +34,11 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	// TODO: Move this to seperate package? | 	// TODO: Move this to separate package? | ||||||
| 	plugins.Register(&transfertypes.ImageStore{}, &ImageStore{}) // TODO: Rename ImageStoreDestination | 	plugins.Register(&transfertypes.ImageStore{}, &Store{}) // TODO: Rename ImageStoreDestination | ||||||
| } | } | ||||||
|  |  | ||||||
| type ImageStore struct { | type Store struct { | ||||||
| 	// TODO: Put these configurations in object which can convert to/from any | 	// TODO: Put these configurations in object which can convert to/from any | ||||||
| 	// Embed generated type | 	// Embed generated type | ||||||
| 	imageName     string | 	imageName     string | ||||||
| @@ -52,17 +52,17 @@ type ImageStore struct { | |||||||
| 	unpacks []unpack.Platform | 	unpacks []unpack.Platform | ||||||
| } | } | ||||||
|  |  | ||||||
| func NewImageStore(image string) *ImageStore { | func NewStore(image string) *Store { | ||||||
| 	return &ImageStore{ | 	return &Store{ | ||||||
| 		imageName: image, | 		imageName: image, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) String() string { | func (is *Store) String() string { | ||||||
| 	return fmt.Sprintf("Local Image Store (%s)", is.imageName) | 	return fmt.Sprintf("Local Image Store (%s)", is.imageName) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) FilterHandler(h images.HandlerFunc, cs content.Store) images.HandlerFunc { | func (is *Store) FilterHandler(h images.HandlerFunc, cs content.Store) images.HandlerFunc { | ||||||
| 	h = images.SetChildrenMappedLabels(cs, h, is.labelMap) | 	h = images.SetChildrenMappedLabels(cs, h, is.labelMap) | ||||||
| 	if is.allMetadata { | 	if is.allMetadata { | ||||||
| 		// Filter manifests by platforms but allow to handle manifest | 		// Filter manifests by platforms but allow to handle manifest | ||||||
| @@ -80,7 +80,7 @@ func (is *ImageStore) FilterHandler(h images.HandlerFunc, cs content.Store) imag | |||||||
| 	return h | 	return h | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) Store(ctx context.Context, desc ocispec.Descriptor, store images.Store) (images.Image, error) { | func (is *Store) Store(ctx context.Context, desc ocispec.Descriptor, store images.Store) (images.Image, error) { | ||||||
| 	img := images.Image{ | 	img := images.Image{ | ||||||
| 		Name:   is.imageName, | 		Name:   is.imageName, | ||||||
| 		Target: desc, | 		Target: desc, | ||||||
| @@ -111,15 +111,15 @@ func (is *ImageStore) Store(ctx context.Context, desc ocispec.Descriptor, store | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) Get(ctx context.Context, store images.Store) (images.Image, error) { | func (is *Store) Get(ctx context.Context, store images.Store) (images.Image, error) { | ||||||
| 	return store.Get(ctx, is.imageName) | 	return store.Get(ctx, is.imageName) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) UnpackPlatforms() []unpack.Platform { | func (is *Store) UnpackPlatforms() []unpack.Platform { | ||||||
| 	return is.unpacks | 	return is.unpacks | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error) { | func (is *Store) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error) { | ||||||
| 	s := &transfertypes.ImageStore{ | 	s := &transfertypes.ImageStore{ | ||||||
| 		Name: is.imageName, | 		Name: is.imageName, | ||||||
| 		// TODO: Support other fields | 		// TODO: Support other fields | ||||||
| @@ -127,7 +127,7 @@ func (is *ImageStore) MarshalAny(ctx context.Context, sm streaming.StreamCreator | |||||||
| 	return typeurl.MarshalAny(s) | 	return typeurl.MarshalAny(s) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (is *ImageStore) UnmarshalAny(ctx context.Context, sm streaming.StreamGetter, a typeurl.Any) error { | func (is *Store) UnmarshalAny(ctx context.Context, sm streaming.StreamGetter, a typeurl.Any) error { | ||||||
| 	var s transfertypes.ImageStore | 	var s transfertypes.ImageStore | ||||||
| 	if err := typeurl.UnmarshalTo(a, &s); err != nil { | 	if err := typeurl.UnmarshalTo(a, &s); err != nil { | ||||||
| 		return err | 		return err | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	// TODO: Move this to seperate package? | 	// TODO: Move this to separate package? | ||||||
| 	plugins.Register(&transfertypes.OCIRegistry{}, &OCIRegistry{}) | 	plugins.Register(&transfertypes.OCIRegistry{}, &OCIRegistry{}) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ import ( | |||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.TransferOpts) error { | func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error { | ||||||
| 	ctx, done, err := ts.withLease(ctx) | 	ctx, done, err := ts.withLease(ctx) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| @@ -146,7 +146,7 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch | |||||||
| 	handler = images.Handlers(append(baseHandlers, | 	handler = images.Handlers(append(baseHandlers, | ||||||
| 		fetchHandler(store, fetcher, progressTracker), | 		fetchHandler(store, fetcher, progressTracker), | ||||||
| 		checkNeedsFix, | 		checkNeedsFix, | ||||||
| 		childrenHandler, // List children to track hierachy | 		childrenHandler, // List children to track hierarchy | ||||||
| 		appendDistSrcLabelHandler, | 		appendDistSrcLabelHandler, | ||||||
| 	)...) | 	)...) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ import ( | |||||||
| 	"github.com/containerd/containerd/remotes" | 	"github.com/containerd/containerd/remotes" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func (ts *localTransferService) push(ctx context.Context, ig transfer.ImageGetter, p transfer.ImagePusher, tops *transfer.TransferOpts) error { | func (ts *localTransferService) push(ctx context.Context, ig transfer.ImageGetter, p transfer.ImagePusher, tops *transfer.Config) error { | ||||||
| 	/* | 	/* | ||||||
| 		// TODO: Platform matching | 		// TODO: Platform matching | ||||||
| 		if pushCtx.PlatformMatcher == nil { | 		if pushCtx.PlatformMatcher == nil { | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ func NewTransferService(lm leases.Manager, cs content.Store, is images.Store) tr | |||||||
| } | } | ||||||
|  |  | ||||||
| func (ts *localTransferService) Transfer(ctx context.Context, src interface{}, dest interface{}, opts ...transfer.Opt) error { | func (ts *localTransferService) Transfer(ctx context.Context, src interface{}, dest interface{}, opts ...transfer.Opt) error { | ||||||
| 	topts := &transfer.TransferOpts{} | 	topts := &transfer.Config{} | ||||||
| 	for _, opt := range opts { | 	for _, opt := range opts { | ||||||
| 		opt(topts) | 		opt(topts) | ||||||
| 	} | 	} | ||||||
| @@ -100,7 +100,7 @@ func name(t interface{}) string { | |||||||
|  |  | ||||||
| // echo is mostly used for testing, it implements an import->export which is | // echo is mostly used for testing, it implements an import->export which is | ||||||
| // a no-op which only roundtrips the bytes. | // a no-op which only roundtrips the bytes. | ||||||
| func (ts *localTransferService) echo(ctx context.Context, i transfer.ImageImportStreamer, e transfer.ImageExportStreamer, tops *transfer.TransferOpts) error { | func (ts *localTransferService) echo(ctx context.Context, i transfer.ImageImportStreamer, e transfer.ImageExportStreamer, tops *transfer.Config) error { | ||||||
| 	r, err := i.ImportStream(ctx) | 	r, err := i.ImportStream(ctx) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ func NewTransferer(client transferapi.TransferClient, sc streaming.StreamCreator | |||||||
| } | } | ||||||
|  |  | ||||||
| func (p *proxyTransferer) Transfer(ctx context.Context, src interface{}, dst interface{}, opts ...transfer.Opt) error { | func (p *proxyTransferer) Transfer(ctx context.Context, src interface{}, dst interface{}, opts ...transfer.Opt) error { | ||||||
| 	o := &transfer.TransferOpts{} | 	o := &transfer.Config{} | ||||||
| 	for _, opt := range opts { | 	for _, opt := range opts { | ||||||
| 		opt(o) | 		opt(o) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -86,14 +86,14 @@ type ImageUnpacker interface { | |||||||
|  |  | ||||||
| type ProgressFunc func(Progress) | type ProgressFunc func(Progress) | ||||||
|  |  | ||||||
| type TransferOpts struct { | type Config struct { | ||||||
| 	Progress ProgressFunc | 	Progress ProgressFunc | ||||||
| } | } | ||||||
|  |  | ||||||
| type Opt func(*TransferOpts) | type Opt func(*Config) | ||||||
|  |  | ||||||
| func WithProgress(f ProgressFunc) Opt { | func WithProgress(f ProgressFunc) Opt { | ||||||
| 	return func(opts *TransferOpts) { | 	return func(opts *Config) { | ||||||
| 		opts.Progress = f | 		opts.Progress = f | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ import ( | |||||||
| 	"github.com/containerd/containerd/pkg/transfer/local" | 	"github.com/containerd/containerd/pkg/transfer/local" | ||||||
| 	"github.com/containerd/containerd/plugin" | 	"github.com/containerd/containerd/plugin" | ||||||
|  |  | ||||||
|  | 	// Load packages with type registrations | ||||||
| 	_ "github.com/containerd/containerd/pkg/transfer/archive" | 	_ "github.com/containerd/containerd/pkg/transfer/archive" | ||||||
| 	_ "github.com/containerd/containerd/pkg/transfer/image" | 	_ "github.com/containerd/containerd/pkg/transfer/image" | ||||||
| ) | ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan