()
| 19 | static hidden = false |
| 20 | |
| 21 | async run(): Promise<void> { |
| 22 | try { |
| 23 | const installedPolicies = await this.add(PluginType.PolicyPack) |
| 24 | |
| 25 | for (const installedPolicy of installedPolicies) { |
| 26 | const { |
| 27 | key, |
| 28 | plugin: { default: { provider } } = { default: { provider: '' } }, |
| 29 | } = installedPolicy |
| 30 | |
| 31 | // Save policy to CG config file |
| 32 | const config = this.getCGConfig() || DEFAULT_CG_CONFIG |
| 33 | let configuredPolicies = |
| 34 | config.cloudGraph.plugins?.[PluginType.PolicyPack] || [] |
| 35 | if (isEmpty(configuredPolicies)) { |
| 36 | // Set new Policy Pack Plugin array |
| 37 | configuredPolicies = [ |
| 38 | { |
| 39 | name: key, |
| 40 | providers: [provider], |
| 41 | }, |
| 42 | ] |
| 43 | } else { |
| 44 | // Add policy to Policy Pack Plugin array |
| 45 | configuredPolicies = [ |
| 46 | ...configuredPolicies, |
| 47 | { |
| 48 | name: key, |
| 49 | providers: [provider], |
| 50 | }, |
| 51 | ] |
| 52 | } |
| 53 | if (!config.cloudGraph.plugin) { |
| 54 | config.cloudGraph.plugins = {} |
| 55 | } |
| 56 | config.cloudGraph.plugins[PluginType.PolicyPack] = uniqBy( |
| 57 | configuredPolicies, |
| 58 | 'name' |
| 59 | ) |
| 60 | this.saveCloudGraphConfigFile(config) |
| 61 | } |
| 62 | } catch (error) { |
| 63 | this.logger.debug(error) |
| 64 | } |
| 65 | } |
| 66 | } |
nothing calls this directly
no test coverage detected