protobuf: use the gogo/types package for empty
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/containerd/containerd/events"
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
@@ -149,24 +149,24 @@ func (s *service) Update(ctx context.Context, req *api.UpdateContainerRequest) (
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, req *api.DeleteContainerRequest) (*empty.Empty, error) {
|
||||
func (s *service) Delete(ctx context.Context, req *api.DeleteContainerRequest) (*ptypes.Empty, error) {
|
||||
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store containers.Store) error {
|
||||
return store.Delete(ctx, req.ID)
|
||||
}); err != nil {
|
||||
return &empty.Empty{}, errdefs.ToGRPC(err)
|
||||
return &ptypes.Empty{}, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
if err := s.publisher.Publish(ctx, "/containers/delete", &eventsapi.ContainerDelete{
|
||||
ID: req.ID,
|
||||
}); err != nil {
|
||||
return &empty.Empty{}, err
|
||||
return &ptypes.Empty{}, err
|
||||
}
|
||||
|
||||
if err := s.db.GarbageCollect(ctx); err != nil {
|
||||
return &empty.Empty{}, errdefs.ToGRPC(errors.Wrap(err, "garbage collection failed"))
|
||||
return &ptypes.Empty{}, errdefs.ToGRPC(errors.Wrap(err, "garbage collection failed"))
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) withStore(ctx context.Context, fn func(ctx context.Context, store containers.Store) error) func(tx *bolt.Tx) error {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -138,7 +138,7 @@ func (s *service) List(req *api.ListContentRequest, session api.Content_ListServ
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*empty.Empty, error) {
|
||||
func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*ptypes.Empty, error) {
|
||||
if err := req.Digest.Validate(); err != nil {
|
||||
return nil, grpc.Errorf(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
@@ -153,7 +153,7 @@ func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) Read(req *api.ReadContentRequest, session api.Content_ReadServer) error {
|
||||
@@ -445,10 +445,10 @@ func (s *service) Write(session api.Content_WriteServer) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) Abort(ctx context.Context, req *api.AbortRequest) (*empty.Empty, error) {
|
||||
func (s *service) Abort(ctx context.Context, req *api.AbortRequest) (*ptypes.Empty, error) {
|
||||
if err := s.store.Abort(ctx, req.Ref); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events/exchange"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
@@ -35,20 +35,20 @@ func (s *service) Register(server *grpc.Server) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Publish(ctx context.Context, r *api.PublishRequest) (*empty.Empty, error) {
|
||||
func (s *service) Publish(ctx context.Context, r *api.PublishRequest) (*ptypes.Empty, error) {
|
||||
if err := s.events.Publish(ctx, r.Topic, r.Event); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) Forward(ctx context.Context, r *api.ForwardRequest) (*empty.Empty, error) {
|
||||
func (s *service) Forward(ctx context.Context, r *api.ForwardRequest) (*ptypes.Empty, error) {
|
||||
if err := s.events.Forward(ctx, r.Envelope); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) Subscribe(req *api.SubscribeRequest, srv api.Events_SubscribeServer) error {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
@@ -150,7 +150,7 @@ func (s *service) Update(ctx context.Context, req *imagesapi.UpdateImageRequest)
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) (*empty.Empty, error) {
|
||||
func (s *service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) (*ptypes.Empty, error) {
|
||||
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store images.Store) error {
|
||||
return errdefs.ToGRPC(store.Delete(ctx, req.Name))
|
||||
}); err != nil {
|
||||
@@ -167,7 +167,7 @@ func (s *service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest)
|
||||
return nil, errdefs.ToGRPC(errors.Wrap(err, "garbage collection failed"))
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) withStore(ctx context.Context, fn func(ctx context.Context, store images.Store) error) func(tx *bolt.Tx) error {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
api "github.com/containerd/containerd/api/services/leases/v1"
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -67,13 +67,13 @@ func (s *service) Create(ctx context.Context, r *api.CreateRequest) (*api.Create
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, r *api.DeleteRequest) (*empty.Empty, error) {
|
||||
func (s *service) Delete(ctx context.Context, r *api.DeleteRequest) (*ptypes.Empty, error) {
|
||||
if err := s.db.Update(func(tx *bolt.Tx) error {
|
||||
return metadata.NewLeaseManager(tx).Delete(ctx, r.ID)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) List(ctx context.Context, r *api.ListRequest) (*api.ListResponse, error) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -182,21 +182,21 @@ func (s *service) Update(ctx context.Context, req *api.UpdateNamespaceRequest) (
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, req *api.DeleteNamespaceRequest) (*empty.Empty, error) {
|
||||
func (s *service) Delete(ctx context.Context, req *api.DeleteNamespaceRequest) (*ptypes.Empty, error) {
|
||||
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store namespaces.Store) error {
|
||||
return errdefs.ToGRPC(store.Delete(ctx, req.Name))
|
||||
}); err != nil {
|
||||
return &empty.Empty{}, err
|
||||
return &ptypes.Empty{}, err
|
||||
}
|
||||
// set the namespace in the context before publishing the event
|
||||
ctx = namespaces.WithNamespace(ctx, req.Name)
|
||||
if err := s.publisher.Publish(ctx, "/namespaces/delete", &eventsapi.NamespaceDelete{
|
||||
Name: req.Name,
|
||||
}); err != nil {
|
||||
return &empty.Empty{}, err
|
||||
return &ptypes.Empty{}, err
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
return &ptypes.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *service) withStore(ctx context.Context, fn func(ctx context.Context, store namespaces.Store) error) func(tx *bolt.Tx) error {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/snapshot"
|
||||
protoempty "github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@@ -29,7 +29,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
var empty = &protoempty.Empty{}
|
||||
var empty = &ptypes.Empty{}
|
||||
|
||||
type service struct {
|
||||
db *metadata.DB
|
||||
@@ -127,7 +127,7 @@ func (s *service) Mounts(ctx context.Context, mr *snapshotapi.MountsRequest) (*s
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequest) (*protoempty.Empty, error) {
|
||||
func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequest) (*ptypes.Empty, error) {
|
||||
log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot")
|
||||
sn, err := s.getSnapshotter(cr.Snapshotter)
|
||||
if err != nil {
|
||||
@@ -151,7 +151,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequ
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveSnapshotRequest) (*protoempty.Empty, error) {
|
||||
func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveSnapshotRequest) (*ptypes.Empty, error) {
|
||||
log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot")
|
||||
sn, err := s.getSnapshotter(rr.Snapshotter)
|
||||
if err != nil {
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
"github.com/containerd/typeurl"
|
||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
@@ -35,7 +35,7 @@ import (
|
||||
|
||||
var (
|
||||
_ = (api.TasksServer)(&service{})
|
||||
empty = &google_protobuf.Empty{}
|
||||
empty = &ptypes.Empty{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -296,7 +296,7 @@ func addTasks(ctx context.Context, r *api.ListTasksResponse, tasks []runtime.Tas
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) Pause(ctx context.Context, r *api.PauseTaskRequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) Pause(ctx context.Context, r *api.PauseTaskRequest) (*ptypes.Empty, error) {
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -308,7 +308,7 @@ func (s *service) Pause(ctx context.Context, r *api.PauseTaskRequest) (*google_p
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func (s *service) Resume(ctx context.Context, r *api.ResumeTaskRequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) Resume(ctx context.Context, r *api.ResumeTaskRequest) (*ptypes.Empty, error) {
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -320,7 +320,7 @@ func (s *service) Resume(ctx context.Context, r *api.ResumeTaskRequest) (*google
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func (s *service) Kill(ctx context.Context, r *api.KillRequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) Kill(ctx context.Context, r *api.KillRequest) (*ptypes.Empty, error) {
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -365,7 +365,7 @@ func (s *service) ListPids(ctx context.Context, r *api.ListPidsRequest) (*api.Li
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *service) Exec(ctx context.Context, r *api.ExecProcessRequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) Exec(ctx context.Context, r *api.ExecProcessRequest) (*ptypes.Empty, error) {
|
||||
if r.ExecID == "" {
|
||||
return nil, grpc.Errorf(codes.InvalidArgument, "exec id cannot be empty")
|
||||
}
|
||||
@@ -387,7 +387,7 @@ func (s *service) Exec(ctx context.Context, r *api.ExecProcessRequest) (*google_
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func (s *service) ResizePty(ctx context.Context, r *api.ResizePtyRequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) ResizePty(ctx context.Context, r *api.ResizePtyRequest) (*ptypes.Empty, error) {
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -407,7 +407,7 @@ func (s *service) ResizePty(ctx context.Context, r *api.ResizePtyRequest) (*goog
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func (s *service) CloseIO(ctx context.Context, r *api.CloseIORequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) CloseIO(ctx context.Context, r *api.CloseIORequest) (*ptypes.Empty, error) {
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -471,7 +471,7 @@ func (s *service) Checkpoint(ctx context.Context, r *api.CheckpointTaskRequest)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *service) Update(ctx context.Context, r *api.UpdateTaskRequest) (*google_protobuf.Empty, error) {
|
||||
func (s *service) Update(ctx context.Context, r *api.UpdateTaskRequest) (*ptypes.Empty, error) {
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
api "github.com/containerd/containerd/api/services/version/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
ctrdversion "github.com/containerd/containerd/version"
|
||||
empty "github.com/golang/protobuf/ptypes/empty"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@@ -31,7 +31,7 @@ func (s *service) Register(server *grpc.Server) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Version(ctx context.Context, _ *empty.Empty) (*api.VersionResponse, error) {
|
||||
func (s *service) Version(ctx context.Context, _ *ptypes.Empty) (*api.VersionResponse, error) {
|
||||
return &api.VersionResponse{
|
||||
Version: ctrdversion.Version,
|
||||
Revision: ctrdversion.Revision,
|
||||
|
||||
Reference in New Issue
Block a user