@@ -120,7 +120,11 @@ func WithSnapshot(id string) NewContainerOpts {
120120 return func (ctx context.Context , client * Client , c * containers.Container ) error {
121121 setSnapshotterIfEmpty (ctx , client , c )
122122 // check that the snapshot exists, if not, fail on creation
123- if _ , err := client .SnapshotService (c .Snapshotter ).Mounts (ctx , id ); err != nil {
123+ s , err := client .getSnapshotter (c .Snapshotter )
124+ if err != nil {
125+ return err
126+ }
127+ if _ , err := s .Mounts (ctx , id ); err != nil {
124128 return err
125129 }
126130 c .SnapshotKey = id
@@ -138,7 +142,11 @@ func WithNewSnapshot(id string, i Image, opts ...snapshots.Opt) NewContainerOpts
138142 }
139143 setSnapshotterIfEmpty (ctx , client , c )
140144 parent := identity .ChainID (diffIDs ).String ()
141- if _ , err := client .SnapshotService (c .Snapshotter ).Prepare (ctx , id , parent , opts ... ); err != nil {
145+ s , err := client .getSnapshotter (c .Snapshotter )
146+ if err != nil {
147+ return err
148+ }
149+ if _ , err := s .Prepare (ctx , id , parent , opts ... ); err != nil {
142150 return err
143151 }
144152 c .SnapshotKey = id
@@ -153,7 +161,11 @@ func WithSnapshotCleanup(ctx context.Context, client *Client, c containers.Conta
153161 if c .Snapshotter == "" {
154162 return errors .Wrapf (errdefs .ErrInvalidArgument , "container.Snapshotter must be set to cleanup rootfs snapshot" )
155163 }
156- return client .SnapshotService (c .Snapshotter ).Remove (ctx , c .SnapshotKey )
164+ s , err := client .getSnapshotter (c .Snapshotter )
165+ if err != nil {
166+ return err
167+ }
168+ return s .Remove (ctx , c .SnapshotKey )
157169 }
158170 return nil
159171}
@@ -168,7 +180,11 @@ func WithNewSnapshotView(id string, i Image, opts ...snapshots.Opt) NewContainer
168180 }
169181 setSnapshotterIfEmpty (ctx , client , c )
170182 parent := identity .ChainID (diffIDs ).String ()
171- if _ , err := client .SnapshotService (c .Snapshotter ).View (ctx , id , parent , opts ... ); err != nil {
183+ s , err := client .getSnapshotter (c .Snapshotter )
184+ if err != nil {
185+ return err
186+ }
187+ if _ , err := s .View (ctx , id , parent , opts ... ); err != nil {
172188 return err
173189 }
174190 c .SnapshotKey = id
0 commit comments