Skip to content

Commit

Permalink
move variables closer to where theyre used
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Feb 13, 2024
1 parent d0707cb commit 4274791
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions flow/connectors/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package connclickhouse

import (
"context"
"crypto/tls"
"database/sql"
"fmt"
"net/url"
Expand Down Expand Up @@ -94,11 +93,6 @@ func NewClickhouseConnector(
}

var clickhouseS3Creds *utils.ClickhouseS3Credentials
deploymentUID := shared.GetDeploymentUID()
flowName, _ := ctx.Value(shared.FlowNameKey).(string)
bucketPathSuffix := fmt.Sprintf("%s/%s",
url.PathEscape(deploymentUID), url.PathEscape(flowName))

// Get user provided S3 credentials
clickhouseS3Creds = &utils.ClickhouseS3Credentials{
AccessKeyID: config.AccessKeyId,
Expand All @@ -110,6 +104,11 @@ func NewClickhouseConnector(
if clickhouseS3Creds.AccessKeyID == "" &&
clickhouseS3Creds.SecretAccessKey == "" && clickhouseS3Creds.Region == "" &&
clickhouseS3Creds.BucketPath == "" {
deploymentUID := shared.GetDeploymentUID()
flowName, _ := ctx.Value(shared.FlowNameKey).(string)
bucketPathSuffix := fmt.Sprintf("%s/%s",
url.PathEscape(deploymentUID), url.PathEscape(flowName))

// Fallback: Get S3 credentials from environment
clickhouseS3Creds = utils.GetClickhouseAWSSecrets(bucketPathSuffix)
}
Expand Down Expand Up @@ -137,7 +136,7 @@ func connect(ctx context.Context, config *protos.ClickhouseConfig) (*sql.DB, err
Username: config.User,
Password: config.Password,
},
TLS: &tls.Config{MinVersion: tls.VersionTLS13},
// TLS: &tls.Config{MinVersion: tls.VersionTLS13},
Compression: &clickhouse.Compression{Method: clickhouse.CompressionLZ4},
ClientInfo: clickhouse.ClientInfo{
Products: []struct {
Expand Down

0 comments on commit 4274791

Please sign in to comment.