From 24043d354d97629029fdebc2d9f9173ee1e2010c Mon Sep 17 00:00:00 2001 From: tada5hi Date: Wed, 17 Jul 2024 17:13:32 +0200 Subject: [PATCH] feat: allow configuring master image repository & branch via env --- packages/server-core/src/config/env/constants.ts | 3 ++- packages/server-core/src/config/env/module.ts | 3 ++- packages/server-core/src/config/env/type.ts | 1 + .../server-core/src/domains/master-image/commands/sync.ts | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/server-core/src/config/env/constants.ts b/packages/server-core/src/config/env/constants.ts index 1cadfc430..28c8387f7 100644 --- a/packages/server-core/src/config/env/constants.ts +++ b/packages/server-core/src/config/env/constants.ts @@ -15,5 +15,6 @@ export enum ConfigDefaults { REDIS = 'redis://127.0.0.1', RABBITMQ = 'amqp://root:start123@127.0.0.1', VAULT = 'start123@http://127.0.0.1:8090/v1/', - MASTER_IMAGE = 'https://github.com/PHT-Medic/master-images/', + MASTER_IMAGE_URL = 'https://github.com/PrivateAim/master-images/', + MASTER_IMAGE_BRANCH = 'master', } diff --git a/packages/server-core/src/config/env/module.ts b/packages/server-core/src/config/env/module.ts index df4d62f57..0a270cc55 100644 --- a/packages/server-core/src/config/env/module.ts +++ b/packages/server-core/src/config/env/module.ts @@ -58,7 +58,8 @@ export function useEnv(key?: string) : any { authupApiURL: read('AUTHUP_URL'), appURL: read('APP_URL', 'http://127.0.0.1:3000/'), - masterImagesURL: read('MASTER_IMAGE_URL', ConfigDefaults.MASTER_IMAGE), + masterImagesURL: read('MASTER_IMAGE_URL', ConfigDefaults.MASTER_IMAGE_URL), + masterImagesBranch: read('MASTER_IMAGE_BRANCH', ConfigDefaults.MASTER_IMAGE_BRANCH), skipProjectApproval: readBool('SKIP_PROJECT_APPROVAL'), skipAnalysisApproval: readBool('SKIP_ANALYSIS_APPROVAL'), diff --git a/packages/server-core/src/config/env/type.ts b/packages/server-core/src/config/env/type.ts index 9b8686fa1..35ed9972c 100644 --- a/packages/server-core/src/config/env/type.ts +++ b/packages/server-core/src/config/env/type.ts @@ -23,6 +23,7 @@ export interface Environment { appURL: string, masterImagesURL: string, + masterImagesBranch: string, skipProjectApproval: boolean, skipAnalysisApproval: boolean diff --git a/packages/server-core/src/domains/master-image/commands/sync.ts b/packages/server-core/src/domains/master-image/commands/sync.ts index 2065378dd..16bc0d0f0 100644 --- a/packages/server-core/src/domains/master-image/commands/sync.ts +++ b/packages/server-core/src/domains/master-image/commands/sync.ts @@ -7,6 +7,7 @@ import { MasterImagesCommand, buildMasterImagesTaskQueueRouterPayload } from '@privateaim/server-analysis-manager-kit'; import { isQueueRouterUsable, useLogger, useQueueRouter } from '@privateaim/server-kit'; +import { useEnv } from '../../../config'; export async function runMasterImagesSynchronizeCommand() : Promise { if (!isQueueRouterUsable()) { @@ -17,8 +18,8 @@ export async function runMasterImagesSynchronizeCommand() : Promise { const message = buildMasterImagesTaskQueueRouterPayload({ command: MasterImagesCommand.SYNCHRONIZE, data: { - branch: 'master', // todo: extract from request - url: 'https://github.com/PrivateAim/master-images/', // todo: extract from request + branch: useEnv('masterImagesBranch'), + url: useEnv('masterImagesURL'), }, });