Add information Type method for Factory

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-03-11 11:44:56 -07:00
parent 9387ebb6ba
commit c44ab12c86
3 changed files with 11 additions and 0 deletions

View File

@ -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
}

View File

@ -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) {

View File

@ -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) {