@datadog/datadog-ci 2.1.0 ā 2.3.0
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/README.md +6 -6
- package/dist/commands/lambda/__tests__/functions/commons.test.js +8 -21
- package/dist/commands/lambda/__tests__/functions/commons.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +71 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/instrument.test.js +165 -75
- package/dist/commands/lambda/__tests__/instrument.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/uninstrument.test.js +40 -16
- package/dist/commands/lambda/__tests__/uninstrument.test.js.map +1 -1
- package/dist/commands/lambda/constants.d.ts +3 -0
- package/dist/commands/lambda/constants.js +5 -2
- package/dist/commands/lambda/constants.js.map +1 -1
- package/dist/commands/lambda/functions/commons.d.ts +5 -3
- package/dist/commands/lambda/functions/commons.js +43 -10
- package/dist/commands/lambda/functions/commons.js.map +1 -1
- package/dist/commands/lambda/functions/uninstrument.js +10 -2
- package/dist/commands/lambda/functions/uninstrument.js.map +1 -1
- package/dist/commands/lambda/instrument.d.ts +3 -2
- package/dist/commands/lambda/instrument.js +123 -81
- package/dist/commands/lambda/instrument.js.map +1 -1
- package/dist/commands/lambda/interfaces.d.ts +1 -0
- package/dist/commands/lambda/prompt.d.ts +1 -0
- package/dist/commands/lambda/prompt.js +32 -9
- package/dist/commands/lambda/prompt.js.map +1 -1
- package/dist/commands/lambda/renderer.d.ts +366 -0
- package/dist/commands/lambda/renderer.js +450 -0
- package/dist/commands/lambda/renderer.js.map +1 -0
- package/dist/commands/lambda/uninstrument.d.ts +1 -0
- package/dist/commands/lambda/uninstrument.js +76 -30
- package/dist/commands/lambda/uninstrument.js.map +1 -1
- package/dist/commands/metric/__tests__/metric.test.js +1 -1
- package/dist/commands/metric/__tests__/metric.test.js.map +1 -1
- package/dist/commands/react-native/xcode.js +1 -1
- package/dist/commands/react-native/xcode.js.map +1 -1
- package/dist/commands/synthetics/__tests__/fixtures.d.ts +1 -1
- package/dist/commands/synthetics/__tests__/fixtures.js +3 -0
- package/dist/commands/synthetics/__tests__/fixtures.js.map +1 -1
- package/dist/commands/synthetics/__tests__/run-test.test.js +4 -4
- package/dist/commands/synthetics/__tests__/run-test.test.js.map +1 -1
- package/dist/commands/synthetics/__tests__/utils.test.js +25 -3
- package/dist/commands/synthetics/__tests__/utils.test.js.map +1 -1
- package/dist/commands/synthetics/command.js +5 -1
- package/dist/commands/synthetics/command.js.map +1 -1
- package/dist/commands/synthetics/errors.d.ts +1 -1
- package/dist/commands/synthetics/errors.js +1 -0
- package/dist/commands/synthetics/errors.js.map +1 -1
- package/dist/commands/synthetics/reporters/default.js +6 -0
- package/dist/commands/synthetics/reporters/default.js.map +1 -1
- package/dist/commands/synthetics/run-test.js +1 -1
- package/dist/commands/synthetics/run-test.js.map +1 -1
- package/dist/commands/synthetics/tunnel/crypto.d.ts +1 -1
- package/dist/commands/synthetics/tunnel/crypto.js.map +1 -1
- package/dist/commands/synthetics/tunnel/tunnel.js +1 -1
- package/dist/commands/synthetics/tunnel/tunnel.js.map +1 -1
- package/dist/commands/synthetics/utils.d.ts +4 -4
- package/dist/commands/synthetics/utils.js +8 -7
- package/dist/commands/synthetics/utils.js.map +1 -1
- package/dist/commands/tag/__tests__/tag.test.js +1 -1
- package/dist/commands/tag/__tests__/tag.test.js.map +1 -1
- package/dist/helpers/__tests__/ci.test.js +12 -1
- package/dist/helpers/__tests__/ci.test.js.map +1 -1
- package/dist/helpers/__tests__/validation.test.js +2 -0
- package/dist/helpers/__tests__/validation.test.js.map +1 -1
- package/dist/helpers/ci.js +19 -23
- package/dist/helpers/ci.js.map +1 -1
- package/dist/helpers/user-provided-git.js +1 -1
- package/dist/helpers/user-provided-git.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.js +20 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/helpers/validation.d.ts +10 -1
- package/dist/helpers/validation.js +12 -0
- package/dist/helpers/validation.js.map +1 -1
- package/package.json +7 -7
|
@@ -34,6 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
jest.mock('fs');
|
|
35
35
|
jest.mock('aws-sdk');
|
|
36
36
|
jest.mock('../prompt');
|
|
37
|
+
jest.mock('../renderer', () => require('../__mocks__/renderer'));
|
|
37
38
|
const fs = __importStar(require("fs"));
|
|
38
39
|
const path_1 = __importDefault(require("path"));
|
|
39
40
|
const aws_sdk_1 = require("aws-sdk");
|
|
@@ -89,7 +90,8 @@ describe('lambda', () => {
|
|
|
89
90
|
const output = context.stdout.toString();
|
|
90
91
|
expect(code).toBe(0);
|
|
91
92
|
expect(output).toMatchInlineSnapshot(`
|
|
92
|
-
"[
|
|
93
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
94
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
93
95
|
\n[!] Functions to be updated:
|
|
94
96
|
\t- arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\n
|
|
95
97
|
[Dry Run] Will apply the following updates:
|
|
@@ -165,7 +167,8 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
165
167
|
const output = context.stdout.toString();
|
|
166
168
|
expect(code).toBe(0);
|
|
167
169
|
expect(output).toMatchInlineSnapshot(`
|
|
168
|
-
"[
|
|
170
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
171
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
169
172
|
\n[!] Functions to be updated:
|
|
170
173
|
\t- arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\n
|
|
171
174
|
[Dry Run] Will apply the following updates:
|
|
@@ -234,7 +237,8 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
234
237
|
const output = context.stdout.toString();
|
|
235
238
|
expect(code).toBe(0);
|
|
236
239
|
expect(output).toMatchInlineSnapshot(`
|
|
237
|
-
"[
|
|
240
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
241
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
238
242
|
\n[!] Functions to be updated:
|
|
239
243
|
\t- arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\n
|
|
240
244
|
[Dry Run] Will apply the following updates:
|
|
@@ -300,7 +304,8 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
300
304
|
const output = context.stdout.toString();
|
|
301
305
|
expect(code).toBe(0);
|
|
302
306
|
expect(output).toMatchInlineSnapshot(`
|
|
303
|
-
"[
|
|
307
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
308
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
304
309
|
\n[!] Functions to be updated:
|
|
305
310
|
\t- arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\n
|
|
306
311
|
[Dry Run] Will apply the following updates:
|
|
@@ -368,7 +373,7 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
368
373
|
const output = context.stdout.toString();
|
|
369
374
|
expect(output.replace('\n', '')).toMatch(/.*Error: Couldn't get local git status.*/);
|
|
370
375
|
}));
|
|
371
|
-
test('
|
|
376
|
+
test('ensure the instrument command ran from a dirty git repo fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
372
377
|
;
|
|
373
378
|
fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
|
|
374
379
|
const lambda = fixtures_1.makeMockLambda({
|
|
@@ -379,8 +384,16 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
379
384
|
},
|
|
380
385
|
});
|
|
381
386
|
aws_sdk_1.Lambda.mockImplementation(() => lambda);
|
|
382
|
-
|
|
387
|
+
process.env.DATADOG_API_KEY = '1234';
|
|
383
388
|
const context = fixtures_1.createMockContext();
|
|
389
|
+
const instrumentCommand = instrument_1.InstrumentCommand;
|
|
390
|
+
const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
|
|
391
|
+
mockGitStatus.mockImplementation(() => ({
|
|
392
|
+
ahead: 0,
|
|
393
|
+
isClean: false,
|
|
394
|
+
}));
|
|
395
|
+
const cli = new advanced_1.Cli();
|
|
396
|
+
cli.register(instrumentCommand);
|
|
384
397
|
yield cli.run([
|
|
385
398
|
'lambda',
|
|
386
399
|
'instrument',
|
|
@@ -397,9 +410,9 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
397
410
|
'0.1',
|
|
398
411
|
], context);
|
|
399
412
|
const output = context.stdout.toString();
|
|
400
|
-
expect(output).toMatch(
|
|
413
|
+
expect(output).toMatch('Error: Local git repository is dirty');
|
|
401
414
|
}));
|
|
402
|
-
test('ensure
|
|
415
|
+
test('ensure source code integration git remotes get formatted correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
403
416
|
;
|
|
404
417
|
fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
|
|
405
418
|
const lambda = fixtures_1.makeMockLambda({
|
|
@@ -413,14 +426,17 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
413
426
|
process.env.DATADOG_API_KEY = '1234';
|
|
414
427
|
const context = fixtures_1.createMockContext();
|
|
415
428
|
const instrumentCommand = instrument_1.InstrumentCommand;
|
|
429
|
+
const instrumentCommandSpy = jest.spyOn(instrumentCommand.prototype, 'filterAndFormatGitRemote');
|
|
416
430
|
const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
|
|
417
431
|
mockGitStatus.mockImplementation(() => ({
|
|
418
432
|
ahead: 0,
|
|
419
|
-
|
|
433
|
+
hash: '1be168ff837f043bde17c0314341c84271047b31',
|
|
434
|
+
remote: 'https://github.com/datadog/test.git',
|
|
435
|
+
isClean: true,
|
|
420
436
|
}));
|
|
421
437
|
const cli = new advanced_1.Cli();
|
|
422
438
|
cli.register(instrumentCommand);
|
|
423
|
-
|
|
439
|
+
const cliInput = [
|
|
424
440
|
'lambda',
|
|
425
441
|
'instrument',
|
|
426
442
|
'--function',
|
|
@@ -434,9 +450,26 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
434
450
|
'dummy',
|
|
435
451
|
'--version',
|
|
436
452
|
'0.1',
|
|
437
|
-
]
|
|
438
|
-
|
|
439
|
-
|
|
453
|
+
];
|
|
454
|
+
yield cli.run(cliInput, context);
|
|
455
|
+
mockGitStatus.mockImplementation(() => ({
|
|
456
|
+
ahead: 0,
|
|
457
|
+
hash: '1be168ff837f043bde17c0314341c84271047b31',
|
|
458
|
+
remote: 'git@github.com:datadog/test.git',
|
|
459
|
+
isClean: true,
|
|
460
|
+
}));
|
|
461
|
+
yield cli.run(cliInput, context);
|
|
462
|
+
mockGitStatus.mockImplementation(() => ({
|
|
463
|
+
ahead: 0,
|
|
464
|
+
hash: '1be168ff837f043bde17c0314341c84271047b31',
|
|
465
|
+
remote: 'github.com/datadog/test.git',
|
|
466
|
+
isClean: true,
|
|
467
|
+
}));
|
|
468
|
+
yield cli.run(cliInput, context);
|
|
469
|
+
expect(instrumentCommandSpy).toHaveBeenCalledTimes(3);
|
|
470
|
+
expect(instrumentCommandSpy).toHaveNthReturnedWith(1, 'github.com/datadog/test.git');
|
|
471
|
+
expect(instrumentCommandSpy).toHaveNthReturnedWith(2, 'github.com/datadog/test.git');
|
|
472
|
+
expect(instrumentCommandSpy).toHaveNthReturnedWith(3, 'github.com/datadog/test.git');
|
|
440
473
|
}));
|
|
441
474
|
test('ensure source code integration flag works from a clean repo', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
442
475
|
;
|
|
@@ -456,12 +489,9 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
456
489
|
mockGitStatus.mockImplementation(() => ({
|
|
457
490
|
ahead: 0,
|
|
458
491
|
hash: '1be168ff837f043bde17c0314341c84271047b31',
|
|
492
|
+
remote: 'git.repository_url:git@github.com:datadog/test.git',
|
|
459
493
|
isClean: true,
|
|
460
494
|
}));
|
|
461
|
-
const mockUploadFunction = jest.spyOn(instrumentCommand.prototype, 'uploadGitData');
|
|
462
|
-
mockUploadFunction.mockImplementation(() => {
|
|
463
|
-
return;
|
|
464
|
-
});
|
|
465
495
|
const cli = new advanced_1.Cli();
|
|
466
496
|
cli.register(instrumentCommand);
|
|
467
497
|
yield cli.run([
|
|
@@ -481,7 +511,8 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
481
511
|
], context);
|
|
482
512
|
const output = context.stdout.toString();
|
|
483
513
|
expect(output).toMatchInlineSnapshot(`
|
|
484
|
-
"
|
|
514
|
+
"\nš¶ Instrumenting Lambda function\n
|
|
515
|
+
[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
485
516
|
\n[!] Functions to be updated:
|
|
486
517
|
\t- arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\n
|
|
487
518
|
Will apply the following updates:
|
|
@@ -496,7 +527,7 @@ UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:la
|
|
|
496
527
|
\\"DD_SITE\\": \\"datadoghq.com\\",
|
|
497
528
|
\\"DD_CAPTURE_LAMBDA_PAYLOAD\\": \\"false\\",
|
|
498
529
|
\\"DD_ENV\\": \\"dummy\\",
|
|
499
|
-
\\"DD_TAGS\\": \\"git.commit.sha:1be168ff837f043bde17c0314341c84271047b31\\",
|
|
530
|
+
\\"DD_TAGS\\": \\"git.commit.sha:1be168ff837f043bde17c0314341c84271047b31,git.repository_url:git.repository_url:github.com/datadog/test.git\\",
|
|
500
531
|
\\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
|
|
501
532
|
\\"DD_SERVICE\\": \\"dummy\\",
|
|
502
533
|
\\"DD_TRACE_ENABLED\\": \\"true\\",
|
|
@@ -552,7 +583,7 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
552
583
|
'0.1',
|
|
553
584
|
], context);
|
|
554
585
|
const output = context.stdout.toString();
|
|
555
|
-
expect(output).toMatch('Error: Local changes have not been pushed remotely. Aborting git
|
|
586
|
+
expect(output).toMatch('Error: Local changes have not been pushed remotely. Aborting git data tagging.');
|
|
556
587
|
}));
|
|
557
588
|
test('runs function update command for lambda library layer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
558
589
|
;
|
|
@@ -622,9 +653,10 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
622
653
|
const output = context.stdout.toString();
|
|
623
654
|
expect(code).toBe(1);
|
|
624
655
|
expect(output).toMatchInlineSnapshot(`
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
656
|
+
"\nš¶ Instrumenting Lambda function
|
|
657
|
+
[Error] No functions specified to instrument.
|
|
658
|
+
"
|
|
659
|
+
`);
|
|
628
660
|
}));
|
|
629
661
|
test('aborts early when no functions are specified while using config file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
630
662
|
;
|
|
@@ -640,9 +672,10 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
640
672
|
yield command['execute']();
|
|
641
673
|
const output = command.context.stdout.toString();
|
|
642
674
|
expect(output).toMatchInlineSnapshot(`
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
675
|
+
"\nš¶ Instrumenting Lambda function
|
|
676
|
+
[Error] No functions specified to instrument.
|
|
677
|
+
"
|
|
678
|
+
`);
|
|
646
679
|
}));
|
|
647
680
|
test("aborts early when function regions can't be found", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
648
681
|
;
|
|
@@ -699,9 +732,10 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
699
732
|
const output = context.stdout.toString();
|
|
700
733
|
expect(code).toBe(1);
|
|
701
734
|
expect(output).toMatchInlineSnapshot(`
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
735
|
+
"\nš¶ Instrumenting Lambda function
|
|
736
|
+
[Error] Couldn't fetch Lambda functions. Error: Can't instrument arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world, as current State is Failed (must be \\"Active\\") and Last Update Status is Unsuccessful (must be \\"Successful\\")
|
|
737
|
+
"
|
|
738
|
+
`);
|
|
705
739
|
}));
|
|
706
740
|
test('aborts early when extensionVersion and forwarder are set', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
707
741
|
;
|
|
@@ -730,9 +764,10 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
730
764
|
const output = context.stdout.toString();
|
|
731
765
|
expect(code).toBe(1);
|
|
732
766
|
expect(output).toMatchInlineSnapshot(`
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
767
|
+
"\nš¶ Instrumenting Lambda function
|
|
768
|
+
[Error] \\"extensionVersion\\" and \\"forwarder\\" should not be used at the same time.
|
|
769
|
+
"
|
|
770
|
+
`);
|
|
736
771
|
}));
|
|
737
772
|
test('check if functions are not empty while using config file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
738
773
|
;
|
|
@@ -799,8 +834,9 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
799
834
|
expect(output).toMatch(`"--functions-regex" isn't meant to be used with ARNs.\n`);
|
|
800
835
|
}));
|
|
801
836
|
test('instrument multiple functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
802
|
-
const
|
|
837
|
+
const node18LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_1.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node18-x`;
|
|
803
838
|
const node16LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_1.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node16-x`;
|
|
839
|
+
const node14LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_1.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node14-x`;
|
|
804
840
|
const node12LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_1.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node12-x`;
|
|
805
841
|
const extensionLayer = `arn:aws:lambda:sa-east-1:${constants_1.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Extension`;
|
|
806
842
|
fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
|
|
@@ -823,6 +859,12 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
823
859
|
Handler: 'index.handler',
|
|
824
860
|
Runtime: 'nodejs16.x',
|
|
825
861
|
},
|
|
862
|
+
'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-4': {
|
|
863
|
+
FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-3',
|
|
864
|
+
FunctionName: 'lambda-hello-world-4',
|
|
865
|
+
Handler: 'index.handler',
|
|
866
|
+
Runtime: 'nodejs18.x',
|
|
867
|
+
},
|
|
826
868
|
}, {
|
|
827
869
|
[`${node14LibraryLayer}:1`]: {
|
|
828
870
|
LayerVersionArn: `${node14LibraryLayer}:1`,
|
|
@@ -836,6 +878,10 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
836
878
|
LayerVersionArn: `${node16LibraryLayer}:1`,
|
|
837
879
|
Version: 1,
|
|
838
880
|
},
|
|
881
|
+
[`${node18LibraryLayer}:1`]: {
|
|
882
|
+
LayerVersionArn: `${node18LibraryLayer}:1`,
|
|
883
|
+
Version: 1,
|
|
884
|
+
},
|
|
839
885
|
[`${extensionLayer}:1`]: {
|
|
840
886
|
LayerVersionArn: `${extensionLayer}:1`,
|
|
841
887
|
Version: 1,
|
|
@@ -861,13 +907,13 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
|
|
|
861
907
|
const output = context.stdout.toString();
|
|
862
908
|
expect(code).toBe(0);
|
|
863
909
|
expect(output).toMatchInlineSnapshot(`
|
|
864
|
-
"
|
|
865
|
-
[!]
|
|
866
|
-
[!] Configure
|
|
867
|
-
|
|
868
|
-
[Warning] The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.
|
|
869
|
-
[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes
|
|
870
|
-
[!] Functions to be updated:
|
|
910
|
+
"\nš¶ Instrumenting Lambda function
|
|
911
|
+
[!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
|
|
912
|
+
\n[!] Configure AWS region.
|
|
913
|
+
\n[!] Configure Datadog settings.
|
|
914
|
+
\n[Warning] The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.
|
|
915
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
916
|
+
\n[!] Functions to be updated:
|
|
871
917
|
\t- arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
872
918
|
\t[Warning] At least one latest layer version is being used. Ensure to lock in versions for production applications using \`--layerVersion\` and \`--extensionVersion\`.
|
|
873
919
|
\t- arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2
|
|
@@ -994,12 +1040,13 @@ TagResource -> arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
|
994
1040
|
const output = context.stdout.toString();
|
|
995
1041
|
expect(code).toBe(0);
|
|
996
1042
|
expect(output).toMatchInlineSnapshot(`
|
|
997
|
-
"
|
|
998
|
-
[!]
|
|
999
|
-
[!] Configure
|
|
1000
|
-
[
|
|
1001
|
-
[Warning]
|
|
1002
|
-
[
|
|
1043
|
+
"\nš¶ Instrumenting Lambda function
|
|
1044
|
+
[!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
|
|
1045
|
+
\n[!] Configure AWS region.
|
|
1046
|
+
\n[!] Configure Datadog settings.
|
|
1047
|
+
\n[Warning] The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.
|
|
1048
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1049
|
+
\n[!] Functions to be updated:
|
|
1003
1050
|
\t- arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
1004
1051
|
\t[Warning] At least one latest layer version is being used. Ensure to lock in versions for production applications using \`--layerVersion\` and \`--extensionVersion\`.
|
|
1005
1052
|
\t- arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2
|
|
@@ -1068,7 +1115,8 @@ TagResource -> arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
|
1068
1115
|
const output = context.stdout.toString();
|
|
1069
1116
|
expect(code).toBe(1);
|
|
1070
1117
|
expect(output).toMatchInlineSnapshot(`
|
|
1071
|
-
"
|
|
1118
|
+
"\nš¶ Instrumenting Lambda function
|
|
1119
|
+
[!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
|
|
1072
1120
|
[Error] Unexpected error
|
|
1073
1121
|
"
|
|
1074
1122
|
`);
|
|
@@ -1087,8 +1135,9 @@ TagResource -> arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
|
1087
1135
|
const output = context.stdout.toString();
|
|
1088
1136
|
expect(code).toBe(1);
|
|
1089
1137
|
expect(output).toMatchInlineSnapshot(`
|
|
1090
|
-
"
|
|
1091
|
-
[!] Configure
|
|
1138
|
+
"\nš¶ Instrumenting Lambda function
|
|
1139
|
+
\n[!] Configure AWS region.
|
|
1140
|
+
\n[!] Configure Datadog settings.
|
|
1092
1141
|
[Error] Unexpected error
|
|
1093
1142
|
"
|
|
1094
1143
|
`);
|
|
@@ -1138,13 +1187,12 @@ TagResource -> arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
|
1138
1187
|
const output = context.stdout.toString();
|
|
1139
1188
|
expect(code).toBe(0);
|
|
1140
1189
|
expect(output).toMatchInlineSnapshot(`
|
|
1141
|
-
"
|
|
1142
|
-
[!]
|
|
1143
|
-
[!] Configure
|
|
1144
|
-
|
|
1145
|
-
[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1146
|
-
|
|
1147
|
-
[!] Functions to be updated:
|
|
1190
|
+
"\nš¶ Instrumenting Lambda function
|
|
1191
|
+
[!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
|
|
1192
|
+
\n[!] Configure AWS region.
|
|
1193
|
+
\n[!] Configure Datadog settings.
|
|
1194
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1195
|
+
\n[!] Functions to be updated:
|
|
1148
1196
|
\t- arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
1149
1197
|
\t[Warning] At least one latest layer version is being used. Ensure to lock in versions for production applications using \`--layerVersion\` and \`--extensionVersion\`.
|
|
1150
1198
|
|
|
@@ -1226,14 +1274,13 @@ TagResource -> arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
|
1226
1274
|
const output = context.stdout.toString();
|
|
1227
1275
|
expect(code).toBe(0);
|
|
1228
1276
|
expect(output).toMatchInlineSnapshot(`
|
|
1229
|
-
"
|
|
1230
|
-
[!]
|
|
1231
|
-
[!] Configure
|
|
1232
|
-
|
|
1233
|
-
[Warning] The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.
|
|
1234
|
-
[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1235
|
-
|
|
1236
|
-
[!] Functions to be updated:
|
|
1277
|
+
"\nš¶ Instrumenting Lambda function
|
|
1278
|
+
[!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
|
|
1279
|
+
\n[!] Configure AWS region.
|
|
1280
|
+
\n[!] Configure Datadog settings.
|
|
1281
|
+
\n[Warning] The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.
|
|
1282
|
+
\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1283
|
+
\n[!] Functions to be updated:
|
|
1237
1284
|
\t- arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
1238
1285
|
\t[Warning] At least one latest layer version is being used. Ensure to lock in versions for production applications using \`--layerVersion\` and \`--extensionVersion\`.
|
|
1239
1286
|
|
|
@@ -1283,8 +1330,8 @@ TagResource -> arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world
|
|
|
1283
1330
|
const output = context.stdout.toString();
|
|
1284
1331
|
expect(code).toBe(1);
|
|
1285
1332
|
expect(output).toMatchInlineSnapshot(`
|
|
1286
|
-
"
|
|
1287
|
-
|
|
1333
|
+
"\nš¶ Instrumenting Lambda function
|
|
1334
|
+
\n[!] Configure AWS region.
|
|
1288
1335
|
[Error] Couldn't find any Lambda functions in the specified region.
|
|
1289
1336
|
"
|
|
1290
1337
|
`);
|
|
@@ -1307,8 +1354,8 @@ Fetching Lambda functions, this might take a while.
|
|
|
1307
1354
|
const output = context.stdout.toString();
|
|
1308
1355
|
expect(code).toBe(1);
|
|
1309
1356
|
expect(output).toMatchInlineSnapshot(`
|
|
1310
|
-
"
|
|
1311
|
-
|
|
1357
|
+
"\nš¶ Instrumenting Lambda function
|
|
1358
|
+
\n[!] Configure AWS region.
|
|
1312
1359
|
[Error] Couldn't fetch Lambda functions. Error: Max retry count exceeded. ListFunctionsError
|
|
1313
1360
|
"
|
|
1314
1361
|
`);
|
|
@@ -1346,7 +1393,8 @@ Fetching Lambda functions, this might take a while.
|
|
|
1346
1393
|
const output = context.stdout.toString();
|
|
1347
1394
|
expect(code).toBe(1);
|
|
1348
1395
|
expect(output).toMatchInlineSnapshot(`
|
|
1349
|
-
"[
|
|
1396
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
1397
|
+
[Error] Couldn't fetch Lambda functions. Error: Only the --extension-version argument should be set for the ruby2.7 runtime. Please remove the --layer-version argument from the instrument command.
|
|
1350
1398
|
"
|
|
1351
1399
|
`);
|
|
1352
1400
|
}));
|
|
@@ -1383,7 +1431,8 @@ Fetching Lambda functions, this might take a while.
|
|
|
1383
1431
|
const output = context.stdout.toString();
|
|
1384
1432
|
expect(code).toBe(1);
|
|
1385
1433
|
expect(output).toMatchInlineSnapshot(`
|
|
1386
|
-
"[
|
|
1434
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
1435
|
+
[Error] Couldn't fetch Lambda functions. Error: Only the --extension-version argument should be set for the provided.al2 runtime. Please remove the --layer-version argument from the instrument command.
|
|
1387
1436
|
"
|
|
1388
1437
|
`);
|
|
1389
1438
|
}));
|
|
@@ -1421,7 +1470,48 @@ Fetching Lambda functions, this might take a while.
|
|
|
1421
1470
|
const output = context.stdout.toString();
|
|
1422
1471
|
expect(code).toBe(1);
|
|
1423
1472
|
expect(output).toMatchInlineSnapshot(`
|
|
1424
|
-
"[
|
|
1473
|
+
"\n[Dry Run] š¶ Instrumenting Lambda function
|
|
1474
|
+
[Error] Couldn't fetch Lambda functions. Error: Instrumenting arm64 architecture is not supported for the given dd-extension version. Please choose the latest dd-extension version or use x86_64 architecture.
|
|
1475
|
+
"
|
|
1476
|
+
`);
|
|
1477
|
+
}));
|
|
1478
|
+
test('instruments correctly with profile when provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1479
|
+
var _a;
|
|
1480
|
+
const credentials = {
|
|
1481
|
+
accessKeyId: fixtures_1.mockAwsAccessKeyId,
|
|
1482
|
+
getPromise: () => Promise.resolve(),
|
|
1483
|
+
needsRefresh: () => false,
|
|
1484
|
+
secretAccessKey: fixtures_1.mockAwsSecretAccessKey,
|
|
1485
|
+
};
|
|
1486
|
+
aws_sdk_1.SharedIniFileCredentials.mockImplementation(() => credentials);
|
|
1487
|
+
aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
|
|
1488
|
+
'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
|
|
1489
|
+
FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
|
|
1490
|
+
Handler: 'index.handler',
|
|
1491
|
+
Runtime: 'nodejs14.x',
|
|
1492
|
+
},
|
|
1493
|
+
}));
|
|
1494
|
+
const cli = fixtures_1.makeCli();
|
|
1495
|
+
const context = fixtures_1.createMockContext();
|
|
1496
|
+
const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
|
|
1497
|
+
const code = yield cli.run(['lambda', 'instrument', '-f', functionARN, '--profile', 'SOME-AWS-PROFILE'], context);
|
|
1498
|
+
expect(code).toBe(0);
|
|
1499
|
+
expect((_a = aws_sdk_1.config.credentials) === null || _a === void 0 ? void 0 : _a.accessKeyId).toBe(fixtures_1.mockAwsAccessKeyId);
|
|
1500
|
+
}));
|
|
1501
|
+
test('prints error when updating aws profile credentials fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1502
|
+
;
|
|
1503
|
+
aws_sdk_1.SharedIniFileCredentials.mockImplementation(() => {
|
|
1504
|
+
throw Error('Update failed!');
|
|
1505
|
+
});
|
|
1506
|
+
const cli = fixtures_1.makeCli();
|
|
1507
|
+
const context = fixtures_1.createMockContext();
|
|
1508
|
+
const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
|
|
1509
|
+
const code = yield cli.run(['lambda', 'instrument', '-f', functionARN, '--profile', 'SOME-AWS-PROFILE'], context);
|
|
1510
|
+
const output = context.stdout.toString();
|
|
1511
|
+
expect(code).toBe(1);
|
|
1512
|
+
expect(output).toMatchInlineSnapshot(`
|
|
1513
|
+
"\nš¶ Instrumenting Lambda function
|
|
1514
|
+
[Error] Error: Couldn't set AWS profile credentials. Update failed!
|
|
1425
1515
|
"
|
|
1426
1516
|
`);
|
|
1427
1517
|
}));
|
|
@@ -1554,7 +1644,7 @@ Fetching Lambda functions, this might take a while.
|
|
|
1554
1644
|
command['config'][option] = 'NotBoolean';
|
|
1555
1645
|
command['getSettings']();
|
|
1556
1646
|
let output = command.context.stdout.toString();
|
|
1557
|
-
expect(output).toMatch(`Invalid boolean specified for ${option}.\n`);
|
|
1647
|
+
expect(output).toMatch(`[Error] Invalid boolean specified for ${option}.\n`);
|
|
1558
1648
|
command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
|
|
1559
1649
|
command[option] = 'NotBoolean';
|
|
1560
1650
|
command['getSettings']();
|
|
@@ -1594,7 +1684,7 @@ Fetching Lambda functions, this might take a while.
|
|
|
1594
1684
|
command['config']['extraTags'] = 'not-complying:illegal-chars-in-key,complies:valid-pair';
|
|
1595
1685
|
command['getSettings']();
|
|
1596
1686
|
const output = command.context.stdout.toString();
|
|
1597
|
-
expect(output).toMatch('Extra tags do not comply with the <key>:<value> array.\n');
|
|
1687
|
+
expect(output).toMatch('[Error] Extra tags do not comply with the <key>:<value> array.\n');
|
|
1598
1688
|
}));
|
|
1599
1689
|
});
|
|
1600
1690
|
describe('printPlannedActions', () => {
|
|
@@ -1605,7 +1695,7 @@ Fetching Lambda functions, this might take a while.
|
|
|
1605
1695
|
const output = command.context.stdout.toString();
|
|
1606
1696
|
expect(output).toMatchInlineSnapshot(`
|
|
1607
1697
|
"
|
|
1608
|
-
No updates will be applied
|
|
1698
|
+
No updates will be applied.
|
|
1609
1699
|
"
|
|
1610
1700
|
`);
|
|
1611
1701
|
});
|
|
@@ -1626,7 +1716,7 @@ Fetching Lambda functions, this might take a while.
|
|
|
1626
1716
|
]);
|
|
1627
1717
|
const output = command.context.stdout.toString();
|
|
1628
1718
|
expect(output).toMatchInlineSnapshot(`
|
|
1629
|
-
"[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1719
|
+
"\n[Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
|
|
1630
1720
|
\n[!] Functions to be updated:
|
|
1631
1721
|
\t- my-func\n
|
|
1632
1722
|
Will apply the following updates:
|