Plugins: Bump Plugin SDK version and address instance management breaking changes (#68900)

* bump sdk and propagate ctx

* fix tests
This commit is contained in:
Will Browne
2023-05-24 10:19:34 +02:00
committed by GitHub
parent 7e816d010c
commit 286b9e08e9
50 changed files with 199 additions and 170 deletions

View File

@@ -82,7 +82,7 @@ func (s *Service) CallResource(ctx context.Context, req *backend.CallResourceReq
}
func (s *Service) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
dsInfo, err := s.getDSInfo(req.PluginContext)
dsInfo, err := s.getDSInfo(ctx, req.PluginContext)
if err != nil {
return nil, err
}
@@ -336,7 +336,7 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
return nil, err
}
dsInfo, err := s.getDSInfo(req.PluginContext)
dsInfo, err := s.getDSInfo(ctx, req.PluginContext)
if err != nil {
return nil, err
}
@@ -637,8 +637,8 @@ func addConfigData(frames data.Frames, dl string, unit string, period string) da
return frames
}
func (s *Service) getDSInfo(pluginCtx backend.PluginContext) (*datasourceInfo, error) {
i, err := s.im.Get(pluginCtx)
func (s *Service) getDSInfo(ctx context.Context, pluginCtx backend.PluginContext) (*datasourceInfo, error) {
i, err := s.im.Get(ctx, pluginCtx)
if err != nil {
return nil, err
}

View File

@@ -397,7 +397,7 @@ func writeResponse(rw http.ResponseWriter, code int, msg string) {
func (s *Service) getDataSourceFromHTTPReq(req *http.Request) (*datasourceInfo, error) {
ctx := req.Context()
pluginContext := httpadapter.PluginConfigFromContext(ctx)
i, err := s.im.Get(pluginContext)
i, err := s.im.Get(ctx, pluginContext)
if err != nil {
return nil, nil
}

View File

@@ -95,13 +95,13 @@ type fakeInstance struct {
services map[string]datasourceService
}
func (f *fakeInstance) Get(pluginContext backend.PluginContext) (instancemgmt.Instance, error) {
func (f *fakeInstance) Get(_ context.Context, _ backend.PluginContext) (instancemgmt.Instance, error) {
return &datasourceInfo{
services: f.services,
}, nil
}
func (f *fakeInstance) Do(pluginContext backend.PluginContext, fn instancemgmt.InstanceCallbackFunc) error {
func (f *fakeInstance) Do(_ context.Context, _ backend.PluginContext, _ instancemgmt.InstanceCallbackFunc) error {
return nil
}