Skip to content

Commit

Permalink
Use latest plugin SDK API, Go version
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyeats committed Nov 14, 2023
1 parent f280375 commit 1d316cc
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull-request-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:

- name: Install Go environment
uses: actions/setup-go@v4
with:
go-version: 'stable'

- name: Install yarn dependencies
run: yarn install
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/run-backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ jobs:
strategy:
fail-fast: true
matrix:
go:
# version pinned until https://github.com/testcontainers/testcontainers-go/issues/1359
# is resolved
- '1.20.5'
clickhouse:
- 22.3
- 22.8
Expand All @@ -33,10 +29,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Go ${{ matrix.go }}
- name: Install Go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: 'stable'

- name: Build
run: go build -v ./...
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/run-frontend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
go:
- '1.20.x'

steps:
- uses: actions/checkout@v4
Expand All @@ -35,10 +32,10 @@ jobs:
with:
node-version-file: '.nvmrc'

- name: Install Go ${{ matrix.go }}
- name: Install Go
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
go-version: 'stable'

- name: Install yarn dependencies
run: yarn install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-k6e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Go 1.20.5
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.20.5
go-version: 'stable'

- name: Install Dagger CLI
run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; }
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/grafana/clickhouse-datasource

go 1.20
go 1.21

toolchain go1.21.4

require (
dagger.io/dagger v0.8.4
Expand Down
28 changes: 28 additions & 0 deletions go.sum

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions pkg/plugin/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ func (h *Clickhouse) Connect(config backend.DataSourceInstanceSettings, message
ClientInfo: clickhouse.ClientInfo{
Products: getClientInfoProducts(),
},
TLS: tlsConfig,
Addr: []string{fmt.Sprintf("%s:%d", settings.Server, settings.Port)},
TLS: tlsConfig,
Addr: []string{fmt.Sprintf("%s:%d", settings.Server, settings.Port)},
HttpUrlPath: settings.Path,
Auth: clickhouse.Auth{
Username: settings.Username,
Expand All @@ -161,8 +161,10 @@ func (h *Clickhouse) Connect(config backend.DataSourceInstanceSettings, message
Settings: customSettings,
}

if sdkproxy.Cli.SecureSocksProxyEnabled(settings.ProxyOptions) {
dialer, err := sdkproxy.Cli.NewSecureSocksProxyContextDialer(settings.ProxyOptions)
p := sdkproxy.New(settings.ProxyOptions)

if p.SecureSocksProxyEnabled() {
dialer, err := p.NewSecureSocksProxyContextDialer()
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ func LoadSettings(config backend.DataSourceInstanceSettings) (settings Settings,
settings.TlsClientKey = tlsClientKey
}

proxyOpts, err := config.ProxyOptions()
// proxy options are only able to be loaded via environment variables
// currently, so we pass `nil` here so they are loaded with defaults
proxyOpts, err := config.ProxyOptions(nil)

if err == nil && proxyOpts != nil {
// the sdk expects the timeout to not be a string
timeout, err := strconv.ParseFloat(settings.Timeout, 64)
Expand Down

0 comments on commit 1d316cc

Please sign in to comment.