refactor(core): Port external storage config (no-changelog) (#10169)

This commit is contained in:
Iván Ovejero
2024-07-24 13:08:20 +02:00
committed by GitHub
parent f1a3791abc
commit 66c49bb6a1
5 changed files with 71 additions and 60 deletions

View File

@@ -0,0 +1,42 @@
import { Config, Env, Nested } from '../decorators';
@Config
class S3BucketConfig {
/** Name of the n8n bucket in S3-compatible external storage */
@Env('N8N_EXTERNAL_STORAGE_S3_BUCKET_NAME')
readonly name: string = '';
/** Region of the n8n bucket in S3-compatible external storage @example "us-east-1" */
@Env('N8N_EXTERNAL_STORAGE_S3_BUCKET_REGION')
readonly region: string = '';
}
@Config
class S3CredentialsConfig {
/** Access key in S3-compatible external storage */
@Env('N8N_EXTERNAL_STORAGE_S3_ACCESS_KEY')
readonly accessKey: string = '';
/** Access secret in S3-compatible external storage */
@Env('N8N_EXTERNAL_STORAGE_S3_ACCESS_SECRET')
readonly accessSecret: string = '';
}
@Config
class S3Config {
/** Host of the n8n bucket in S3-compatible external storage @example "s3.us-east-1.amazonaws.com" */
@Env('N8N_EXTERNAL_STORAGE_S3_HOST')
readonly host: string = '';
@Nested
readonly bucket: S3BucketConfig;
@Nested
readonly credentials: S3CredentialsConfig;
}
@Config
export class ExternalStorageConfig {
@Nested
readonly s3: S3Config;
}

View File

@@ -8,6 +8,7 @@ import { ExternalSecretsConfig } from './configs/external-secrets';
import { TemplatesConfig } from './configs/templates';
import { EventBusConfig } from './configs/event-bus';
import { NodesConfig } from './configs/nodes';
import { ExternalStorageConfig } from './configs/external-storage';
@Config
class UserManagementConfig {
@@ -18,29 +19,32 @@ class UserManagementConfig {
@Config
export class GlobalConfig {
@Nested
database: DatabaseConfig;
readonly database: DatabaseConfig;
@Nested
credentials: CredentialsConfig;
readonly credentials: CredentialsConfig;
@Nested
userManagement: UserManagementConfig;
readonly userManagement: UserManagementConfig;
@Nested
versionNotifications: VersionNotificationsConfig;
readonly versionNotifications: VersionNotificationsConfig;
@Nested
publicApi: PublicApiConfig;
readonly publicApi: PublicApiConfig;
@Nested
externalSecrets: ExternalSecretsConfig;
readonly externalSecrets: ExternalSecretsConfig;
@Nested
templates: TemplatesConfig;
readonly templates: TemplatesConfig;
@Nested
eventBus: EventBusConfig;
readonly eventBus: EventBusConfig;
@Nested
readonly nodes: NodesConfig;
@Nested
readonly externalStorage: ExternalStorageConfig;
}

View File

@@ -122,6 +122,19 @@ describe('GlobalConfig', () => {
endpoint: 'https://api.n8n.io/api/versions/',
infoUrl: 'https://docs.n8n.io/hosting/installation/updating/',
},
externalStorage: {
s3: {
host: '',
bucket: {
name: '',
region: '',
},
credentials: {
accessKey: '',
accessSecret: '',
},
},
},
};
it('should use all default values when no env variables are defined', () => {