8a094fe609
Audit the OCI spec options used for Linux containers to ensure they are less order-dependent. Ensure they don't assume that any pointer fields are non-nil and that they don't unintentionally clobber mutations to the spec applied by other options. Signed-off-by: Cory Snider <csnider@mirantis.com>
16 lines
457 B
Go
16 lines
457 B
Go
package oci // import "github.com/docker/docker/oci"
|
|
|
|
import specs "github.com/opencontainers/runtime-spec/specs-go"
|
|
|
|
// RemoveNamespace removes the `nsType` namespace from OCI spec `s`
|
|
func RemoveNamespace(s *specs.Spec, nsType specs.LinuxNamespaceType) {
|
|
if s.Linux == nil {
|
|
return
|
|
}
|
|
for i, n := range s.Linux.Namespaces {
|
|
if n.Type == nsType {
|
|
s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...)
|
|
return
|
|
}
|
|
}
|
|
}
|