From c98ae1f88fccd89eb2184cd2b780f9827ad5ad41 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Wed, 24 Dec 2014 19:09:38 -0800 Subject: [PATCH] Update libcontainer to 0f397d4e145fb4053792d42b3424dd2143fb23ad This fixes wrong behavior of mutating methods of Namespaces object Signed-off-by: Alexandr Morozov --- project/vendor.sh | 2 +- .../github.com/docker/libcontainer/MAINTAINERS | 1 + .../src/github.com/docker/libcontainer/config.go | 16 ++++++++-------- .../docker/libcontainer/config_test.go | 12 ++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/project/vendor.sh b/project/vendor.sh index 2c84e45eee..c1074e887e 100755 --- a/project/vendor.sh +++ b/project/vendor.sh @@ -66,7 +66,7 @@ if [ "$1" = '--go' ]; then mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar fi -clone git github.com/docker/libcontainer 1597c68f7b941fd97881155d7f077852e2914e7b +clone git github.com/docker/libcontainer 0f397d4e145fb4053792d42b3424dd2143fb23ad # see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file) rm -rf src/github.com/docker/libcontainer/vendor eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli')" diff --git a/vendor/src/github.com/docker/libcontainer/MAINTAINERS b/vendor/src/github.com/docker/libcontainer/MAINTAINERS index 7295c6038f..5235131722 100644 --- a/vendor/src/github.com/docker/libcontainer/MAINTAINERS +++ b/vendor/src/github.com/docker/libcontainer/MAINTAINERS @@ -2,4 +2,5 @@ Michael Crosby (@crosbymichael) Rohit Jnagal (@rjnagal) Victor Marmol (@vmarmol) Mrunal Patel (@mrunalp) +Alexandr Morozov (@LK4D4) update-vendor.sh: Tianon Gravi (@tianon) diff --git a/vendor/src/github.com/docker/libcontainer/config.go b/vendor/src/github.com/docker/libcontainer/config.go index 7f1bcc9621..7ab9a9a76a 100644 --- a/vendor/src/github.com/docker/libcontainer/config.go +++ b/vendor/src/github.com/docker/libcontainer/config.go @@ -30,26 +30,26 @@ type Namespace struct { type Namespaces []Namespace -func (n Namespaces) Remove(t NamespaceType) bool { +func (n *Namespaces) Remove(t NamespaceType) bool { i := n.index(t) if i == -1 { return false } - n = append(n[:i], n[i+1:]...) + *n = append((*n)[:i], (*n)[i+1:]...) return true } -func (n Namespaces) Add(t NamespaceType, path string) { +func (n *Namespaces) Add(t NamespaceType, path string) { i := n.index(t) if i == -1 { - n = append(n, Namespace{Type: t, Path: path}) + *n = append(*n, Namespace{Type: t, Path: path}) return } - n[i].Path = path + (*n)[i].Path = path } -func (n Namespaces) index(t NamespaceType) int { - for i, ns := range n { +func (n *Namespaces) index(t NamespaceType) int { + for i, ns := range *n { if ns.Type == t { return i } @@ -57,7 +57,7 @@ func (n Namespaces) index(t NamespaceType) int { return -1 } -func (n Namespaces) Contains(t NamespaceType) bool { +func (n *Namespaces) Contains(t NamespaceType) bool { return n.index(t) != -1 } diff --git a/vendor/src/github.com/docker/libcontainer/config_test.go b/vendor/src/github.com/docker/libcontainer/config_test.go index 5c73f84af5..f2287fc741 100644 --- a/vendor/src/github.com/docker/libcontainer/config_test.go +++ b/vendor/src/github.com/docker/libcontainer/config_test.go @@ -158,3 +158,15 @@ func TestSelinuxLabels(t *testing.T) { t.Fatalf("expected mount label %q but received %q", label, container.MountConfig.MountLabel) } } + +func TestRemoveNamespace(t *testing.T) { + ns := Namespaces{ + {Type: NEWNET}, + } + if !ns.Remove(NEWNET) { + t.Fatal("NEWNET was not removed") + } + if len(ns) != 0 { + t.Fatalf("namespaces should have 0 items but reports %d", len(ns)) + } +}