github.com/khulnasoft-lab/khulnasoft@v26.0.1-0.20240328202558-330a6f959fe0+incompatible/oci/namespaces.go (about) 1 package oci // import "github.com/docker/docker/oci" 2 3 import specs "github.com/opencontainers/runtime-spec/specs-go" 4 5 // RemoveNamespace removes the `nsType` namespace from OCI spec `s` 6 func RemoveNamespace(s *specs.Spec, nsType specs.LinuxNamespaceType) { 7 if s.Linux == nil { 8 return 9 } 10 for i, n := range s.Linux.Namespaces { 11 if n.Type == nsType { 12 s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...) 13 return 14 } 15 } 16 } 17 18 // NamespacePath returns the configured Path of the first namespace in 19 // s.Linux.Namespaces of type nsType. 20 func NamespacePath(s *specs.Spec, nsType specs.LinuxNamespaceType) (path string, ok bool) { 21 for _, n := range s.Linux.Namespaces { 22 if n.Type == nsType { 23 return n.Path, true 24 } 25 } 26 return "", false 27 }