Rename remote snapshotter to proxy
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
0d1807a43d
commit
48b0a022ef
@ -31,21 +31,21 @@ import (
|
|||||||
// NewSnapshotter returns a new Snapshotter which communicates over a GRPC
|
// NewSnapshotter returns a new Snapshotter which communicates over a GRPC
|
||||||
// connection using the containerd snapshot GRPC API.
|
// connection using the containerd snapshot GRPC API.
|
||||||
func NewSnapshotter(client snapshotsapi.SnapshotsClient, snapshotterName string) snapshots.Snapshotter {
|
func NewSnapshotter(client snapshotsapi.SnapshotsClient, snapshotterName string) snapshots.Snapshotter {
|
||||||
return &remoteSnapshotter{
|
return &proxySnapshotter{
|
||||||
client: client,
|
client: client,
|
||||||
snapshotterName: snapshotterName,
|
snapshotterName: snapshotterName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type remoteSnapshotter struct {
|
type proxySnapshotter struct {
|
||||||
client snapshotsapi.SnapshotsClient
|
client snapshotsapi.SnapshotsClient
|
||||||
snapshotterName string
|
snapshotterName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
|
func (p *proxySnapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
|
||||||
resp, err := r.client.Stat(ctx,
|
resp, err := p.client.Stat(ctx,
|
||||||
&snapshotsapi.StatSnapshotRequest{
|
&snapshotsapi.StatSnapshotRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Key: key,
|
Key: key,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -54,10 +54,10 @@ func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshots.Inf
|
|||||||
return toInfo(resp.Info), nil
|
return toInfo(resp.Info), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
|
func (p *proxySnapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
|
||||||
resp, err := r.client.Update(ctx,
|
resp, err := p.client.Update(ctx,
|
||||||
&snapshotsapi.UpdateSnapshotRequest{
|
&snapshotsapi.UpdateSnapshotRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Info: fromInfo(info),
|
Info: fromInfo(info),
|
||||||
UpdateMask: &protobuftypes.FieldMask{
|
UpdateMask: &protobuftypes.FieldMask{
|
||||||
Paths: fieldpaths,
|
Paths: fieldpaths,
|
||||||
@ -69,9 +69,9 @@ func (r *remoteSnapshotter) Update(ctx context.Context, info snapshots.Info, fie
|
|||||||
return toInfo(resp.Info), nil
|
return toInfo(resp.Info), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
|
func (p *proxySnapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) {
|
||||||
resp, err := r.client.Usage(ctx, &snapshotsapi.UsageRequest{
|
resp, err := p.client.Usage(ctx, &snapshotsapi.UsageRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Key: key,
|
Key: key,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -80,9 +80,9 @@ func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshots.Us
|
|||||||
return toUsage(resp), nil
|
return toUsage(resp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) {
|
func (p *proxySnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) {
|
||||||
resp, err := r.client.Mounts(ctx, &snapshotsapi.MountsRequest{
|
resp, err := p.client.Mounts(ctx, &snapshotsapi.MountsRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Key: key,
|
Key: key,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -91,15 +91,15 @@ func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mou
|
|||||||
return toMounts(resp.Mounts), nil
|
return toMounts(resp.Mounts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
func (p *proxySnapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
||||||
var local snapshots.Info
|
var local snapshots.Info
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
if err := opt(&local); err != nil {
|
if err := opt(&local); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp, err := r.client.Prepare(ctx, &snapshotsapi.PrepareSnapshotRequest{
|
resp, err := p.client.Prepare(ctx, &snapshotsapi.PrepareSnapshotRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Key: key,
|
Key: key,
|
||||||
Parent: parent,
|
Parent: parent,
|
||||||
Labels: local.Labels,
|
Labels: local.Labels,
|
||||||
@ -110,15 +110,15 @@ func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opt
|
|||||||
return toMounts(resp.Mounts), nil
|
return toMounts(resp.Mounts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
func (p *proxySnapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
||||||
var local snapshots.Info
|
var local snapshots.Info
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
if err := opt(&local); err != nil {
|
if err := opt(&local); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp, err := r.client.View(ctx, &snapshotsapi.ViewSnapshotRequest{
|
resp, err := p.client.View(ctx, &snapshotsapi.ViewSnapshotRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Key: key,
|
Key: key,
|
||||||
Parent: parent,
|
Parent: parent,
|
||||||
Labels: local.Labels,
|
Labels: local.Labels,
|
||||||
@ -129,15 +129,15 @@ func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts .
|
|||||||
return toMounts(resp.Mounts), nil
|
return toMounts(resp.Mounts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
func (p *proxySnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
||||||
var local snapshots.Info
|
var local snapshots.Info
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
if err := opt(&local); err != nil {
|
if err := opt(&local); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err := r.client.Commit(ctx, &snapshotsapi.CommitSnapshotRequest{
|
_, err := p.client.Commit(ctx, &snapshotsapi.CommitSnapshotRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Name: name,
|
Name: name,
|
||||||
Key: key,
|
Key: key,
|
||||||
Labels: local.Labels,
|
Labels: local.Labels,
|
||||||
@ -145,17 +145,17 @@ func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts .
|
|||||||
return errdefs.FromGRPC(err)
|
return errdefs.FromGRPC(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Remove(ctx context.Context, key string) error {
|
func (p *proxySnapshotter) Remove(ctx context.Context, key string) error {
|
||||||
_, err := r.client.Remove(ctx, &snapshotsapi.RemoveSnapshotRequest{
|
_, err := p.client.Remove(ctx, &snapshotsapi.RemoveSnapshotRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
Key: key,
|
Key: key,
|
||||||
})
|
})
|
||||||
return errdefs.FromGRPC(err)
|
return errdefs.FromGRPC(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
|
func (p *proxySnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
|
||||||
sc, err := r.client.List(ctx, &snapshotsapi.ListSnapshotsRequest{
|
sc, err := p.client.List(ctx, &snapshotsapi.ListSnapshotsRequest{
|
||||||
Snapshotter: r.snapshotterName,
|
Snapshotter: p.snapshotterName,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errdefs.FromGRPC(err)
|
return errdefs.FromGRPC(err)
|
||||||
@ -179,7 +179,7 @@ func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteSnapshotter) Close() error {
|
func (p *proxySnapshotter) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user