mirror of
https://github.com/opencontainers/runc.git
synced 2026-06-24 08:48:44 +00:00
This removes libcontainer's own error wrapping system, consisting of a few types and functions, aimed at typization, wrapping and unwrapping of errors, as well as saving error stack traces. Since Go 1.13 now provides its own error wrapping mechanism and a few related functions, it makes sense to switch to it. While doing that, improve some error messages so that they start with "error", "unable to", or "can't". A few things that are worth mentioning: 1. We lose stack traces (which were never shown anyway). 2. Users of libcontainer that relied on particular errors (like ContainerNotExists) need to switch to using errors.Is with the new errors defined in error.go. 3. encoding/json is unable to unmarshal the built-in error type, so we have to introduce initError and wrap the errors into it (basically passing the error as a string). This is the same as it was before, just a tad simpler (actually the initError is a type that got removed in commit afa844311; also suddenly ierr variable name makes sense now). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package libcontainer
|
|
|
|
import (
|
|
"github.com/opencontainers/runc/libcontainer/configs"
|
|
)
|
|
|
|
type Factory interface {
|
|
// Creates a new container with the given id and starts the initial process inside it.
|
|
// id must be a string containing only letters, digits and underscores and must contain
|
|
// between 1 and 1024 characters, inclusive.
|
|
//
|
|
// The id must not already be in use by an existing container. Containers created using
|
|
// a factory with the same path (and filesystem) must have distinct ids.
|
|
//
|
|
// Returns the new container with a running process.
|
|
//
|
|
// On error, any partially created container parts are cleaned up (the operation is atomic).
|
|
Create(id string, config *configs.Config) (Container, error)
|
|
|
|
// Load takes an ID for an existing container and returns the container information
|
|
// from the state. This presents a read only view of the container.
|
|
Load(id string) (Container, error)
|
|
|
|
// StartInitialization is an internal API to libcontainer used during the reexec of the
|
|
// container.
|
|
StartInitialization() error
|
|
|
|
// Type returns info string about factory type (e.g. lxc, libcontainer...)
|
|
Type() string
|
|
}
|