mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Update PDC pattern from latest plugin SDK changes (#76036)
* update with sdk * do sql * fix core plugins * fix proxy settings * bump SDK version * tidy * enable pdc for test * add codeowners
This commit is contained in:
@@ -97,8 +97,8 @@ func (s *Service) newInstanceSettings(cfg *setting.Cfg) datasource.InstanceFacto
|
||||
|
||||
driverName := "postgres"
|
||||
// register a proxy driver if the secure socks proxy is enabled
|
||||
proxyOpts := proxyutil.GetSQLProxyOptions(dsInfo)
|
||||
if sdkproxy.Cli.SecureSocksProxyEnabled(proxyOpts) {
|
||||
proxyOpts := proxyutil.GetSQLProxyOptions(cfg.SecureSocksDSProxy, dsInfo)
|
||||
if sdkproxy.New(proxyOpts).SecureSocksProxyEnabled() {
|
||||
driverName, err = createPostgresProxyDriver(cnnstr, proxyOpts)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
|
||||
@@ -55,10 +55,10 @@ type postgresProxyDriver struct {
|
||||
var _ driver.DriverContext = (*postgresProxyDriver)(nil)
|
||||
var _ core.Driver = (*postgresProxyDriver)(nil)
|
||||
|
||||
// newPostgresProxyDriver updates the dialer for a postgres connector with a dialer that proxys connections through the secure socks proxy
|
||||
// newPostgresProxyDriver updates the dialer for a postgres connector with a dialer that proxies connections through the secure socks proxy
|
||||
// and returns a new postgres driver to register
|
||||
func newPostgresProxyDriver(connector *pq.Connector, opts *sdkproxy.Options) (*postgresProxyDriver, error) {
|
||||
dialer, err := sdkproxy.Cli.NewSecureSocksProxyContextDialer(opts)
|
||||
dialer, err := sdkproxy.New(opts).NewSecureSocksProxyContextDialer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/sqleng"
|
||||
"github.com/grafana/grafana/pkg/tsdb/sqleng/proxyutil"
|
||||
"github.com/lib/pq"
|
||||
@@ -14,8 +15,16 @@ import (
|
||||
|
||||
func TestPostgresProxyDriver(t *testing.T) {
|
||||
dialect := "postgres"
|
||||
opts := proxyutil.GetSQLProxyOptions(sqleng.DataSourceInfo{UID: "1", JsonData: sqleng.JsonData{SecureDSProxy: true}})
|
||||
settings := proxyutil.SetupTestSecureSocksProxySettings(t)
|
||||
proxySettings := setting.SecureSocksDSProxySettings{
|
||||
Enabled: true,
|
||||
ClientCert: settings.ClientCert,
|
||||
ClientKey: settings.ClientKey,
|
||||
RootCA: settings.RootCA,
|
||||
ProxyAddress: settings.ProxyAddress,
|
||||
ServerName: settings.ServerName,
|
||||
}
|
||||
opts := proxyutil.GetSQLProxyOptions(proxySettings, sqleng.DataSourceInfo{UID: "1", JsonData: sqleng.JsonData{SecureDSProxy: true}})
|
||||
dbURL := "localhost:5432"
|
||||
cnnstr := fmt.Sprintf("postgres://auser:password@%s/db?sslmode=disable", dbURL)
|
||||
driverName, err := createPostgresProxyDriver(cnnstr, opts)
|
||||
|
||||
Reference in New Issue
Block a user