@@ -23,6 +23,7 @@ import (
2323 "github.com/containerd/containerd/errdefs"
2424 "github.com/containerd/containerd/oci"
2525 "github.com/containerd/containerd/platforms"
26+ "github.com/containerd/containerd/snapshots"
2627 "github.com/containerd/typeurl"
2728 "github.com/gogo/protobuf/types"
2829 "github.com/opencontainers/image-spec/identity"
@@ -118,15 +119,15 @@ func WithSnapshot(id string) NewContainerOpts {
118119
119120// WithNewSnapshot allocates a new snapshot to be used by the container as the
120121// root filesystem in read-write mode
121- func WithNewSnapshot (id string , i Image ) NewContainerOpts {
122+ func WithNewSnapshot (id string , i Image , opts ... snapshots. Opt ) NewContainerOpts {
122123 return func (ctx context.Context , client * Client , c * containers.Container ) error {
123124 diffIDs , err := i .(* image ).i .RootFS (ctx , client .ContentStore (), platforms .Default ())
124125 if err != nil {
125126 return err
126127 }
127128 setSnapshotterIfEmpty (c )
128129 parent := identity .ChainID (diffIDs ).String ()
129- if _ , err := client .SnapshotService (c .Snapshotter ).Prepare (ctx , id , parent ); err != nil {
130+ if _ , err := client .SnapshotService (c .Snapshotter ).Prepare (ctx , id , parent , opts ... ); err != nil {
130131 return err
131132 }
132133 c .SnapshotKey = id
@@ -148,15 +149,15 @@ func WithSnapshotCleanup(ctx context.Context, client *Client, c containers.Conta
148149
149150// WithNewSnapshotView allocates a new snapshot to be used by the container as the
150151// root filesystem in read-only mode
151- func WithNewSnapshotView (id string , i Image ) NewContainerOpts {
152+ func WithNewSnapshotView (id string , i Image , opts ... snapshots. Opt ) NewContainerOpts {
152153 return func (ctx context.Context , client * Client , c * containers.Container ) error {
153154 diffIDs , err := i .(* image ).i .RootFS (ctx , client .ContentStore (), platforms .Default ())
154155 if err != nil {
155156 return err
156157 }
157158 setSnapshotterIfEmpty (c )
158159 parent := identity .ChainID (diffIDs ).String ()
159- if _ , err := client .SnapshotService (c .Snapshotter ).View (ctx , id , parent ); err != nil {
160+ if _ , err := client .SnapshotService (c .Snapshotter ).View (ctx , id , parent , opts ... ); err != nil {
160161 return err
161162 }
162163 c .SnapshotKey = id
0 commit comments