Plugins: Fix circular reference in customOptions leading to MarshalJSON errors (#62328)

* Plugins: test ds.JsonData.MarshalJSON()

* CustomOptions: copy to avoid cyclic marshal
pull/62563/head^2
Yasir Ekinci 2 years ago committed by GitHub
parent 850d5141cf
commit c41f97029e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      pkg/services/datasources/service/datasource.go
  2. 4
      pkg/services/datasources/service/datasource_test.go

@ -417,7 +417,10 @@ func (s *Service) httpClientOptions(ctx context.Context, ds *datasources.DataSou
if ds.JsonData != nil {
opts.CustomOptions = ds.JsonData.MustMap()
// allow the plugin sdk to get the json data in JSONDataFromHTTPClientOptions
opts.CustomOptions["grafanaData"] = ds.JsonData.MustMap()
opts.CustomOptions["grafanaData"] = make(map[string]interface{})
for k, v := range opts.CustomOptions {
opts.CustomOptions[k] = v
}
}
if ds.BasicAuth {
password, err := s.DecryptedBasicAuthPassword(ctx, ds)

@ -429,6 +429,10 @@ func TestService_GetHttpTransport(t *testing.T) {
require.NotNil(t, rt)
tr := configuredTransport
// make sure we can still marshal the JsonData after httpClientOptions (avoid cycles)
_, err = ds.JsonData.MarshalJSON()
require.NoError(t, err)
require.False(t, tr.TLSClientConfig.InsecureSkipVerify)
// Ignoring deprecation, the system will not include the root CA
// used in this scenario.

Loading…
Cancel
Save