@opscompass/opscompass-cli 1.0.47 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/colors.js +5 -5
- package/credentials.js +20 -29
- package/environment/current.js +6 -6
- package/environment/demo.js +6 -6
- package/environment/dev.js +6 -6
- package/environment/local.js +6 -6
- package/environment/production.js +6 -6
- package/error.js +1 -1
- package/index.js +20 -20
- package/lib/cliHelpers.js +34 -15
- package/lib/consts.js +2 -11
- package/lib/homeInteraction.js +21 -22
- package/lib/maskValues.js +17 -17
- package/lib/parseMetrics.js +25 -21
- package/lib/pgpTools.js +8 -10
- package/lib/utils.js +18 -22
- package/login.js +90 -40
- package/modules/accounts.js +32 -26
- package/modules/compliance.js +75 -76
- package/modules/data-gathering-scripts.js +41 -41
- package/modules/defaults.js +12 -12
- package/modules/expiration-info.js +54 -25
- package/modules/license-manager/microsoft.js +95 -72
- package/modules/license-manager/nutanix.js +31 -22
- package/modules/license-manager/vcenter.js +31 -22
- package/modules/license-manager.js +89 -91
- package/modules/resources.js +140 -70
- package/modules.js +31 -15
- package/oauth.js +2 -2
- package/opscompass.js +8 -9
- package/package.json +3 -2
- package/updates.js +9 -11
package/modules/resources.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getOpsCompassClient } from "../opscompass.js";
|
|
2
|
+
import { parseMetrics } from "../lib/parseMetrics.js";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
4
|
|
|
5
5
|
const actionMap = {
|
|
6
|
-
|
|
6
|
+
get: "get",
|
|
7
7
|
"get-compliance": "getCompliance",
|
|
8
8
|
"get-drift": "getDrift",
|
|
9
9
|
"get-tags": "getTags",
|
|
10
10
|
"add-tags": "addTags",
|
|
11
11
|
"remove-tags": "removeTags",
|
|
12
|
-
|
|
13
|
-
"send-external-resources": "sendExternalResources"
|
|
12
|
+
list: "list",
|
|
13
|
+
"send-external-resources": "sendExternalResources",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
async function scan(args) {
|
|
@@ -18,12 +18,12 @@ async function scan(args) {
|
|
|
18
18
|
switch (args[i].toLowerCase()) {
|
|
19
19
|
case "--company":
|
|
20
20
|
callParams.company = args[++i];
|
|
21
|
-
|
|
21
|
+
break;
|
|
22
22
|
case "--account":
|
|
23
23
|
callParams.account = args[++i];
|
|
24
|
-
|
|
25
|
-
case "--resourcetags":
|
|
26
|
-
case "--resource-tags":
|
|
24
|
+
break;
|
|
25
|
+
case "--resourcetags":
|
|
26
|
+
case "--resource-tags":
|
|
27
27
|
if (typeof callParams.resourceTags === "string") {
|
|
28
28
|
callParams.resourceTags = [callParams.resourceTags];
|
|
29
29
|
}
|
|
@@ -32,9 +32,9 @@ async function scan(args) {
|
|
|
32
32
|
} else {
|
|
33
33
|
callParams.resourceTags = args[++i];
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
case "--resource-ids":
|
|
37
|
-
case "--resourceids":
|
|
35
|
+
break;
|
|
36
|
+
case "--resource-ids":
|
|
37
|
+
case "--resourceids":
|
|
38
38
|
if (typeof callParams.resourceIds === "string") {
|
|
39
39
|
callParams.resourceIds = [callParams.resourceIds];
|
|
40
40
|
}
|
|
@@ -43,8 +43,8 @@ async function scan(args) {
|
|
|
43
43
|
} else {
|
|
44
44
|
callParams.resourceIds = args[++i];
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
case "--ids":
|
|
46
|
+
break;
|
|
47
|
+
case "--ids":
|
|
48
48
|
if (typeof callParams.ids === "string") {
|
|
49
49
|
callParams.ids = [callParams.ids];
|
|
50
50
|
}
|
|
@@ -53,8 +53,7 @@ async function scan(args) {
|
|
|
53
53
|
} else {
|
|
54
54
|
callParams.ids = args[++i];
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
break;
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -63,9 +62,13 @@ async function scan(args) {
|
|
|
63
62
|
ids: callParams.ids,
|
|
64
63
|
resourceIds: callParams.resourceIds,
|
|
65
64
|
resourceTags: callParams.resourceTags,
|
|
66
|
-
}
|
|
65
|
+
};
|
|
67
66
|
|
|
68
|
-
const resource = await client.resources.scan(
|
|
67
|
+
const resource = await client.resources.scan(
|
|
68
|
+
callParams.company,
|
|
69
|
+
callParams.account,
|
|
70
|
+
optionalParams,
|
|
71
|
+
);
|
|
69
72
|
|
|
70
73
|
console.log(JSON.stringify(resource, null, 2));
|
|
71
74
|
}
|
|
@@ -76,7 +79,7 @@ async function get(action, args) {
|
|
|
76
79
|
case "--company":
|
|
77
80
|
callParams.company = args[++i];
|
|
78
81
|
break;
|
|
79
|
-
case "--id":
|
|
82
|
+
case "--id":
|
|
80
83
|
callParams.id = args[++i];
|
|
81
84
|
break;
|
|
82
85
|
case "--resourceid":
|
|
@@ -117,7 +120,7 @@ async function get(action, args) {
|
|
|
117
120
|
case "--latestconfiguration":
|
|
118
121
|
callParams.latestConfiguration = args[++i] == "true" ? true : undefined;
|
|
119
122
|
break;
|
|
120
|
-
|
|
123
|
+
}
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
const client = await getOpsCompassClient();
|
|
@@ -238,8 +241,8 @@ async function tags(action, args) {
|
|
|
238
241
|
case "--company":
|
|
239
242
|
callData.company = args[++i];
|
|
240
243
|
break;
|
|
241
|
-
case "--id":
|
|
242
|
-
|
|
244
|
+
case "--id":
|
|
245
|
+
callData.id = args[++i];
|
|
243
246
|
break;
|
|
244
247
|
case "--resourceid":
|
|
245
248
|
case "--resource-id":
|
|
@@ -252,7 +255,7 @@ async function tags(action, args) {
|
|
|
252
255
|
callData.tags = [args[++i]];
|
|
253
256
|
}
|
|
254
257
|
break;
|
|
255
|
-
|
|
258
|
+
}
|
|
256
259
|
}
|
|
257
260
|
|
|
258
261
|
const client = await getOpsCompassClient();
|
|
@@ -263,10 +266,15 @@ async function tags(action, args) {
|
|
|
263
266
|
async function getUsageAnalytics(args) {
|
|
264
267
|
let resourceId = undefined;
|
|
265
268
|
let metricType = undefined;
|
|
266
|
-
let optionalParams = {
|
|
269
|
+
let optionalParams = {
|
|
270
|
+
analysisType: undefined,
|
|
271
|
+
groupingPeriod: undefined,
|
|
272
|
+
calculatedAtFrom: undefined,
|
|
273
|
+
calculatedAtTo: undefined,
|
|
274
|
+
};
|
|
267
275
|
for (let i = 0; i < args.length - 1; i++) {
|
|
268
276
|
switch (args[i].toLowerCase()) {
|
|
269
|
-
case "--id":
|
|
277
|
+
case "--id":
|
|
270
278
|
resourceId = args[++i];
|
|
271
279
|
break;
|
|
272
280
|
case "--metric-type":
|
|
@@ -293,18 +301,21 @@ async function getUsageAnalytics(args) {
|
|
|
293
301
|
}
|
|
294
302
|
|
|
295
303
|
const client = await getOpsCompassClient();
|
|
296
|
-
const usageAnalytics = await client.resources.getUsageAnalytics(
|
|
304
|
+
const usageAnalytics = await client.resources.getUsageAnalytics(
|
|
305
|
+
resourceId,
|
|
306
|
+
metricType,
|
|
307
|
+
optionalParams,
|
|
308
|
+
);
|
|
297
309
|
|
|
298
310
|
console.log(JSON.stringify(usageAnalytics, null, 2));
|
|
299
311
|
}
|
|
300
312
|
|
|
301
313
|
async function getMetricNamesForResourceType(args) {
|
|
302
|
-
let company = undefined;
|
|
303
314
|
let resourceType = undefined;
|
|
304
315
|
for (let i = 0; i < args.length - 1; i++) {
|
|
305
316
|
switch (args[i].toLowerCase()) {
|
|
306
|
-
case "--company":
|
|
307
|
-
company = args[++i];
|
|
317
|
+
case "--company":
|
|
318
|
+
global.company = args[++i];
|
|
308
319
|
break;
|
|
309
320
|
case "--resource-type":
|
|
310
321
|
case "--resourcetype":
|
|
@@ -314,7 +325,10 @@ async function getMetricNamesForResourceType(args) {
|
|
|
314
325
|
}
|
|
315
326
|
|
|
316
327
|
const client = await getOpsCompassClient();
|
|
317
|
-
const usageAnalytics = await client.resources.getMetricNamesForResourceType(
|
|
328
|
+
const usageAnalytics = await client.resources.getMetricNamesForResourceType(
|
|
329
|
+
global.company,
|
|
330
|
+
resourceType,
|
|
331
|
+
);
|
|
318
332
|
|
|
319
333
|
console.log(JSON.stringify(usageAnalytics, null, 2));
|
|
320
334
|
}
|
|
@@ -323,7 +337,7 @@ async function getMetricNames(args) {
|
|
|
323
337
|
const callParams = {};
|
|
324
338
|
for (let i = 0; i < args.length - 1; i++) {
|
|
325
339
|
switch (args[i].toLowerCase()) {
|
|
326
|
-
case "--company":
|
|
340
|
+
case "--company":
|
|
327
341
|
callParams.company = args[++i];
|
|
328
342
|
break;
|
|
329
343
|
case "--resource-id":
|
|
@@ -333,11 +347,12 @@ async function getMetricNames(args) {
|
|
|
333
347
|
case "--id":
|
|
334
348
|
callParams.id = args[++i];
|
|
335
349
|
break;
|
|
336
|
-
|
|
350
|
+
}
|
|
337
351
|
}
|
|
338
352
|
|
|
339
353
|
const client = await getOpsCompassClient();
|
|
340
|
-
const metricNames =
|
|
354
|
+
const metricNames =
|
|
355
|
+
await client.resources.getMetricNamesForResource(callParams);
|
|
341
356
|
|
|
342
357
|
console.log(JSON.stringify(metricNames, null, 2));
|
|
343
358
|
}
|
|
@@ -359,7 +374,7 @@ async function uploadMetrics(args) {
|
|
|
359
374
|
case "--metrics":
|
|
360
375
|
callData.metrics = await parseMetrics(args[++i]);
|
|
361
376
|
break;
|
|
362
|
-
|
|
377
|
+
}
|
|
363
378
|
}
|
|
364
379
|
|
|
365
380
|
const client = await getOpsCompassClient();
|
|
@@ -381,11 +396,12 @@ async function getLatestConfiguration(args) {
|
|
|
381
396
|
case "--resource-id":
|
|
382
397
|
callData.resourceId = args[++i];
|
|
383
398
|
break;
|
|
384
|
-
|
|
399
|
+
}
|
|
385
400
|
}
|
|
386
401
|
|
|
387
402
|
const client = await getOpsCompassClient();
|
|
388
|
-
const latestConfiguration =
|
|
403
|
+
const latestConfiguration =
|
|
404
|
+
await client.resources.getLatestConfiguration(callData);
|
|
389
405
|
console.log(JSON.stringify(latestConfiguration, null, 2));
|
|
390
406
|
}
|
|
391
407
|
|
|
@@ -416,11 +432,12 @@ async function getMetricCheckResults(args) {
|
|
|
416
432
|
case "--resource-id":
|
|
417
433
|
callParams.resourceId = args[++i];
|
|
418
434
|
break;
|
|
419
|
-
|
|
435
|
+
}
|
|
420
436
|
}
|
|
421
437
|
|
|
422
438
|
const client = await getOpsCompassClient();
|
|
423
|
-
const metricCheckResults =
|
|
439
|
+
const metricCheckResults =
|
|
440
|
+
await client.resources.getMetricCheckResults(callParams);
|
|
424
441
|
console.log(JSON.stringify(metricCheckResults, null, 2));
|
|
425
442
|
}
|
|
426
443
|
|
|
@@ -456,11 +473,14 @@ async function getAggregateMetrics(args) {
|
|
|
456
473
|
case "--calculated-at-to":
|
|
457
474
|
callParams.calculatedAtTo = args[++i];
|
|
458
475
|
break;
|
|
459
|
-
|
|
476
|
+
}
|
|
460
477
|
}
|
|
461
478
|
|
|
462
479
|
const client = await getOpsCompassClient();
|
|
463
|
-
const aggregateMetrics = await client.resources.getAggregateMetrics(
|
|
480
|
+
const aggregateMetrics = await client.resources.getAggregateMetrics(
|
|
481
|
+
callParams.granularity,
|
|
482
|
+
callParams,
|
|
483
|
+
);
|
|
464
484
|
console.log(JSON.stringify(aggregateMetrics, null, 2));
|
|
465
485
|
}
|
|
466
486
|
|
|
@@ -479,7 +499,7 @@ async function sendExternalResources(args) {
|
|
|
479
499
|
|
|
480
500
|
if (passedData.jsonFilePath) {
|
|
481
501
|
try {
|
|
482
|
-
const data = readFileSync(passedData.jsonFilePath,
|
|
502
|
+
const data = readFileSync(passedData.jsonFilePath, "utf8");
|
|
483
503
|
passedData.resourcesInfo = data;
|
|
484
504
|
} catch (error) {
|
|
485
505
|
console.error("Error reading JSON file:", error.message);
|
|
@@ -488,19 +508,25 @@ async function sendExternalResources(args) {
|
|
|
488
508
|
}
|
|
489
509
|
let callData = {};
|
|
490
510
|
if (!passedData.resourcesInfo) {
|
|
491
|
-
console.error(
|
|
511
|
+
console.error(
|
|
512
|
+
"You must provide --resources-info with a stringified JSON object of resource info or --json-file-path.",
|
|
513
|
+
);
|
|
492
514
|
return;
|
|
493
515
|
} else {
|
|
494
516
|
try {
|
|
495
517
|
callData = JSON.parse(passedData.resourcesInfo);
|
|
496
518
|
} catch (error) {
|
|
497
|
-
console.error(
|
|
519
|
+
console.error(
|
|
520
|
+
"Invalid JSON provided for --resources-info:",
|
|
521
|
+
error.message,
|
|
522
|
+
);
|
|
498
523
|
return;
|
|
499
524
|
}
|
|
500
525
|
}
|
|
501
526
|
|
|
502
527
|
const client = await getOpsCompassClient();
|
|
503
|
-
const sendResponse =
|
|
528
|
+
const sendResponse =
|
|
529
|
+
await client.resources[actionMap["send-external-resources"]](callData);
|
|
504
530
|
console.log(JSON.stringify(sendResponse, null, 2));
|
|
505
531
|
}
|
|
506
532
|
|
|
@@ -514,7 +540,10 @@ async function printHelp() {
|
|
|
514
540
|
console.log("--resource-id [cloud-resource-id]");
|
|
515
541
|
console.log("--latest-configuration (optional) [boolean]");
|
|
516
542
|
console.log();
|
|
517
|
-
console.log(
|
|
543
|
+
console.log(
|
|
544
|
+
"get-compliance",
|
|
545
|
+
"Gets compliance check details for a resource.",
|
|
546
|
+
);
|
|
518
547
|
console.log("Parameters:");
|
|
519
548
|
console.log("--company [company_id]");
|
|
520
549
|
console.log("--id [12345]");
|
|
@@ -527,7 +556,7 @@ async function printHelp() {
|
|
|
527
556
|
console.log("--id [12345]");
|
|
528
557
|
console.log("--resource-id [cloud-resource-id]");
|
|
529
558
|
console.log("--status [new | inprogress | acknowledged | resolved]");
|
|
530
|
-
console.log(
|
|
559
|
+
console.log('--concern "concern name"');
|
|
531
560
|
console.log("--type [configuration_alert | security_alert]");
|
|
532
561
|
console.log();
|
|
533
562
|
console.log("get-metric-names", "Fetches metric names for a resource.");
|
|
@@ -542,7 +571,10 @@ async function printHelp() {
|
|
|
542
571
|
console.log("--id [12345]");
|
|
543
572
|
console.log("--resource-id [cloud-resource-id]");
|
|
544
573
|
console.log();
|
|
545
|
-
console.log(
|
|
574
|
+
console.log(
|
|
575
|
+
"list",
|
|
576
|
+
"Lists a set of resources that match any given criteria.",
|
|
577
|
+
);
|
|
546
578
|
console.log("Parameters:");
|
|
547
579
|
console.log("--company [company_id]");
|
|
548
580
|
console.log("--accounts [account_id]");
|
|
@@ -551,9 +583,9 @@ async function printHelp() {
|
|
|
551
583
|
console.log("--cloud-providers [aws | azure | gcp | microsoft365]");
|
|
552
584
|
console.log("--resource-types [resource-type-name]");
|
|
553
585
|
console.log("--region-ids [region-id]");
|
|
554
|
-
console.log("--tags [tag-value]")
|
|
555
|
-
console.log(
|
|
556
|
-
console.log(
|
|
586
|
+
console.log("--tags [tag-value]");
|
|
587
|
+
console.log('--resource-creation-date-beginning ["2020-11-11 00:00:00.000"]');
|
|
588
|
+
console.log('--resource-creation-date-end ["2021-11-11 00:00:00.000"]');
|
|
557
589
|
console.log("--open-compliance-issues [true | false]");
|
|
558
590
|
console.log("--unacknowledged-changes [true | false]");
|
|
559
591
|
console.log("--skip [12345]");
|
|
@@ -572,7 +604,10 @@ async function printHelp() {
|
|
|
572
604
|
console.log("--resource-id [cloud-resource-id]");
|
|
573
605
|
console.log("--tag [tag-value]");
|
|
574
606
|
console.log();
|
|
575
|
-
console.log(
|
|
607
|
+
console.log(
|
|
608
|
+
"get-usage-analytics",
|
|
609
|
+
"Calculates the resource usage analytics for given criteria.",
|
|
610
|
+
);
|
|
576
611
|
console.log("Parameters:");
|
|
577
612
|
console.log("--id [resource_id]");
|
|
578
613
|
console.log("--metric-type [string]");
|
|
@@ -581,7 +616,10 @@ async function printHelp() {
|
|
|
581
616
|
console.log("--calculated-at-from (optional) [2021-09-01T00:00:00.000Z]");
|
|
582
617
|
console.log("--calculated-at-to (optional) [2023-10-01T00:00:00.000Z]");
|
|
583
618
|
console.log();
|
|
584
|
-
console.log(
|
|
619
|
+
console.log(
|
|
620
|
+
"get-metric-names-for-resource-type",
|
|
621
|
+
"Fetches metric names for provided resource type.",
|
|
622
|
+
);
|
|
585
623
|
console.log("Parameters:");
|
|
586
624
|
console.log("--company [company slug]");
|
|
587
625
|
console.log("--resource-type [string]");
|
|
@@ -593,51 +631,82 @@ async function printHelp() {
|
|
|
593
631
|
console.log("--resource-id [cloud-resource-id]");
|
|
594
632
|
console.log("--metrics [path to metrics file]");
|
|
595
633
|
console.log();
|
|
596
|
-
console.log(
|
|
634
|
+
console.log(
|
|
635
|
+
"scan",
|
|
636
|
+
"(beta)",
|
|
637
|
+
"Queues the requested resources / account for scanning. Currently only accessible through beta.",
|
|
638
|
+
);
|
|
597
639
|
console.log("Parameters:");
|
|
598
640
|
console.log("--company [company slug]");
|
|
599
641
|
console.log("--account [account_id]");
|
|
600
|
-
console.log(
|
|
601
|
-
|
|
602
|
-
|
|
642
|
+
console.log(
|
|
643
|
+
"--ids (optional) [resource numeric id] Example: --ids 12345,56854,104455",
|
|
644
|
+
);
|
|
645
|
+
console.log(
|
|
646
|
+
"--resourceIds (optional) [resource cloud id] Example: --resourceIds arn:aws:ec2:us-east-1:444855252760:customer-gateway/1234",
|
|
647
|
+
);
|
|
648
|
+
console.log("--resourceTags (optional) [tag-value] ");
|
|
603
649
|
console.log();
|
|
604
|
-
console.log(
|
|
650
|
+
console.log(
|
|
651
|
+
"get-latest-configuration",
|
|
652
|
+
"Gets the latest configuration for a resource.",
|
|
653
|
+
);
|
|
605
654
|
console.log("Parameters:");
|
|
606
655
|
console.log("--company [company_id]");
|
|
607
656
|
console.log("--id [resource id]");
|
|
608
657
|
console.log("--resource-id [cloud-resource-id]");
|
|
609
658
|
console.log();
|
|
610
|
-
console.log(
|
|
659
|
+
console.log(
|
|
660
|
+
"get-overprovisioned",
|
|
661
|
+
"Gets resources that have been marked as being overprovisioned.",
|
|
662
|
+
);
|
|
611
663
|
console.log("Parameters:");
|
|
612
664
|
console.log("--company [company_id]");
|
|
613
665
|
console.log();
|
|
614
|
-
console.log(
|
|
666
|
+
console.log(
|
|
667
|
+
"get-metric-check-results",
|
|
668
|
+
"Gets the metric check results for a resource.",
|
|
669
|
+
);
|
|
615
670
|
console.log("Parameters:");
|
|
616
671
|
console.log("--company [company_id]");
|
|
617
672
|
console.log("--id [resource id]");
|
|
618
673
|
console.log("--resource-id [cloud-resource-id]");
|
|
619
674
|
console.log();
|
|
620
|
-
console.log(
|
|
675
|
+
console.log(
|
|
676
|
+
"get-aggregate-metrics",
|
|
677
|
+
"Gets the aggregate metrics for a resource.",
|
|
678
|
+
);
|
|
621
679
|
console.log("Parameters:");
|
|
622
680
|
console.log("--granularity ['Day' or 'Hour']");
|
|
623
681
|
console.log("--metric-check-result-id (optional) [metric check result id]");
|
|
624
|
-
console.log(
|
|
625
|
-
|
|
682
|
+
console.log(
|
|
683
|
+
"--offset (optional) [number] assists in pagination of records, default is 0",
|
|
684
|
+
);
|
|
685
|
+
console.log(
|
|
686
|
+
"--limit (optional) [number] assists in pagination of records, default is 100, max is 250",
|
|
687
|
+
);
|
|
626
688
|
console.log("--resource-id (optional) [database resource id]");
|
|
627
689
|
console.log("--metric-type (optional) [string]");
|
|
628
690
|
console.log("--calculated-at-from (optional) [timestamp]");
|
|
629
691
|
console.log("--calculated-at-to (optional) [timestamp]");
|
|
630
692
|
console.log();
|
|
631
|
-
console.log(
|
|
693
|
+
console.log(
|
|
694
|
+
"send-external-resources",
|
|
695
|
+
"Sends external resources to Opscompass to be scanned. Only 500 resources can be sent at a time.",
|
|
696
|
+
);
|
|
632
697
|
console.log("Parameters:");
|
|
633
|
-
console.log(
|
|
634
|
-
|
|
698
|
+
console.log(
|
|
699
|
+
"--resources-info (optional) [Stringified JSON of resource info]",
|
|
700
|
+
);
|
|
701
|
+
console.log(
|
|
702
|
+
"--json-file-path (optional) [Path to JSON file containing resource info]",
|
|
703
|
+
);
|
|
635
704
|
console.log();
|
|
636
705
|
}
|
|
637
706
|
|
|
638
707
|
const resourcesModule = (action, ...args) => {
|
|
639
708
|
switch (action?.toLowerCase() ?? "") {
|
|
640
|
-
case "scan":
|
|
709
|
+
case "scan":
|
|
641
710
|
return scan(args);
|
|
642
711
|
case "get":
|
|
643
712
|
case "get-compliance":
|
|
@@ -650,7 +719,7 @@ const resourcesModule = (action, ...args) => {
|
|
|
650
719
|
case "remove-tags":
|
|
651
720
|
return tags(action, args);
|
|
652
721
|
case "list":
|
|
653
|
-
return list(args)
|
|
722
|
+
return list(args);
|
|
654
723
|
case "get-usage-analytics":
|
|
655
724
|
return getUsageAnalytics(args);
|
|
656
725
|
case "get-metric-names-for-resource-type":
|
|
@@ -677,6 +746,7 @@ const resourcesModule = (action, ...args) => {
|
|
|
677
746
|
};
|
|
678
747
|
|
|
679
748
|
resourcesModule.requiresLogin = true;
|
|
680
|
-
resourcesModule.description =
|
|
749
|
+
resourcesModule.description =
|
|
750
|
+
"Provides access to details about Resources in OpsCompass.";
|
|
681
751
|
|
|
682
|
-
|
|
752
|
+
export default resourcesModule;
|
package/modules.js
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import resources from "./modules/resources.js";
|
|
2
|
+
import accounts from "./modules/accounts.js";
|
|
3
|
+
import licenseManager from "./modules/license-manager.js";
|
|
4
|
+
import compliance from "./modules/compliance.js";
|
|
5
|
+
import expirationInfo from "./modules/expiration-info.js";
|
|
6
|
+
import defaults from "./modules/defaults.js";
|
|
7
7
|
|
|
8
8
|
// Dynaimcally loaded modules - may be optional
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
15
|
+
|
|
16
|
+
let dataGatheringScripts;
|
|
17
|
+
try {
|
|
18
|
+
if (
|
|
19
|
+
fs.existsSync(path.join(__dirname, "modules/data-gathering-scripts.js"))
|
|
20
|
+
) {
|
|
21
|
+
const module = await import("./modules/data-gathering-scripts.js");
|
|
22
|
+
dataGatheringScripts = module.default;
|
|
23
|
+
} else {
|
|
24
|
+
dataGatheringScripts = {
|
|
16
25
|
requiresLogin: false,
|
|
17
26
|
description: "removed for security",
|
|
18
27
|
};
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
dataGatheringScripts = {
|
|
31
|
+
requiresLogin: false,
|
|
32
|
+
description: "removed for security",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
19
35
|
|
|
20
36
|
/* login acts like a module, even though it's special */
|
|
21
|
-
|
|
37
|
+
import login from "./login.js";
|
|
22
38
|
|
|
23
|
-
|
|
39
|
+
export default {
|
|
24
40
|
login,
|
|
25
41
|
resources,
|
|
26
42
|
accounts,
|
package/oauth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { oAuthClient } from "./environment/current.js";
|
|
2
2
|
|
|
3
3
|
function redeemDeviceCode(deviceCode) {
|
|
4
4
|
return oAuthClient.redeemDeviceCode(deviceCode);
|
|
@@ -20,7 +20,7 @@ function redeemRefreshToken(refreshToken) {
|
|
|
20
20
|
return oAuthClient.redeemRefreshToken(refreshToken);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
export {
|
|
24
24
|
redeemDeviceCode,
|
|
25
25
|
getDeviceCode,
|
|
26
26
|
generateAuthorizeUrl,
|
package/opscompass.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { OpsCompassClient } from "./environment/current.js";
|
|
2
|
+
import { getCredentials } from "./credentials.js";
|
|
3
|
+
import { utilsModule as utils } from "./lib/utils.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This module provides a functions to use the OpsCompass API client
|
|
@@ -17,9 +17,8 @@ async function getOpsCompassClient() {
|
|
|
17
17
|
return new OpsCompassClient(access_token);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
20
|
+
export { getOpsCompassClient };
|
|
21
|
+
|
|
22
|
+
export const getConfigFilePath = utils.getConfigFilePath;
|
|
23
|
+
export const readConfigFile = utils.readConfigFile;
|
|
24
|
+
export const writeConfigFile = utils.writeConfigFile;
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"author": "opscompass",
|
|
17
18
|
"license": "SEE LICENSE IN license.txt",
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@opscompass/opscompass-api": "^1.
|
|
20
|
+
"@opscompass/opscompass-api": "^1.3.1",
|
|
20
21
|
"adm-zip": "^0.5.16",
|
|
21
22
|
"axios": "^0.28.1",
|
|
22
23
|
"better-sqlite3": "^11.8.0",
|
package/updates.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import pkg from "./package.json" with { type: "json" };
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import { exec } from "child_process";
|
|
4
|
+
import { yellowText, redText } from "./colors.js";
|
|
5
|
+
import { opscompassHome } from "./environment/current.js";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
8
|
|
|
9
9
|
/* versionCheck sends a command to the terminal to check the latest package version and compares it to the current version specified in package.json, prompting the user to upgrade if it is out of date. */
|
|
10
10
|
/* This is turned off by default when using the local environment. To turn it on for dev purposes, comment out isLocal check in index.js */
|
|
@@ -73,11 +73,9 @@ function versionCheck() {
|
|
|
73
73
|
// Ignore errors when writing the version file
|
|
74
74
|
}
|
|
75
75
|
resolve(result);
|
|
76
|
-
}
|
|
76
|
+
},
|
|
77
77
|
);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
versionCheck,
|
|
83
|
-
};
|
|
81
|
+
export { versionCheck };
|