Rename remote content to proxy content
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
6e64091322
commit
7c80d0ae11
@ -27,20 +27,20 @@ import (
|
|||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
)
|
)
|
||||||
|
|
||||||
type remoteContent struct {
|
type proxyContentStore struct {
|
||||||
client contentapi.ContentClient
|
client contentapi.ContentClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewContentStore returns a new content store which communicates over a GRPC
|
// NewContentStore returns a new content store which communicates over a GRPC
|
||||||
// connection using the containerd content GRPC API.
|
// connection using the containerd content GRPC API.
|
||||||
func NewContentStore(client contentapi.ContentClient) content.Store {
|
func NewContentStore(client contentapi.ContentClient) content.Store {
|
||||||
return &remoteContent{
|
return &proxyContentStore{
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
|
func (pcs *proxyContentStore) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
|
||||||
resp, err := rs.client.Info(ctx, &contentapi.InfoRequest{
|
resp, err := pcs.client.Info(ctx, &contentapi.InfoRequest{
|
||||||
Digest: dgst,
|
Digest: dgst,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -50,8 +50,8 @@ func (rs *remoteContent) Info(ctx context.Context, dgst digest.Digest) (content.
|
|||||||
return infoFromGRPC(resp.Info), nil
|
return infoFromGRPC(resp.Info), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error {
|
func (pcs *proxyContentStore) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error {
|
||||||
session, err := rs.client.List(ctx, &contentapi.ListContentRequest{
|
session, err := pcs.client.List(ctx, &contentapi.ListContentRequest{
|
||||||
Filters: filters,
|
Filters: filters,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -78,8 +78,8 @@ func (rs *remoteContent) Walk(ctx context.Context, fn content.WalkFunc, filters
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) Delete(ctx context.Context, dgst digest.Digest) error {
|
func (pcs *proxyContentStore) Delete(ctx context.Context, dgst digest.Digest) error {
|
||||||
if _, err := rs.client.Delete(ctx, &contentapi.DeleteContentRequest{
|
if _, err := pcs.client.Delete(ctx, &contentapi.DeleteContentRequest{
|
||||||
Digest: dgst,
|
Digest: dgst,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return errdefs.FromGRPC(err)
|
return errdefs.FromGRPC(err)
|
||||||
@ -88,8 +88,8 @@ func (rs *remoteContent) Delete(ctx context.Context, dgst digest.Digest) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) ReaderAt(ctx context.Context, dgst digest.Digest) (content.ReaderAt, error) {
|
func (pcs *proxyContentStore) ReaderAt(ctx context.Context, dgst digest.Digest) (content.ReaderAt, error) {
|
||||||
i, err := rs.Info(ctx, dgst)
|
i, err := pcs.Info(ctx, dgst)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -98,12 +98,12 @@ func (rs *remoteContent) ReaderAt(ctx context.Context, dgst digest.Digest) (cont
|
|||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
digest: dgst,
|
digest: dgst,
|
||||||
size: i.Size,
|
size: i.Size,
|
||||||
client: rs.client,
|
client: pcs.client,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) Status(ctx context.Context, ref string) (content.Status, error) {
|
func (pcs *proxyContentStore) Status(ctx context.Context, ref string) (content.Status, error) {
|
||||||
resp, err := rs.client.Status(ctx, &contentapi.StatusRequest{
|
resp, err := pcs.client.Status(ctx, &contentapi.StatusRequest{
|
||||||
Ref: ref,
|
Ref: ref,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -121,8 +121,8 @@ func (rs *remoteContent) Status(ctx context.Context, ref string) (content.Status
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) {
|
func (pcs *proxyContentStore) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) {
|
||||||
resp, err := rs.client.Update(ctx, &contentapi.UpdateRequest{
|
resp, err := pcs.client.Update(ctx, &contentapi.UpdateRequest{
|
||||||
Info: infoToGRPC(info),
|
Info: infoToGRPC(info),
|
||||||
UpdateMask: &protobuftypes.FieldMask{
|
UpdateMask: &protobuftypes.FieldMask{
|
||||||
Paths: fieldpaths,
|
Paths: fieldpaths,
|
||||||
@ -134,8 +134,8 @@ func (rs *remoteContent) Update(ctx context.Context, info content.Info, fieldpat
|
|||||||
return infoFromGRPC(resp.Info), nil
|
return infoFromGRPC(resp.Info), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) ListStatuses(ctx context.Context, filters ...string) ([]content.Status, error) {
|
func (pcs *proxyContentStore) ListStatuses(ctx context.Context, filters ...string) ([]content.Status, error) {
|
||||||
resp, err := rs.client.ListStatuses(ctx, &contentapi.ListStatusesRequest{
|
resp, err := pcs.client.ListStatuses(ctx, &contentapi.ListStatusesRequest{
|
||||||
Filters: filters,
|
Filters: filters,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -157,8 +157,8 @@ func (rs *remoteContent) ListStatuses(ctx context.Context, filters ...string) ([
|
|||||||
return statuses, nil
|
return statuses, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (content.Writer, error) {
|
func (pcs *proxyContentStore) Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (content.Writer, error) {
|
||||||
wrclient, offset, err := rs.negotiate(ctx, ref, size, expected)
|
wrclient, offset, err := pcs.negotiate(ctx, ref, size, expected)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errdefs.FromGRPC(err)
|
return nil, errdefs.FromGRPC(err)
|
||||||
}
|
}
|
||||||
@ -171,8 +171,8 @@ func (rs *remoteContent) Writer(ctx context.Context, ref string, size int64, exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Abort implements asynchronous abort. It starts a new write session on the ref l
|
// Abort implements asynchronous abort. It starts a new write session on the ref l
|
||||||
func (rs *remoteContent) Abort(ctx context.Context, ref string) error {
|
func (pcs *proxyContentStore) Abort(ctx context.Context, ref string) error {
|
||||||
if _, err := rs.client.Abort(ctx, &contentapi.AbortRequest{
|
if _, err := pcs.client.Abort(ctx, &contentapi.AbortRequest{
|
||||||
Ref: ref,
|
Ref: ref,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return errdefs.FromGRPC(err)
|
return errdefs.FromGRPC(err)
|
||||||
@ -181,8 +181,8 @@ func (rs *remoteContent) Abort(ctx context.Context, ref string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *remoteContent) negotiate(ctx context.Context, ref string, size int64, expected digest.Digest) (contentapi.Content_WriteClient, int64, error) {
|
func (pcs *proxyContentStore) negotiate(ctx context.Context, ref string, size int64, expected digest.Digest) (contentapi.Content_WriteClient, int64, error) {
|
||||||
wrclient, err := rs.client.Write(ctx)
|
wrclient, err := pcs.client.Write(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user