mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 05:02:35 +08:00
Plugins: Add support for ResourceConversion (#91977)
This commit is contained in:
@ -25,6 +25,7 @@ type ClientV2 struct {
|
||||
grpcplugin.DataClient
|
||||
grpcplugin.StreamClient
|
||||
grpcplugin.AdmissionClient
|
||||
grpcplugin.ConversionClient
|
||||
pluginextensionv2.RendererPlugin
|
||||
secretsmanagerplugin.SecretsManagerPlugin
|
||||
}
|
||||
@ -50,6 +51,11 @@ func newClientV2(descriptor PluginDescriptor, logger log.Logger, rpcClient plugi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rawConversion, err := rpcClient.Dispense("conversion")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rawStream, err := rpcClient.Dispense("stream")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -90,6 +96,12 @@ func newClientV2(descriptor PluginDescriptor, logger log.Logger, rpcClient plugi
|
||||
}
|
||||
}
|
||||
|
||||
if rawConversion != nil {
|
||||
if conversionClient, ok := rawConversion.(grpcplugin.ConversionClient); ok {
|
||||
c.ConversionClient = conversionClient
|
||||
}
|
||||
}
|
||||
|
||||
if rawStream != nil {
|
||||
if streamClient, ok := rawStream.(grpcplugin.StreamClient); ok {
|
||||
c.StreamClient = streamClient
|
||||
@ -308,13 +320,13 @@ func (c *ClientV2) MutateAdmission(ctx context.Context, req *backend.AdmissionRe
|
||||
return backend.FromProto().MutationResponse(protoResp), nil
|
||||
}
|
||||
|
||||
func (c *ClientV2) ConvertObject(ctx context.Context, req *backend.ConversionRequest) (*backend.ConversionResponse, error) {
|
||||
if c.AdmissionClient == nil {
|
||||
func (c *ClientV2) ConvertObjects(ctx context.Context, req *backend.ConversionRequest) (*backend.ConversionResponse, error) {
|
||||
if c.ConversionClient == nil {
|
||||
return nil, plugins.ErrMethodNotImplemented
|
||||
}
|
||||
|
||||
protoReq := backend.ToProto().ConversionRequest(req)
|
||||
protoResp, err := c.AdmissionClient.ConvertObject(ctx, protoReq)
|
||||
protoResp, err := c.ConversionClient.ConvertObjects(ctx, protoReq)
|
||||
|
||||
if err != nil {
|
||||
if status.Code(err) == codes.Unimplemented {
|
||||
|
Reference in New Issue
Block a user