Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make rule activity configurable with an environmental variable #499

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading