containerd/containers/containers.go
Michael Crosby 94eafaab60 Update GRPC for consistency
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-21 13:34:24 -07:00

55 lines
1.3 KiB
Go

package containers
import (
"bytes"
"context"
"encoding/gob"
"errors"
"time"
)
// Container represents the set of data pinned by a container. Unless otherwise
// noted, the resources here are considered in use by the container.
//
// The resources specified in this object are used to create tasks from the container.
type Container struct {
ID string
Labels map[string]string
Image string
Runtime RuntimeInfo
Spec []byte
RootFS string
CreatedAt time.Time
UpdatedAt time.Time
}
type RuntimeInfo struct {
Name string
Options map[string]string
}
func (r RuntimeInfo) MarshalBinary() ([]byte, error) {
buf := bytes.NewBuffer(nil)
if err := gob.NewEncoder(buf).Encode(r); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (r RuntimeInfo) UnmarshalBinary(data []byte) error {
buf := data
if len(buf) == 0 {
return errors.New("RuntimeInfo: no data")
}
reader := bytes.NewReader(buf)
return gob.NewDecoder(reader).Decode(&r)
}
type Store interface {
Get(ctx context.Context, id string) (Container, error)
List(ctx context.Context, filter string) ([]Container, error)
Create(ctx context.Context, container Container) (Container, error)
Update(ctx context.Context, container Container) (Container, error)
Delete(ctx context.Context, id string) error
}