diff --git a/config.go b/config.go index bf523655..7f1bcc96 100644 --- a/config.go +++ b/config.go @@ -57,6 +57,10 @@ func (n Namespaces) index(t NamespaceType) int { return -1 } +func (n Namespaces) Contains(t NamespaceType) bool { + return n.index(t) != -1 +} + // Config defines configuration options for executing a process inside a contained environment. type Config struct { // Mount specific options. diff --git a/config_test.go b/config_test.go index 63b8aa8a..5c73f84a 100644 --- a/config_test.go +++ b/config_test.go @@ -64,12 +64,12 @@ func TestConfigJsonFormat(t *testing.T) { t.Fail() } - if container.Namespaces.index(NEWNET) == -1 { + if !container.Namespaces.Contains(NEWNET) { t.Log("namespaces should contain NEWNET") t.Fail() } - if container.Namespaces.index(NEWUSER) != -1 { + if container.Namespaces.Contains(NEWUSER) { t.Log("namespaces should not contain NEWUSER") t.Fail() }