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:
@@ -111,8 +111,8 @@ func newInstanceSettings(cfg *setting.Cfg) datasource.InstanceFactoryFunc {
|
||||
}
|
||||
|
||||
// register a new 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() {
|
||||
URL, err := ParseURL(dsInfo.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,7 +71,7 @@ var _ core.Driver = (*mssqlProxyDriver)(nil)
|
||||
// newMSSQLProxyDriver updates the dialer for a mssql connector with a dialer that proxys connections through the secure socks proxy
|
||||
// and returns a new mssql driver to register
|
||||
func newMSSQLProxyDriver(connector *mssql.Connector, hostName string, opts *sdkproxy.Options) (*mssqlProxyDriver, 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"
|
||||
mssql "github.com/microsoft/go-mssqldb"
|
||||
@@ -14,8 +15,16 @@ import (
|
||||
|
||||
func TestMSSQLProxyDriver(t *testing.T) {
|
||||
settings := proxyutil.SetupTestSecureSocksProxySettings(t)
|
||||
proxySettings := setting.SecureSocksDSProxySettings{
|
||||
Enabled: true,
|
||||
ClientCert: settings.ClientCert,
|
||||
ClientKey: settings.ClientKey,
|
||||
RootCA: settings.RootCA,
|
||||
ProxyAddress: settings.ProxyAddress,
|
||||
ServerName: settings.ServerName,
|
||||
}
|
||||
dialect := "mssql"
|
||||
opts := proxyutil.GetSQLProxyOptions(sqleng.DataSourceInfo{UID: "1", JsonData: sqleng.JsonData{SecureDSProxy: true}})
|
||||
opts := proxyutil.GetSQLProxyOptions(proxySettings, sqleng.DataSourceInfo{UID: "1", JsonData: sqleng.JsonData{SecureDSProxy: true}})
|
||||
cnnstr := "server=127.0.0.1;port=1433;user id=sa;password=yourStrong(!)Password;database=db"
|
||||
driverName, err := createMSSQLProxyDriver(cnnstr, "127.0.0.1", opts)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user