1414 limitations under the License.
1515*/
1616
17- package containerd
17+ package proxy
1818
1919import (
2020 "context"
@@ -28,24 +28,24 @@ import (
2828 protobuftypes "github.com/gogo/protobuf/types"
2929)
3030
31- // NewSnapshotterFromClient returns a new Snapshotter which communicates
32- // over a GRPC connection .
33- func NewSnapshotterFromClient (client snapshotsapi.SnapshotsClient , snapshotterName string ) snapshots.Snapshotter {
34- return & remoteSnapshotter {
31+ // NewSnapshotter returns a new Snapshotter which communicates over a GRPC
32+ // connection using the containerd snapshot GRPC API .
33+ func NewSnapshotter (client snapshotsapi.SnapshotsClient , snapshotterName string ) snapshots.Snapshotter {
34+ return & proxySnapshotter {
3535 client : client ,
3636 snapshotterName : snapshotterName ,
3737 }
3838}
3939
40- type remoteSnapshotter struct {
40+ type proxySnapshotter struct {
4141 client snapshotsapi.SnapshotsClient
4242 snapshotterName string
4343}
4444
45- func (r * remoteSnapshotter ) Stat (ctx context.Context , key string ) (snapshots.Info , error ) {
46- resp , err := r .client .Stat (ctx ,
45+ func (p * proxySnapshotter ) Stat (ctx context.Context , key string ) (snapshots.Info , error ) {
46+ resp , err := p .client .Stat (ctx ,
4747 & snapshotsapi.StatSnapshotRequest {
48- Snapshotter : r .snapshotterName ,
48+ Snapshotter : p .snapshotterName ,
4949 Key : key ,
5050 })
5151 if err != nil {
@@ -54,10 +54,10 @@ func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshots.Inf
5454 return toInfo (resp .Info ), nil
5555}
5656
57- func (r * remoteSnapshotter ) Update (ctx context.Context , info snapshots.Info , fieldpaths ... string ) (snapshots.Info , error ) {
58- resp , err := r .client .Update (ctx ,
57+ func (p * proxySnapshotter ) Update (ctx context.Context , info snapshots.Info , fieldpaths ... string ) (snapshots.Info , error ) {
58+ resp , err := p .client .Update (ctx ,
5959 & snapshotsapi.UpdateSnapshotRequest {
60- Snapshotter : r .snapshotterName ,
60+ Snapshotter : p .snapshotterName ,
6161 Info : fromInfo (info ),
6262 UpdateMask : & protobuftypes.FieldMask {
6363 Paths : fieldpaths ,
@@ -69,9 +69,9 @@ func (r *remoteSnapshotter) Update(ctx context.Context, info snapshots.Info, fie
6969 return toInfo (resp .Info ), nil
7070}
7171
72- func (r * remoteSnapshotter ) Usage (ctx context.Context , key string ) (snapshots.Usage , error ) {
73- resp , err := r .client .Usage (ctx , & snapshotsapi.UsageRequest {
74- Snapshotter : r .snapshotterName ,
72+ func (p * proxySnapshotter ) Usage (ctx context.Context , key string ) (snapshots.Usage , error ) {
73+ resp , err := p .client .Usage (ctx , & snapshotsapi.UsageRequest {
74+ Snapshotter : p .snapshotterName ,
7575 Key : key ,
7676 })
7777 if err != nil {
@@ -80,9 +80,9 @@ func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshots.Us
8080 return toUsage (resp ), nil
8181}
8282
83- func (r * remoteSnapshotter ) Mounts (ctx context.Context , key string ) ([]mount.Mount , error ) {
84- resp , err := r .client .Mounts (ctx , & snapshotsapi.MountsRequest {
85- Snapshotter : r .snapshotterName ,
83+ func (p * proxySnapshotter ) Mounts (ctx context.Context , key string ) ([]mount.Mount , error ) {
84+ resp , err := p .client .Mounts (ctx , & snapshotsapi.MountsRequest {
85+ Snapshotter : p .snapshotterName ,
8686 Key : key ,
8787 })
8888 if err != nil {
@@ -91,15 +91,15 @@ func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mou
9191 return toMounts (resp .Mounts ), nil
9292}
9393
94- func (r * remoteSnapshotter ) Prepare (ctx context.Context , key , parent string , opts ... snapshots.Opt ) ([]mount.Mount , error ) {
94+ func (p * proxySnapshotter ) Prepare (ctx context.Context , key , parent string , opts ... snapshots.Opt ) ([]mount.Mount , error ) {
9595 var local snapshots.Info
9696 for _ , opt := range opts {
9797 if err := opt (& local ); err != nil {
9898 return nil , err
9999 }
100100 }
101- resp , err := r .client .Prepare (ctx , & snapshotsapi.PrepareSnapshotRequest {
102- Snapshotter : r .snapshotterName ,
101+ resp , err := p .client .Prepare (ctx , & snapshotsapi.PrepareSnapshotRequest {
102+ Snapshotter : p .snapshotterName ,
103103 Key : key ,
104104 Parent : parent ,
105105 Labels : local .Labels ,
@@ -110,15 +110,15 @@ func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opt
110110 return toMounts (resp .Mounts ), nil
111111}
112112
113- func (r * remoteSnapshotter ) View (ctx context.Context , key , parent string , opts ... snapshots.Opt ) ([]mount.Mount , error ) {
113+ func (p * proxySnapshotter ) View (ctx context.Context , key , parent string , opts ... snapshots.Opt ) ([]mount.Mount , error ) {
114114 var local snapshots.Info
115115 for _ , opt := range opts {
116116 if err := opt (& local ); err != nil {
117117 return nil , err
118118 }
119119 }
120- resp , err := r .client .View (ctx , & snapshotsapi.ViewSnapshotRequest {
121- Snapshotter : r .snapshotterName ,
120+ resp , err := p .client .View (ctx , & snapshotsapi.ViewSnapshotRequest {
121+ Snapshotter : p .snapshotterName ,
122122 Key : key ,
123123 Parent : parent ,
124124 Labels : local .Labels ,
@@ -129,33 +129,33 @@ func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts .
129129 return toMounts (resp .Mounts ), nil
130130}
131131
132- func (r * remoteSnapshotter ) Commit (ctx context.Context , name , key string , opts ... snapshots.Opt ) error {
132+ func (p * proxySnapshotter ) Commit (ctx context.Context , name , key string , opts ... snapshots.Opt ) error {
133133 var local snapshots.Info
134134 for _ , opt := range opts {
135135 if err := opt (& local ); err != nil {
136136 return err
137137 }
138138 }
139- _ , err := r .client .Commit (ctx , & snapshotsapi.CommitSnapshotRequest {
140- Snapshotter : r .snapshotterName ,
139+ _ , err := p .client .Commit (ctx , & snapshotsapi.CommitSnapshotRequest {
140+ Snapshotter : p .snapshotterName ,
141141 Name : name ,
142142 Key : key ,
143143 Labels : local .Labels ,
144144 })
145145 return errdefs .FromGRPC (err )
146146}
147147
148- func (r * remoteSnapshotter ) Remove (ctx context.Context , key string ) error {
149- _ , err := r .client .Remove (ctx , & snapshotsapi.RemoveSnapshotRequest {
150- Snapshotter : r .snapshotterName ,
148+ func (p * proxySnapshotter ) Remove (ctx context.Context , key string ) error {
149+ _ , err := p .client .Remove (ctx , & snapshotsapi.RemoveSnapshotRequest {
150+ Snapshotter : p .snapshotterName ,
151151 Key : key ,
152152 })
153153 return errdefs .FromGRPC (err )
154154}
155155
156- func (r * remoteSnapshotter ) Walk (ctx context.Context , fn func (context.Context , snapshots.Info ) error ) error {
157- sc , err := r .client .List (ctx , & snapshotsapi.ListSnapshotsRequest {
158- Snapshotter : r .snapshotterName ,
156+ func (p * proxySnapshotter ) Walk (ctx context.Context , fn func (context.Context , snapshots.Info ) error ) error {
157+ sc , err := p .client .List (ctx , & snapshotsapi.ListSnapshotsRequest {
158+ Snapshotter : p .snapshotterName ,
159159 })
160160 if err != nil {
161161 return errdefs .FromGRPC (err )
@@ -179,7 +179,7 @@ func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, s
179179 }
180180}
181181
182- func (r * remoteSnapshotter ) Close () error {
182+ func (p * proxySnapshotter ) Close () error {
183183 return nil
184184}
185185
0 commit comments