Plugins: Add sql support for the secure socks proxy (#64630)

This commit is contained in:
Stephanie Hingtgen
2023-03-16 07:54:19 -05:00
committed by GitHub
parent 68e38aad6a
commit 10db808ea1
19 changed files with 651 additions and 104 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/sqleng"
)
@ -60,6 +61,7 @@ func (s *Service) newInstanceSettings(cfg *setting.Cfg) datasource.InstanceFacto
ConnMaxLifetime: 14400,
Timescaledb: false,
ConfigurationMethod: "file-path",
SecureDSProxy: false,
}
err := json.Unmarshal(settings.JSONData, &jsonData)
@ -92,8 +94,17 @@ func (s *Service) newInstanceSettings(cfg *setting.Cfg) datasource.InstanceFacto
logger.Debug("GetEngine", "connection", cnnstr)
}
driverName := "postgres"
// register a proxy driver if the secure socks proxy is enabled
if cfg.IsFeatureToggleEnabled(featuremgmt.FlagSecureSocksDatasourceProxy) && cfg.SecureSocksDSProxy.Enabled && jsonData.SecureDSProxy {
driverName, err = createPostgresProxyDriver(&cfg.SecureSocksDSProxy, cnnstr)
if err != nil {
return "", nil
}
}
config := sqleng.DataPluginConfiguration{
DriverName: "postgres",
DriverName: driverName,
ConnectionString: cnnstr,
DSInfo: dsInfo,
MetricColumnTypes: []string{"UNKNOWN", "TEXT", "VARCHAR", "CHAR"},