namespaces.go 411 B

12345678910111213141516
  1. package oci
  2. import specs "github.com/opencontainers/runtime-spec/specs-go"
  3. // RemoveNamespace removes the `nsType` namespace from OCI spec `s`
  4. func RemoveNamespace(s *specs.Spec, nsType specs.NamespaceType) {
  5. idx := -1
  6. for i, n := range s.Linux.Namespaces {
  7. if n.Type == nsType {
  8. idx = i
  9. }
  10. }
  11. if idx >= 0 {
  12. s.Linux.Namespaces = append(s.Linux.Namespaces[:idx], s.Linux.Namespaces[idx+1:]...)
  13. }
  14. }