@cloud-copilot/iam-lens
Version:
Visibility in IAM in and across AWS accounts
58 lines • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTestDatasetClient = getTestDatasetClient;
exports.getTestDatasetConfigs = getTestDatasetConfigs;
const fs_1 = require("fs");
const path_1 = require("path");
const url_1 = require("url");
const collect_js_1 = require("../collect/collect.js");
// @ts-ignore
const __dirname = (0, path_1.dirname)((0, url_1.fileURLToPath)(import.meta.url));
/**
* Resolves the absolute path for a test dataset directory.
*
* @param dataSetId - The numeric ID suffix of the dataset (e.g. "1" for iam-data-1)
* @returns Absolute path to the dataset directory
*/
function datasetPath(dataSetId) {
return (0, path_1.resolve)((0, path_1.join)(__dirname, `iam-data-${dataSetId}`));
}
/**
* Get an IAMCollectClient for a test database
*
* @param dataSetId the ID of the test dataset to use
* @returns IamCollectClient instance configured for the specified dataset
*/
async function getTestDatasetClient(dataSetId) {
const path = datasetPath(dataSetId);
if (!(0, fs_1.existsSync)(path)) {
throw new Error(`Test dataset with ID ${dataSetId} does not exist at path ${path}. Someone messed up.`);
}
return (0, collect_js_1.getCollectClient)([
{
iamCollectVersion: '0.0.0',
storage: {
type: 'file',
path
}
}
], 'aws');
}
/**
* Get TopLevelConfig array for a test dataset.
*
* @param dataSetId - The numeric ID suffix of the dataset
* @returns Configuration array pointing to the dataset's file storage
*/
function getTestDatasetConfigs(dataSetId) {
return [
{
iamCollectVersion: '0.0.0',
storage: {
type: 'file',
path: datasetPath(dataSetId)
}
}
];
}
//# sourceMappingURL=testClient.js.map