Skip to content

Commit 4a67c4e

Browse files
MytsVmaany
authored andcommitted
Make rule activity configurable with an environmental variable
1 parent 5bcb8fb commit 4a67c4e

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

.env.development.local.template

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ NODE_TLS_REJECT_UNAUTHORIZED=0
1717
[gateway]
1818
RUCIO_AUTH_HOST=https://rucio-devmaany.cern.ch:443
1919
RUCIO_HOST=https://rucio-devmaany.cern.ch:443
20+
RULE_ACTIVITY=User Subscriptions
2021
PARAMS_ENCODING_ENABLED=false
2122

2223
[oidc]

src/lib/core/port/secondary/env-config-gateway-output-port.ts

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ export default interface EnvConfigGatewayOutputPort {
6161
*/
6262
projectURL(): Promise<string>;
6363

64+
/**
65+
* @returns the rule activity string
66+
*/
67+
ruleActivity(): Promise<string>;
68+
6469
/**
6570
* @returns whether the query parameters should get URI encoded
6671
*/

src/lib/infrastructure/gateway/env-config-gateway.ts

+6
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class EnvConfigGateway implements EnvConfigGatewayOutputPort {
154154
return Promise.resolve(true);
155155
}
156156

157+
async ruleActivity(): Promise<string> {
158+
const value = await this.get('RULE_ACTIVITY');
159+
// Return a default value if the environmental variable is not specified
160+
return value ?? 'User Subscriptions';
161+
}
162+
157163
async get(key: string, required: boolean = false): Promise<string | undefined> {
158164
let value = process.env[key];
159165
if (value !== undefined) {

src/lib/infrastructure/gateway/rule-gateway/endpoints/create-rule-endpoint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class CreateRuleEndpoint extends BaseEndpoint<CreateRuleDTO> {
1414
const rucioHost = await this.envConfigGateway.rucioHost();
1515
const endpoint = `${rucioHost}/rules/`;
1616

17-
this.params.activity = 'User Subscriptions';
17+
this.params.activity = await this.envConfigGateway.ruleActivity();
1818

1919
const request: HTTPRequest = {
2020
method: 'POST',

0 commit comments

Comments
 (0)