metadata: merge storage into package

The implementations for the storage of metadata have been merged into a
single metadata package where they can share storage primitives and
techniques. The is a requisite for the addition of namespaces, which
will require a coordinated layout for records to be organized by
namespace.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-05-26 16:58:02 -07:00
parent 4ac0e69575
commit 7c14cbc091
12 changed files with 298 additions and 312 deletions

View File

@@ -3,6 +3,7 @@ package containers
import (
api "github.com/containerd/containerd/api/services/containers"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/metadata"
"github.com/gogo/protobuf/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
"google.golang.org/grpc"
@@ -46,9 +47,9 @@ func containerFromProto(containerpb *api.Container) containers.Container {
func mapGRPCError(err error, id string) error {
switch {
case containers.IsNotFound(err):
case metadata.IsNotFound(err):
return grpc.Errorf(codes.NotFound, "container %v not found", id)
case containers.IsExists(err):
case metadata.IsExists(err):
return grpc.Errorf(codes.AlreadyExists, "container %v already exists", id)
}

View File

@@ -4,6 +4,7 @@ import (
"github.com/boltdb/bolt"
api "github.com/containerd/containerd/api/services/containers"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/plugin"
"github.com/golang/protobuf/ptypes/empty"
"golang.org/x/net/context"
@@ -136,7 +137,7 @@ func (s *Service) Delete(ctx context.Context, req *api.DeleteContainerRequest) (
}
func (s *Service) withStore(ctx context.Context, fn func(ctx context.Context, store containers.Store) error) func(tx *bolt.Tx) error {
return func(tx *bolt.Tx) error { return fn(ctx, containers.NewStore(tx)) }
return func(tx *bolt.Tx) error { return fn(ctx, metadata.NewContainerStore(tx)) }
}
func (s *Service) withStoreView(ctx context.Context, fn func(ctx context.Context, store containers.Store) error) error {