From 6165caaeffd968b3f6c0f98692d7a69870850dc3 Mon Sep 17 00:00:00 2001 From: MytsV Date: Mon, 21 Oct 2024 20:03:06 +0300 Subject: [PATCH] Make rule activity configurable with an environmental variable --- .env.development.local.template | 1 + .../core/port/secondary/env-config-gateway-output-port.ts | 5 +++++ src/lib/infrastructure/gateway/env-config-gateway.ts | 6 ++++++ .../gateway/rule-gateway/endpoints/create-rule-endpoint.ts | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.env.development.local.template b/.env.development.local.template index 17248068a..4bf6f3d25 100644 --- a/.env.development.local.template +++ b/.env.development.local.template @@ -17,6 +17,7 @@ NODE_TLS_REJECT_UNAUTHORIZED=0 [gateway] RUCIO_AUTH_HOST=https://rucio-devmaany.cern.ch:443 RUCIO_HOST=https://rucio-devmaany.cern.ch:443 +RULE_ACTIVITY=User Subscriptions [oidc] OIDC_ENABLED=true diff --git a/src/lib/core/port/secondary/env-config-gateway-output-port.ts b/src/lib/core/port/secondary/env-config-gateway-output-port.ts index 8a8fcaf16..c8396ed33 100644 --- a/src/lib/core/port/secondary/env-config-gateway-output-port.ts +++ b/src/lib/core/port/secondary/env-config-gateway-output-port.ts @@ -60,4 +60,9 @@ export default interface EnvConfigGatewayOutputPort { * @returns the URL of the VO/Experiment community that maintains the Rucio WebUI instance */ projectURL(): Promise; + + /** + * @returns the rule activity string + */ + ruleActivity(): Promise; } diff --git a/src/lib/infrastructure/gateway/env-config-gateway.ts b/src/lib/infrastructure/gateway/env-config-gateway.ts index 0a4a3a3ed..c77ce39cf 100644 --- a/src/lib/infrastructure/gateway/env-config-gateway.ts +++ b/src/lib/infrastructure/gateway/env-config-gateway.ts @@ -154,6 +154,12 @@ class EnvConfigGateway implements EnvConfigGatewayOutputPort { return Promise.resolve(true); } + async ruleActivity(): Promise { + const value = await this.get('RULE_ACTIVITY'); + // Return a default value if the environmental variable is not specified + return value ?? 'User Subscriptions'; + } + async get(key: string, required: boolean = false): Promise { let value = process.env[key]; if (value !== undefined) { diff --git a/src/lib/infrastructure/gateway/rule-gateway/endpoints/create-rule-endpoint.ts b/src/lib/infrastructure/gateway/rule-gateway/endpoints/create-rule-endpoint.ts index 19e247fcb..00808210f 100644 --- a/src/lib/infrastructure/gateway/rule-gateway/endpoints/create-rule-endpoint.ts +++ b/src/lib/infrastructure/gateway/rule-gateway/endpoints/create-rule-endpoint.ts @@ -14,7 +14,7 @@ export default class CreateRuleEndpoint extends BaseEndpoint { const rucioHost = await this.envConfigGateway.rucioHost(); const endpoint = `${rucioHost}/rules/`; - this.params.activity = 'User Subscriptions'; + this.params.activity = await this.envConfigGateway.ruleActivity(); const request: HTTPRequest = { method: 'POST',