From c0311283a5d91c4b6f5b2a2c2f07a33babd0bd3f Mon Sep 17 00:00:00 2001 From: Creation's Date: Thu, 9 Jan 2025 01:28:18 -0500 Subject: [PATCH] feat: add DATASOURCE_S3_FORCE_PATH_STYLE (#658) Co-authored-by: dicedtomato <35403473+diced@users.noreply.github.com> --- src/lib/config/read.ts | 2 ++ src/lib/config/validate.ts | 1 + src/lib/datasource/S3.ts | 2 ++ src/lib/datasource/index.ts | 1 + 4 files changed, 6 insertions(+) diff --git a/src/lib/config/read.ts b/src/lib/config/read.ts index e1a251a9..a917cd82 100755 --- a/src/lib/config/read.ts +++ b/src/lib/config/read.ts @@ -156,6 +156,7 @@ export const PROP_TO_ENV = { 'datasource.s3.region': 'DATASOURCE_S3_REGION', 'datasource.s3.bucket': 'DATASOURCE_S3_BUCKET', 'datasource.s3.endpoint': 'DATASOURCE_S3_ENDPOINT', + 'datasource.s3.forcePathStyle': 'DATASOURCE_S3_FORCE_PATH_STYLE', 'datasource.local.directory': 'DATASOURCE_LOCAL_DIRECTORY', @@ -321,6 +322,7 @@ export function readEnv() { env('datasource.s3.region', 'string'), env('datasource.s3.bucket', 'string'), env('datasource.s3.endpoint', 'string'), + env('datasource.s3.forcePathStyle', 'boolean'), env('datasource.local.directory', 'string'), diff --git a/src/lib/config/validate.ts b/src/lib/config/validate.ts index 71b049f8..98ee8c53 100755 --- a/src/lib/config/validate.ts +++ b/src/lib/config/validate.ts @@ -109,6 +109,7 @@ export const schema = z.object({ region: z.string(), bucket: z.string(), endpoint: z.string().nullable().default(null), + forcePathStyle: z.boolean().default(false), }) .optional(), local: z diff --git a/src/lib/datasource/S3.ts b/src/lib/datasource/S3.ts index 17054b2b..089dd64b 100644 --- a/src/lib/datasource/S3.ts +++ b/src/lib/datasource/S3.ts @@ -24,6 +24,7 @@ export class S3Datasource extends Datasource { region?: string; bucket: string; endpoint?: string | null; + forcePathStyle?: boolean; }, ) { super(); @@ -35,6 +36,7 @@ export class S3Datasource extends Datasource { }, region: this.options.region ?? undefined, endpoint: this.options.endpoint ?? undefined, + forcePathStyle: this.options.forcePathStyle ?? false, }); this.ensureBucketExists(); diff --git a/src/lib/datasource/index.ts b/src/lib/datasource/index.ts index 19359a47..e55130b1 100755 --- a/src/lib/datasource/index.ts +++ b/src/lib/datasource/index.ts @@ -27,6 +27,7 @@ function getDatasource(conf?: typeof config): void { region: config.datasource.s3?.region, bucket: config.datasource.s3!.bucket, endpoint: config.datasource.s3?.endpoint, + forcePathStyle: config.datasource.s3?.forcePathStyle, }); break; default: