Merge pull request #2118 from AkihiroSuda/narrower-interface
*: use narrower content interfaces
This commit is contained in:
		| @@ -115,7 +115,7 @@ func WithTaskCheckpoint(im Image) NewTaskOpts { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func decodeIndex(ctx context.Context, store content.Store, id digest.Digest) (*v1.Index, error) { | func decodeIndex(ctx context.Context, store content.Provider, id digest.Digest) (*v1.Index, error) { | ||||||
| 	var index v1.Index | 	var index v1.Index | ||||||
| 	p, err := content.ReadBlob(ctx, store, id) | 	p, err := content.ReadBlob(ctx, store, id) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|   | |||||||
| @@ -22,14 +22,14 @@ import ( | |||||||
|  |  | ||||||
| // NewFileSystemApplier returns an applier which simply mounts | // NewFileSystemApplier returns an applier which simply mounts | ||||||
| // and applies diff onto the mounted filesystem. | // and applies diff onto the mounted filesystem. | ||||||
| func NewFileSystemApplier(cs content.Store) diff.Applier { | func NewFileSystemApplier(cs content.Provider) diff.Applier { | ||||||
| 	return &fsApplier{ | 	return &fsApplier{ | ||||||
| 		store: cs, | 		store: cs, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| type fsApplier struct { | type fsApplier struct { | ||||||
| 	store content.Store | 	store content.Provider | ||||||
| } | } | ||||||
|  |  | ||||||
| var emptyDesc = ocispec.Descriptor{} | var emptyDesc = ocispec.Descriptor{} | ||||||
|   | |||||||
| @@ -17,5 +17,5 @@ type Importer interface { | |||||||
| // Exporter is the interface for image exporter. | // Exporter is the interface for image exporter. | ||||||
| type Exporter interface { | type Exporter interface { | ||||||
| 	// Export exports an image to a tar stream. | 	// Export exports an image to a tar stream. | ||||||
| 	Export(ctx context.Context, store content.Store, desc ocispec.Descriptor, writer io.Writer) error | 	Export(ctx context.Context, store content.Provider, desc ocispec.Descriptor, writer io.Writer) error | ||||||
| } | } | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ type V1Exporter struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| // Export implements Exporter. | // Export implements Exporter. | ||||||
| func (oe *V1Exporter) Export(ctx context.Context, store content.Store, desc ocispec.Descriptor, writer io.Writer) error { | func (oe *V1Exporter) Export(ctx context.Context, store content.Provider, desc ocispec.Descriptor, writer io.Writer) error { | ||||||
| 	tw := tar.NewWriter(writer) | 	tw := tar.NewWriter(writer) | ||||||
| 	defer tw.Close() | 	defer tw.Close() | ||||||
|  |  | ||||||
| @@ -67,7 +67,7 @@ type tarRecord struct { | |||||||
| 	CopyTo func(context.Context, io.Writer) (int64, error) | 	CopyTo func(context.Context, io.Writer) (int64, error) | ||||||
| } | } | ||||||
|  |  | ||||||
| func blobRecord(cs content.Store, desc ocispec.Descriptor) tarRecord { | func blobRecord(cs content.Provider, desc ocispec.Descriptor) tarRecord { | ||||||
| 	path := "blobs/" + desc.Digest.Algorithm().String() + "/" + desc.Digest.Hex() | 	path := "blobs/" + desc.Digest.Algorithm().String() + "/" + desc.Digest.Hex() | ||||||
| 	return tarRecord{ | 	return tarRecord{ | ||||||
| 		Header: &tar.Header{ | 		Header: &tar.Header{ | ||||||
|   | |||||||
| @@ -113,7 +113,7 @@ func normalizeImageRef(imageName string, manifest ocispec.Descriptor) (string, e | |||||||
| 	return imageName + ":" + ociRef, nil | 	return imageName + ":" + ociRef, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func onUntarBlob(ctx context.Context, r io.Reader, store content.Store, name string, size int64) error { | func onUntarBlob(ctx context.Context, r io.Reader, store content.Ingester, name string, size int64) error { | ||||||
| 	// name is like "blobs/sha256/deadbeef" | 	// name is like "blobs/sha256/deadbeef" | ||||||
| 	split := strings.Split(name, "/") | 	split := strings.Split(name, "/") | ||||||
| 	if len(split) != 3 { | 	if len(split) != 3 { | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								task.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								task.go
									
									
									
									
									
								
							| @@ -572,7 +572,7 @@ func (t *task) writeIndex(ctx context.Context, index *v1.Index) (d v1.Descriptor | |||||||
| 	return writeContent(ctx, t.client.ContentStore(), v1.MediaTypeImageIndex, t.id, buf, content.WithLabels(labels)) | 	return writeContent(ctx, t.client.ContentStore(), v1.MediaTypeImageIndex, t.id, buf, content.WithLabels(labels)) | ||||||
| } | } | ||||||
|  |  | ||||||
| func writeContent(ctx context.Context, store content.Store, mediaType, ref string, r io.Reader, opts ...content.Opt) (d v1.Descriptor, err error) { | func writeContent(ctx context.Context, store content.Ingester, mediaType, ref string, r io.Reader, opts ...content.Opt) (d v1.Descriptor, err error) { | ||||||
| 	writer, err := store.Writer(ctx, ref, 0, "") | 	writer, err := store.Writer(ctx, ref, 0, "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return d, err | 		return d, err | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby