libcontainer: remove LinuxFactory

Since LinuxFactory has become the means to specify containers state
top directory (aka --root), and is only used by two methods (Create
and Load), it is easier to pass root to them directly.

Modify all the users and the docs accordingly.

While at it, fix Create and Load docs (those that were originally moved
from the Factory interface docs).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2022-02-10 19:53:38 -08:00
parent 6a29787bc9
commit 6a3fe1618f
9 changed files with 44 additions and 106 deletions

View File

@@ -23,19 +23,15 @@ import (
var errEmptyID = errors.New("container id cannot be empty")
// getContainer returns the specified container instance by loading it from state
// with the default factory.
// getContainer returns the specified container instance by loading it from
// a state directory (root).
func getContainer(context *cli.Context) (libcontainer.Container, error) {
id := context.Args().First()
if id == "" {
return nil, errEmptyID
}
root := context.GlobalString("root")
factory, err := libcontainer.New(root)
if err != nil {
return nil, err
}
return factory.Load(id)
return libcontainer.Load(root, id)
}
func getDefaultImagePath() string {
@@ -185,11 +181,7 @@ func createContainer(context *cli.Context, id string, spec *specs.Spec) (libcont
}
root := context.GlobalString("root")
factory, err := libcontainer.New(root)
if err != nil {
return nil, err
}
return factory.Create(id, config)
return libcontainer.Create(root, id, config)
}
type runner struct {