Skip to content

Commit

Permalink
Make rule activity configurable with an environmental variable
Browse files Browse the repository at this point in the history
  • Loading branch information
MytsV authored and maany committed Nov 25, 2024
1 parent 5bcb8fb commit 4a67c4e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.development.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
PARAMS_ENCODING_ENABLED=false

[oidc]
Expand Down
5 changes: 5 additions & 0 deletions src/lib/core/port/secondary/env-config-gateway-output-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export default interface EnvConfigGatewayOutputPort {
*/
projectURL(): Promise<string>;

/**
* @returns the rule activity string
*/
ruleActivity(): Promise<string>;

/**
* @returns whether the query parameters should get URI encoded
*/
Expand Down
6 changes: 6 additions & 0 deletions src/lib/infrastructure/gateway/env-config-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ class EnvConfigGateway implements EnvConfigGatewayOutputPort {
return Promise.resolve(true);
}

async ruleActivity(): Promise<string> {
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<string | undefined> {
let value = process.env[key];
if (value !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class CreateRuleEndpoint extends BaseEndpoint<CreateRuleDTO> {
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',
Expand Down

0 comments on commit 4a67c4e

Please sign in to comment.