1 | const ConfigFile = require('./abstract-config-file');
|
2 |
|
3 |
|
4 | let instance = null;
|
5 |
|
6 | module.exports = class AppConfig extends ConfigFile {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 | constructor(filePath) {
|
13 | if (instance && instance.path === filePath) {
|
14 | return instance;
|
15 | }
|
16 |
|
17 | super(filePath);
|
18 | instance = this;
|
19 | }
|
20 |
|
21 | static getInstance() {
|
22 | return instance;
|
23 | }
|
24 |
|
25 | static dispose() {
|
26 | instance = null;
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 | getAwsProfile(profile) {
|
32 | return this.getProperty(['profiles', profile, 'aws_profile']);
|
33 | }
|
34 |
|
35 | setAwsProfile(profile, awsProfile) {
|
36 | this.setProperty(['profiles', profile, 'aws_profile'], awsProfile);
|
37 | }
|
38 |
|
39 | getToken(profile) {
|
40 | return this.getProperty(['profiles', profile, 'token']);
|
41 | }
|
42 |
|
43 | setToken(profile, tokenObject) {
|
44 | this.setProperty(['profiles', profile, 'token'], tokenObject);
|
45 | }
|
46 |
|
47 | getVendorId(profile) {
|
48 | return this.getProperty(['profiles', profile, 'vendor_id']);
|
49 | }
|
50 |
|
51 | setVendorId(profile, vendorId) {
|
52 | this.setProperty(['profiles', profile, 'vendor_id'], vendorId);
|
53 | }
|
54 |
|
55 | |
56 |
|
57 |
|
58 |
|
59 | getProfilesList() {
|
60 | const profilesList = [];
|
61 | const profilesObj = this.getProperty(['profiles']);
|
62 | for (const profile of Object.getOwnPropertyNames(profilesObj)) {
|
63 | profilesList.push({
|
64 | askProfile: profile,
|
65 | awsProfile: profilesObj[profile].aws_profile
|
66 | });
|
67 | }
|
68 | return profilesList;
|
69 | }
|
70 | };
|