-
Notifications
You must be signed in to change notification settings - Fork 721
Expand file tree
/
Copy pathConfigResolver.ts
More file actions
34 lines (28 loc) · 1.18 KB
/
ConfigResolver.ts
File metadata and controls
34 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { createChildLogger } from '@aws-github-runner/aws-powertools-util';
export class Config {
createSpotWarningMetric: boolean;
createSpotTerminationMetric: boolean;
tagFilters: Record<string, string>;
prefix: string;
enableRunnerDeregistration: boolean;
ghesApiUrl: string;
constructor() {
const logger = createChildLogger('config-resolver');
logger.debug('Loading config from environment variables', { env: process.env });
this.createSpotWarningMetric = process.env.ENABLE_METRICS_SPOT_WARNING === 'true';
this.createSpotTerminationMetric = process.env.ENABLE_METRICS_SPOT_TERMINATION === 'true';
this.prefix = process.env.PREFIX ?? '';
this.enableRunnerDeregistration = process.env.ENABLE_RUNNER_DEREGISTRATION === 'true';
this.ghesApiUrl = process.env.GHES_URL ?? '';
this.tagFilters = { 'ghr:environment': this.prefix };
const rawTagFilters = process.env.TAG_FILTERS;
if (rawTagFilters && rawTagFilters !== 'null') {
try {
this.tagFilters = JSON.parse(rawTagFilters);
} catch (e) {
logger.error('Failed to parse TAG_FILTERS', { error: e });
}
}
logger.debug('Loaded config', { config: this });
}
}