Cleanup introspection interface
Split service proxy from service plugin. Make introspection service easier for clients to use. Update service proxy to support grpc and ttrpc. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -19,13 +19,17 @@ package introspection
|
||||
import (
|
||||
context "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
api "github.com/containerd/containerd/v2/api/services/introspection/v1"
|
||||
"github.com/containerd/containerd/v2/core/introspection"
|
||||
"github.com/containerd/containerd/v2/plugins"
|
||||
"github.com/containerd/containerd/v2/plugins/services"
|
||||
ptypes "github.com/containerd/containerd/v2/protobuf/types"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/plugin"
|
||||
"github.com/containerd/plugin/registry"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -54,7 +58,7 @@ func init() {
|
||||
}
|
||||
|
||||
type server struct {
|
||||
local api.IntrospectionClient
|
||||
local introspection.Service
|
||||
api.UnimplementedIntrospectionServer
|
||||
}
|
||||
|
||||
@@ -65,14 +69,25 @@ func (s *server) Register(server *grpc.Server) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *server) Plugins(ctx context.Context, req *api.PluginsRequest) (*api.PluginsResponse, error) {
|
||||
return s.local.Plugins(ctx, req)
|
||||
func (s *server) Plugins(ctx context.Context, req *api.PluginsRequest) (resp *api.PluginsResponse, err error) {
|
||||
resp, err = s.local.Plugins(ctx, req.Filters...)
|
||||
return resp, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
func (s *server) Server(ctx context.Context, empty *ptypes.Empty) (*api.ServerResponse, error) {
|
||||
return s.local.Server(ctx, empty)
|
||||
func (s *server) Server(ctx context.Context, _ *ptypes.Empty) (resp *api.ServerResponse, err error) {
|
||||
resp, err = s.local.Server(ctx)
|
||||
return resp, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
func (s *server) PluginInfo(ctx context.Context, req *api.PluginInfoRequest) (*api.PluginInfoResponse, error) {
|
||||
return s.local.PluginInfo(ctx, req)
|
||||
func (s *server) PluginInfo(ctx context.Context, req *api.PluginInfoRequest) (resp *api.PluginInfoResponse, err error) {
|
||||
var options any
|
||||
if req.Options != nil {
|
||||
options, err = typeurl.UnmarshalAny(req.Options)
|
||||
if err != nil {
|
||||
return resp, errdefs.ToGRPC(fmt.Errorf("failed to unmarshal plugin info Options: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
resp, err = s.local.PluginInfo(ctx, req.Type, req.ID, options)
|
||||
return resp, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user