2018-02-05 21:05:59 +00:00
|
|
|
package oci // import "github.com/docker/docker/oci"
|
2016-11-22 21:42:11 +00:00
|
|
|
|
2019-08-05 14:37:47 +00:00
|
|
|
import specs "github.com/opencontainers/runtime-spec/specs-go"
|
2016-11-22 21:42:11 +00:00
|
|
|
|
|
|
|
// RemoveNamespace removes the `nsType` namespace from OCI spec `s`
|
2017-04-27 21:52:47 +00:00
|
|
|
func RemoveNamespace(s *specs.Spec, nsType specs.LinuxNamespaceType) {
|
2023-06-06 16:57:38 +00:00
|
|
|
if s.Linux == nil {
|
|
|
|
return
|
|
|
|
}
|
2016-11-22 21:42:11 +00:00
|
|
|
for i, n := range s.Linux.Namespaces {
|
|
|
|
if n.Type == nsType {
|
2016-12-14 09:34:29 +00:00
|
|
|
s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...)
|
|
|
|
return
|
2016-11-22 21:42:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-01 19:21:37 +00:00
|
|
|
|
|
|
|
// NamespacePath returns the configured Path of the first namespace in
|
|
|
|
// s.Linux.Namespaces of type nsType.
|
|
|
|
func NamespacePath(s *specs.Spec, nsType specs.LinuxNamespaceType) (path string, ok bool) {
|
|
|
|
for _, n := range s.Linux.Namespaces {
|
|
|
|
if n.Type == nsType {
|
|
|
|
return n.Path, true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "", false
|
|
|
|
}
|