Add errors listing to libpod

Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
Matthew Heon 2017-09-11 11:27:40 -04:00
parent f8e48aad29
commit ae5634f8dd
6 changed files with 105 additions and 60 deletions

View file

@ -1,20 +1,15 @@
package libpod
import (
"fmt"
"sync"
"github.com/containers/storage"
"github.com/docker/docker/pkg/stringid"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/ulule/deepcopier"
)
var (
// ErrNotImplemented indicates that functionality is not yet implemented
errNotImplemented = fmt.Errorf("NOT IMPLEMENTED")
)
// Container is a single OCI container
type Container struct {
id string
@ -60,7 +55,7 @@ func (c *Container) Spec() *spec.Spec {
// Make a new container
func newContainer(rspec *spec.Spec) (*Container, error) {
if rspec == nil {
return nil, fmt.Errorf("must provide a valid spec to construct container")
return nil, errors.Wrapf(ErrInvalidArg, "must provide a valid runtime spec to create container")
}
ctr := new(Container)
@ -75,52 +70,52 @@ func newContainer(rspec *spec.Spec) (*Container, error) {
// Create creates a container in the OCI runtime
func (c *Container) Create() error {
return errNotImplemented
return ErrNotImplemented
}
// Start starts a container
func (c *Container) Start() error {
return errNotImplemented
return ErrNotImplemented
}
// Stop stops a container
func (c *Container) Stop() error {
return errNotImplemented
return ErrNotImplemented
}
// Kill sends a signal to a container
func (c *Container) Kill(signal uint) error {
return errNotImplemented
return ErrNotImplemented
}
// Exec starts a new process inside the container
// Returns fully qualified URL of streaming server for executed process
func (c *Container) Exec(cmd []string, tty bool, stdin bool) (string, error) {
return "", errNotImplemented
return "", ErrNotImplemented
}
// Attach attaches to a container
// Returns fully qualified URL of streaming server for the container
func (c *Container) Attach(stdin, tty bool) (string, error) {
return "", errNotImplemented
return "", ErrNotImplemented
}
// Mount mounts a container's filesystem on the host
// The path where the container has been mounted is returned
func (c *Container) Mount() (string, error) {
return "", errNotImplemented
return "", ErrNotImplemented
}
// Status gets a container's status
// TODO this should return relevant information about container state
func (c *Container) Status() error {
return errNotImplemented
return ErrNotImplemented
}
// Export exports a container's root filesystem as a tar archive
// The archive will be saved as a file at the given path
func (c *Container) Export(path string) error {
return errNotImplemented
return ErrNotImplemented
}
// Commit commits the changes between a container and its image, creating a new
@ -130,5 +125,5 @@ func (c *Container) Export(path string) error {
// a new base image will be created from the contents of the container's
// filesystem
func (c *Container) Commit() (*storage.Image, error) {
return nil, errNotImplemented
return nil, ErrNotImplemented
}