Skip to content

Commit 5ab8872

Browse files
committed
feat(server): add backward compatibility for minio config
1 parent fee5ab3 commit 5ab8872

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/common/src/config-schema.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ export const minioConfigSchema = object({
7373
url: optional(string()),
7474
accessKey: optional(string()),
7575
secretKey: optional(string()),
76+
77+
/**
78+
* @deprecated Use url instead
79+
*/
80+
endPoint: optional(string()),
81+
/**
82+
* @deprecated Use url instead
83+
*/
84+
port: optional(number(), 9000),
85+
/**
86+
* @deprecated Use url instead
87+
*/
88+
useSSL: optional(boolean(), false),
7689
})
7790

7891
export const otelConfigSchema = object({

packages/common/src/env.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ export function parseEnvToConfig(env: Environment, logger?: Logger): Config {
7070
bucket: readEnvValue('MINIO_BUCKET', env),
7171
accessKey: readEnvValue('MINIO_ACCESS_KEY', env),
7272
secretKey: readEnvValue('MINIO_SECRET_KEY', env),
73+
74+
/**
75+
* For backward compatibility
76+
*/
77+
endPoint: readEnvValue('MINIO_ENDPOINT', env),
78+
port: readIntegerEnv('MINIO_PORT', env),
79+
useSSL: readBooleanEnv('MINIO_USE_SSL', env),
7380
},
7481
otel: {
7582
endpoint: readEnvValue('OTEL_EXPORTER_OTLP_ENDPOINT', env),
@@ -83,6 +90,12 @@ export function parseEnvToConfig(env: Environment, logger?: Logger): Config {
8390
throw new Error('Failed to parse config', { cause: parsedConfig.issues })
8491
}
8592

93+
// For backward compatibility
94+
if (parsedConfig.output.minio?.endPoint && parsedConfig.output.minio?.port) {
95+
parsedConfig.output.minio.url = `${parsedConfig.output.minio.useSSL ? 'https' : 'http'}://${parsedConfig.output.minio.endPoint}:${parsedConfig.output.minio.port}`
96+
logger?.withFields({ minio: parsedConfig.output.minio }).warn('MINIO_ENDPOINT and MINIO_PORT are deprecated, use MINIO_URL instead')
97+
}
98+
8699
logger?.withFields({ config: parsedConfig.output }).debug('Config parsed')
87100

88101
return parsedConfig.output

0 commit comments

Comments
 (0)