-
Notifications
You must be signed in to change notification settings - Fork 399
/
index.js
37 lines (32 loc) · 985 Bytes
/
index.js
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
35
36
37
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'
const logger = require('../logger').child({ component: 'utilization' })
const VENDOR_METHODS = {
aws: require('./aws-info'),
pcf: require('./pcf-info'),
azure: require('./azure-info'),
gcp: require('./gcp-info'),
docker: require('./docker-info').getVendorInfo,
kubernetes: require('./kubernetes-info')
}
const VENDOR_NAMES = Object.keys(VENDOR_METHODS)
module.exports.getVendors = getVendors
function getVendors(agent, callback) {
let done = 0
let vendors = null
VENDOR_NAMES.forEach(function getVendorInfo(vendor) {
VENDOR_METHODS[vendor](agent, function getInfo(err, result) {
logger.trace('Vendor %s finished.', vendor)
if (result) {
vendors = vendors || Object.create(null)
vendors[vendor] = result
}
if (++done === VENDOR_NAMES.length) {
callback(null, vendors)
}
})
})
}