Skip to content

Commit 96bee34

Browse files
committed
refactor(staging): move S3 bucket name fallback into PeerDBClickHouseStagingBucketName
Centralize the fallback from PEERDB_CLICKHOUSE_STAGING_BUCKET_NAME to the legacy PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME in the config lookup function, simplifying createS3StagingStore.
1 parent 70ad58e commit 96bee34

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

flow/connectors/clickhouse/staging.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,13 @@ func createS3StagingStore(
8181
}
8282

8383
if awsBucketPath == "" {
84+
if unifiedBucketName == "" {
85+
return nil, nil, errors.New("PeerDB ClickHouse Bucket Name not set")
86+
}
8487
deploymentUID := internal.PeerDBDeploymentUID()
8588
flowName, _ := ctx.Value(shared.FlowNameKey).(string)
8689
bucketPathSuffix := fmt.Sprintf("%s/%s", url.PathEscape(deploymentUID), url.PathEscape(flowName))
87-
// Prefer unified bucket name, fall back to legacy S3-specific env var.
88-
awsBucketName := unifiedBucketName
89-
if awsBucketName == "" {
90-
awsBucketName, err = internal.PeerDBClickHouseAWSS3BucketName(ctx, env)
91-
if err != nil {
92-
return nil, nil, fmt.Errorf("failed to get PeerDB ClickHouse Bucket Name: %w", err)
93-
}
94-
}
95-
if awsBucketName == "" {
96-
return nil, nil, errors.New("PeerDB ClickHouse Bucket Name not set")
97-
}
98-
awsBucketPath = fmt.Sprintf("s3://%s/%s", awsBucketName, bucketPathSuffix)
90+
awsBucketPath = fmt.Sprintf("s3://%s/%s", unifiedBucketName, bucketPathSuffix)
9991
}
10092

10193
// S3 with session tokens requires ClickHouse >= 24.3.1

flow/internal/dynamicconf.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,15 @@ func PeerDBClickHouseStagingProvider(ctx context.Context, env map[string]string)
731731
}
732732

733733
func PeerDBClickHouseStagingBucketName(ctx context.Context, env map[string]string) (string, error) {
734-
return dynLookup(ctx, env, "PEERDB_CLICKHOUSE_STAGING_BUCKET_NAME")
734+
name, err := dynLookup(ctx, env, "PEERDB_CLICKHOUSE_STAGING_BUCKET_NAME")
735+
if err != nil {
736+
return "", err
737+
}
738+
if name != "" {
739+
return name, nil
740+
}
741+
// Fall back to legacy S3-specific env var.
742+
return dynLookup(ctx, env, "PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME")
735743
}
736744

737745
func PeerDBS3UuidPrefix(ctx context.Context, env map[string]string) (bool, error) {

0 commit comments

Comments
 (0)