Skip to content

Commit

Permalink
fix(clickhouse): s3 validation - add forward slash
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Mar 20, 2024
1 parent d57250e commit cbc1548
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion flow/connectors/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"net/url"
"os"
"strings"

"github.com/ClickHouse/clickhouse-go/v2"
_ "github.com/ClickHouse/clickhouse-go/v2/lib/driver"
Expand Down Expand Up @@ -43,9 +44,14 @@ func ValidateS3(ctx context.Context, creds *utils.ClickHouseS3Credentials) error
return fmt.Errorf("failed to create S3 bucket and prefix: %w", err)
}

prefix := object.Prefix
if !strings.HasSuffix(prefix, "/") {
prefix += "/"
}

_, listErr := s3Client.ListObjectsV2(ctx, &s3.ListObjectsV2Input{
Bucket: &object.Bucket,
Prefix: &object.Prefix,
Prefix: &prefix,
},
)
if listErr != nil {
Expand Down
6 changes: 3 additions & 3 deletions flow/connectors/utils/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ func GetAWSCredentialsProvider(ctx context.Context, connectorName string, peerCr
if err != nil {
return nil, err
}
logger.LoggerFromCtx(ctx).Info("Received AWS credentials with role from peer for connector: %s" + connectorName)
logger.LoggerFromCtx(ctx).Info("Received AWS credentials with role from peer for connector: " + connectorName)
return NewConfigBasedAWSCredentialsProvider(awsConfig), nil
}
envCredentialsProvider := LoadPeerDBAWSEnvConfigProvider(connectorName)
if envCredentialsProvider != nil {
logger.LoggerFromCtx(ctx).Info("Received AWS credentials from PeerDB Env for connector: %s" + connectorName)
logger.LoggerFromCtx(ctx).Info("Received AWS credentials from PeerDB Env for connector: " + connectorName)
return envCredentialsProvider, nil
}

Expand All @@ -174,7 +174,7 @@ func GetAWSCredentialsProvider(ctx context.Context, connectorName string, peerCr
if err != nil {
return nil, err
}
logger.LoggerFromCtx(ctx).Info("Received AWS credentials from SDK config for connector: %s" + connectorName)
logger.LoggerFromCtx(ctx).Info("Received AWS credentials from SDK config for connector: " + connectorName)
return NewConfigBasedAWSCredentialsProvider(awsConfig), nil
}

Expand Down

0 comments on commit cbc1548

Please sign in to comment.