From c44ab12c86689065978950d2ed92bb131b2a932c Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Wed, 11 Mar 2015 11:44:56 -0700 Subject: [PATCH] Add information Type method for Factory Signed-off-by: Alexander Morozov --- factory.go | 3 +++ factory_linux.go | 4 ++++ factory_linux_test.go | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/factory.go b/factory.go index 37e629645..0c9fa63a3 100644 --- a/factory.go +++ b/factory.go @@ -41,4 +41,7 @@ type Factory interface { // pipe connection error // system error StartInitialization(pipefd uintptr) error + + // Type returns info string about factory type (e.g. lxc, libcontainer...) + Type() string } diff --git a/factory_linux.go b/factory_linux.go index 468398c01..ecd3dd5c9 100644 --- a/factory_linux.go +++ b/factory_linux.go @@ -172,6 +172,10 @@ func (l *LinuxFactory) Load(id string) (Container, error) { }, nil } +func (l *LinuxFactory) Type() string { + return "libcontainer" +} + // StartInitialization loads a container by opening the pipe fd from the parent to read the configuration and state // This is a low level implementation detail of the reexec and should not be consumed externally func (l *LinuxFactory) StartInitialization(pipefd uintptr) (err error) { diff --git a/factory_linux_test.go b/factory_linux_test.go index 19fc77ba5..968f6a965 100644 --- a/factory_linux_test.go +++ b/factory_linux_test.go @@ -43,6 +43,10 @@ func TestFactoryNew(t *testing.T) { if lfactory.Root != root { t.Fatalf("expected factory root to be %q but received %q", root, lfactory.Root) } + + if factory.Type() != "libcontainer" { + t.Fatalf("unexpected factory type: %q, expected %q", factory.Type(), "libcontainer") + } } func TestFactoryLoadNotExists(t *testing.T) {