Skip to content

[RFC] content: change Writer/ReaderAt to take OCI descriptor #2129

@AkihiroSuda

Description

@AkihiroSuda
diff --git a/content/content.go b/content/content.go
index 05fd4aeb..edcc7a97 100644
--- a/content/content.go
--- b/content/content.go
@@ -6,6 +6,7 @@ import (
 	"time"
 
 	"github.com/opencontainers/go-digest"
+	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
 )
 
 // ReaderAt extends the standard io.ReaderAt interface with reporting of Size and io.Closer
@@ -17,12 +18,19 @@ type ReaderAt interface {
 
 // Provider provides a reader interface for specific content
 type Provider interface {
-	ReaderAt(ctx context.Context, dgst digest.Digest) (ReaderAt, error)
+	// ReaderAt only requires desc.Digest to be provided.
+	// Other fields in the descriptor may be used internally for resolving
+	// the location of the actual data.
+	ReaderAt(ctx context.Context, desc ocispec.Descriptor) (ReaderAt, error)
 }
 
 // Ingester writes content
 type Ingester interface {
-	Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (Writer, error)
+	// Writer may optionally use the descriptor internally for resolving
+	// the location of the actual data.
+	// If desc is set but the data size is unknown, desc.Size should be set
+	// to 0. Some implementation also accepts negative values.
+	Writer(ctx context.Context, ref string, desc *ocispec.Descriptor) (Writer, error)
 }
 
 // Info holds content specific information

Most implementations would just ignore these descriptors, however, for example, we could implement a registry-based content store that switches GET/PUT URLs using descriptor.MediaType strings.

No change on gRPC API.

This proposal was originally suggested by @tonistiigi moby/buildkit#278 (comment)

PR is ready, but I didn't open it immediately as this proposal might be controversial: master...AkihiroSuda:oci-content-store.20180213-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions