From 222f03f168bb509a944d7817696a8ab8a3be6faa Mon Sep 17 00:00:00 2001 From: Amogh-Bharadwaj Date: Tue, 13 Feb 2024 06:04:22 +0530 Subject: [PATCH] cleanup --- flow/connectors/clickhouse/clickhouse.go | 26 +++++++++++--------- flow/connectors/utils/aws.go | 4 +-- ui/components/PeerForms/ClickhouseConfig.tsx | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/flow/connectors/clickhouse/clickhouse.go b/flow/connectors/clickhouse/clickhouse.go index 44e931379c..83fdcc76cd 100644 --- a/flow/connectors/clickhouse/clickhouse.go +++ b/flow/connectors/clickhouse/clickhouse.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "database/sql" "fmt" + "net/url" "github.com/ClickHouse/clickhouse-go/v2" _ "github.com/ClickHouse/clickhouse-go/v2/lib/driver" @@ -95,18 +96,21 @@ func NewClickhouseConnector( var clickhouseS3Creds *utils.ClickhouseS3Credentials deploymentUID := shared.GetDeploymentUID() flowName, _ := ctx.Value(shared.FlowNameKey).(string) - bucketPathSuffix := fmt.Sprintf("%s/%s", deploymentUID, flowName) - // Get S3 credentials from environment - clickhouseS3Creds = utils.GetClickhouseAWSSecrets(bucketPathSuffix) + bucketPathSuffix := fmt.Sprintf("%s/%s", url.PathEscape(deploymentUID), flowName) + + // Get user provided S3 credentials + clickhouseS3Creds = &utils.ClickhouseS3Credentials{ + AccessKeyID: config.AccessKeyId, + SecretAccessKey: config.SecretAccessKey, + Region: config.Region, + BucketPath: config.S3Path, + } + if clickhouseS3Creds.AccessKeyID == "" && - clickhouseS3Creds.SecretAccessKey == "" && clickhouseS3Creds.Region == "" { - // Fallback: user provided S3 credentials - clickhouseS3Creds = &utils.ClickhouseS3Credentials{ - AccessKeyID: config.AccessKeyId, - SecretAccessKey: config.SecretAccessKey, - Region: config.Region, - BucketPath: config.S3Path, - } + clickhouseS3Creds.SecretAccessKey == "" && clickhouseS3Creds.Region == "" && + clickhouseS3Creds.BucketPath == "" { + // Fallback: Get S3 credentials from environment + clickhouseS3Creds = utils.GetClickhouseAWSSecrets(bucketPathSuffix) } validateErr := ValidateS3(ctx, clickhouseS3Creds) diff --git a/flow/connectors/utils/aws.go b/flow/connectors/utils/aws.go index df1abba7f3..b62522b28c 100644 --- a/flow/connectors/utils/aws.go +++ b/flow/connectors/utils/aws.go @@ -3,7 +3,6 @@ package utils import ( "fmt" "net/http" - "net/url" "os" "strings" "time" @@ -86,8 +85,7 @@ func GetClickhouseAWSSecrets(bucketPathSuffix string) *ClickhouseS3Credentials { awsSecret := os.Getenv("PEERDB_CLICKHOUSE_AWS_CREDENTIALS_AWS_SECRET_ACCESS_KEY") awsBucketName := os.Getenv("PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME") - escapedPathSuffix := url.PathEscape(bucketPathSuffix) - awsBucketPath := fmt.Sprintf("s3://%s/%s", awsBucketName, escapedPathSuffix) + awsBucketPath := fmt.Sprintf("s3://%s/%s", awsBucketName, bucketPathSuffix) return &ClickhouseS3Credentials{ AccessKeyID: awsKey, SecretAccessKey: awsSecret, diff --git a/ui/components/PeerForms/ClickhouseConfig.tsx b/ui/components/PeerForms/ClickhouseConfig.tsx index c1a7ab93e4..a0e85c7076 100644 --- a/ui/components/PeerForms/ClickhouseConfig.tsx +++ b/ui/components/PeerForms/ClickhouseConfig.tsx @@ -83,7 +83,7 @@ export default function ClickhouseForm({ settings, setter }: ConfigProps) { .map((setting, id) => ( {setting.label} } + label={} action={