pkg/cri/opts.WithoutRunMount -> oci.WithoutRunMount
Move `pkg/cri/opts.WithoutRunMount` function to `oci.WithoutRunMount` so that it can be used without dependency on CRI. Also add `oci.WithoutMounts(dests ...string)` for generality. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
@@ -273,6 +273,28 @@ func WithMounts(mounts []specs.Mount) SpecOpts {
|
||||
}
|
||||
}
|
||||
|
||||
// WithoutMounts removes mounts
|
||||
func WithoutMounts(dests ...string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
var (
|
||||
mounts []specs.Mount
|
||||
current = s.Mounts
|
||||
)
|
||||
mLoop:
|
||||
for _, m := range current {
|
||||
mDestination := filepath.Clean(m.Destination)
|
||||
for _, dest := range dests {
|
||||
if mDestination == dest {
|
||||
continue mLoop
|
||||
}
|
||||
}
|
||||
mounts = append(mounts, m)
|
||||
}
|
||||
s.Mounts = mounts
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithHostNamespace allows a task to run inside the host's linux namespace
|
||||
func WithHostNamespace(ns specs.LinuxNamespaceType) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
|
||||
Reference in New Issue
Block a user