@datadog/datadog-ci 0.17.9 → 0.17.13

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.
Files changed (81) hide show
  1. package/LICENSE-3rdparty.csv +2 -0
  2. package/README.md +9 -2
  3. package/dist/{commands/dependencies/index.d.ts → cli.d.ts} +0 -0
  4. package/dist/cli.js +34 -0
  5. package/dist/commands/{dsyms/index.d.ts → dependencies/cli.d.ts} +0 -0
  6. package/dist/commands/dependencies/{index.js → cli.js} +0 -0
  7. package/dist/commands/dependencies/upload.d.ts +1 -1
  8. package/dist/commands/{git-metadata/index.d.ts → dsyms/cli.d.ts} +0 -0
  9. package/dist/commands/dsyms/{index.js → cli.js} +0 -0
  10. package/dist/commands/dsyms/upload.d.ts +1 -1
  11. package/dist/commands/{junit/index.d.ts → git-metadata/cli.d.ts} +0 -0
  12. package/dist/commands/git-metadata/{index.js → cli.js} +0 -0
  13. package/dist/commands/git-metadata/upload.d.ts +1 -1
  14. package/dist/commands/git-metadata/upload.js +6 -1
  15. package/dist/commands/{lambda/index.d.ts → junit/cli.d.ts} +0 -0
  16. package/dist/commands/junit/{index.js → cli.js} +0 -0
  17. package/dist/commands/junit/upload.d.ts +1 -1
  18. package/dist/commands/junit/upload.js +1 -1
  19. package/dist/commands/lambda/__tests__/fixtures.d.ts +5 -1
  20. package/dist/commands/lambda/__tests__/fixtures.js +13 -2
  21. package/dist/commands/lambda/__tests__/functions/commons.test.js +400 -0
  22. package/dist/commands/lambda/__tests__/functions/instrument.test.js +229 -117
  23. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +80 -7
  24. package/dist/commands/lambda/__tests__/instrument.test.js +542 -111
  25. package/dist/commands/{sourcemaps/index.d.ts → lambda/__tests__/prompt.test.d.ts} +0 -0
  26. package/dist/commands/lambda/__tests__/prompt.test.js +216 -0
  27. package/dist/commands/lambda/__tests__/uninstrument.test.js +381 -17
  28. package/dist/commands/{trace/index.d.ts → lambda/cli.d.ts} +0 -0
  29. package/dist/commands/lambda/{index.js → cli.js} +0 -0
  30. package/dist/commands/lambda/constants.d.ts +27 -6
  31. package/dist/commands/lambda/constants.js +63 -6
  32. package/dist/commands/lambda/functions/commons.d.ts +49 -4
  33. package/dist/commands/lambda/functions/commons.js +198 -7
  34. package/dist/commands/lambda/functions/instrument.d.ts +5 -14
  35. package/dist/commands/lambda/functions/instrument.js +63 -80
  36. package/dist/commands/lambda/functions/uninstrument.d.ts +3 -2
  37. package/dist/commands/lambda/functions/uninstrument.js +23 -11
  38. package/dist/commands/lambda/instrument.d.ts +2 -1
  39. package/dist/commands/lambda/instrument.js +112 -58
  40. package/dist/commands/lambda/interfaces.d.ts +4 -1
  41. package/dist/commands/lambda/loggroup.js +3 -1
  42. package/dist/commands/lambda/prompt.d.ts +9 -0
  43. package/dist/commands/lambda/prompt.js +187 -0
  44. package/dist/commands/lambda/uninstrument.d.ts +2 -0
  45. package/dist/commands/lambda/uninstrument.js +107 -30
  46. package/dist/commands/sourcemaps/cli.d.ts +1 -0
  47. package/dist/commands/sourcemaps/{index.js → cli.js} +0 -0
  48. package/dist/commands/sourcemaps/upload.d.ts +1 -1
  49. package/dist/commands/synthetics/__tests__/cli.test.js +36 -13
  50. package/dist/commands/synthetics/__tests__/fixtures.js +1 -0
  51. package/dist/commands/synthetics/__tests__/run-test.test.js +48 -2
  52. package/dist/commands/synthetics/__tests__/utils.test.js +11 -4
  53. package/dist/commands/synthetics/__tests__/websocket.test.js +3 -3
  54. package/dist/commands/synthetics/cli.d.ts +1 -26
  55. package/dist/commands/synthetics/cli.js +2 -227
  56. package/dist/commands/synthetics/command.d.ts +27 -0
  57. package/dist/commands/synthetics/command.js +236 -0
  58. package/dist/commands/synthetics/index.d.ts +5 -1
  59. package/dist/commands/synthetics/index.js +31 -2
  60. package/dist/commands/synthetics/interfaces.d.ts +8 -3
  61. package/dist/commands/synthetics/interfaces.js +7 -3
  62. package/dist/commands/synthetics/reporters/default.js +5 -1
  63. package/dist/commands/synthetics/run-test.js +3 -1
  64. package/dist/commands/synthetics/utils.d.ts +3 -3
  65. package/dist/commands/synthetics/utils.js +17 -8
  66. package/dist/commands/trace/api.js +1 -1
  67. package/dist/commands/trace/cli.d.ts +1 -0
  68. package/dist/commands/trace/{index.js → cli.js} +0 -0
  69. package/dist/commands/trace/trace.d.ts +1 -1
  70. package/dist/helpers/__tests__/ci.test.js +97 -136
  71. package/dist/helpers/__tests__/user-provided-git.test.js +81 -27
  72. package/dist/helpers/__tests__/utils.test.js +4 -0
  73. package/dist/helpers/ci.js +54 -95
  74. package/dist/helpers/interfaces.d.ts +28 -2
  75. package/dist/helpers/user-provided-git.d.ts +2 -1
  76. package/dist/helpers/user-provided-git.js +29 -5
  77. package/dist/helpers/utils.d.ts +4 -0
  78. package/dist/helpers/utils.js +18 -1
  79. package/dist/index.d.ts +3 -1
  80. package/dist/index.js +23 -31
  81. package/package.json +10 -8
@@ -49,6 +49,7 @@ describe('uninstrument', () => {
49
49
  'arn:aws:lambda:us-east-1:000000000000:function:uninstrument': {
50
50
  Environment: {
51
51
  Variables: {
52
+ [constants_1.API_KEY_SECRET_ARN_ENV_VAR]: 'some-secret:arn:from:aws',
52
53
  [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
53
54
  [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
54
55
  [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
@@ -146,7 +147,7 @@ describe('uninstrument', () => {
146
147
  `);
147
148
  }));
148
149
  });
149
- describe('getFunctionConfigs', () => {
150
+ describe('getUninstrumentedFunctionConfigs', () => {
150
151
  const OLD_ENV = process.env;
151
152
  beforeEach(() => {
152
153
  jest.resetModules();
@@ -178,7 +179,7 @@ describe('uninstrument', () => {
178
179
  },
179
180
  });
180
181
  const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
181
- const result = yield uninstrument_1.getFunctionConfigs(lambda, cloudWatch, ['arn:aws:lambda:us-east-1:000000000000:function:uninstrument'], undefined);
182
+ const result = yield uninstrument_1.getUninstrumentedFunctionConfigs(lambda, cloudWatch, ['arn:aws:lambda:us-east-1:000000000000:function:uninstrument'], undefined);
182
183
  expect(result.length).toEqual(1);
183
184
  expect(result[0].updateRequest).toMatchInlineSnapshot(`
184
185
  Object {
@@ -218,7 +219,7 @@ describe('uninstrument', () => {
218
219
  },
219
220
  });
220
221
  const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
221
- const result = yield uninstrument_1.getFunctionConfigs(lambda, cloudWatch, [
222
+ const result = yield uninstrument_1.getUninstrumentedFunctionConfigs(lambda, cloudWatch, [
222
223
  'arn:aws:lambda:us-east-1:000000000000:function:another-func',
223
224
  'arn:aws:lambda:us-east-1:000000000000:function:uninstrument',
224
225
  ], undefined);
@@ -235,7 +236,7 @@ describe('uninstrument', () => {
235
236
  `);
236
237
  }));
237
238
  });
238
- describe('getFunctionConfig', () => {
239
+ describe('getUninstrumentedFunctionConfig', () => {
239
240
  const OLD_ENV = process.env;
240
241
  beforeEach(() => {
241
242
  jest.resetModules();
@@ -253,7 +254,7 @@ describe('uninstrument', () => {
253
254
  });
254
255
  const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
255
256
  const config = yield commons_1.getLambdaFunctionConfig(lambda, 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument');
256
- yield expect(uninstrument_1.getFunctionConfig(lambda, cloudWatch, config, undefined)).rejects.toThrow();
257
+ yield expect(uninstrument_1.getUninstrumentedFunctionConfig(lambda, cloudWatch, config, undefined)).rejects.toThrow();
257
258
  }));
258
259
  test('returns configurations without updateRequest when no changes need to be made', () => __awaiter(void 0, void 0, void 0, function* () {
259
260
  const lambda = fixtures_1.makeMockLambda({
@@ -268,7 +269,7 @@ describe('uninstrument', () => {
268
269
  });
269
270
  const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
270
271
  const config = yield commons_1.getLambdaFunctionConfig(lambda, 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument');
271
- expect((yield uninstrument_1.getFunctionConfig(lambda, cloudWatch, config, undefined)).updateRequest).toBeUndefined();
272
+ expect((yield uninstrument_1.getUninstrumentedFunctionConfig(lambda, cloudWatch, config, undefined)).updateRequest).toBeUndefined();
272
273
  }));
273
274
  test('returns log group configuration subscription delete request when forwarderARN is set', () => __awaiter(void 0, void 0, void 0, function* () {
274
275
  const logGroupName = '/aws/lambda/group';
@@ -285,7 +286,7 @@ describe('uninstrument', () => {
285
286
  });
286
287
  const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
287
288
  const config = yield commons_1.getLambdaFunctionConfig(lambda, 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument');
288
- const result = yield uninstrument_1.getFunctionConfig(lambda, cloudWatch, config, 'valid-forwarder-arn');
289
+ const result = yield uninstrument_1.getUninstrumentedFunctionConfig(lambda, cloudWatch, config, 'valid-forwarder-arn');
289
290
  expect(result).toBeDefined();
290
291
  expect(result.logGroupConfiguration).toMatchInlineSnapshot(`
291
292
  Object {
@@ -295,4 +296,76 @@ describe('uninstrument', () => {
295
296
  `);
296
297
  }));
297
298
  });
299
+ describe('getUninstrumentedFunctionConfigsFromRegEx', () => {
300
+ const OLD_ENV = process.env;
301
+ beforeEach(() => {
302
+ jest.resetModules();
303
+ process.env = {};
304
+ });
305
+ afterAll(() => {
306
+ process.env = OLD_ENV;
307
+ });
308
+ test('returns the update request for each function that matches the pattern', () => __awaiter(void 0, void 0, void 0, function* () {
309
+ const lambda = fixtures_1.makeMockLambda({
310
+ 'autoinstrument-scooby': {
311
+ Environment: {
312
+ Variables: {
313
+ [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
314
+ [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
315
+ [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'index.handler',
316
+ [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
317
+ [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
318
+ [constants_1.SERVICE_ENV_VAR]: 'middletier',
319
+ [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
320
+ [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
321
+ [constants_1.VERSION_ENV_VAR]: '0.2',
322
+ USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
323
+ },
324
+ },
325
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument-scooby',
326
+ FunctionName: 'autoinstrument-scooby',
327
+ Handler: '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler',
328
+ Runtime: 'nodejs12.x',
329
+ },
330
+ 'autoinstrument-scrapy': {
331
+ Environment: {
332
+ Variables: {
333
+ [constants_1.API_KEY_ENV_VAR]: '1234',
334
+ [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
335
+ [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
336
+ [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'index.handler',
337
+ [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
338
+ [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
339
+ },
340
+ },
341
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument-scrapy',
342
+ FunctionName: 'autoinstrument-scrapy',
343
+ Handler: '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler',
344
+ Runtime: 'nodejs12.x',
345
+ },
346
+ });
347
+ const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
348
+ const result = yield uninstrument_1.getUninstrumentedFunctionConfigsFromRegEx(lambda, cloudWatch, 'autoinstrument-scr.', undefined);
349
+ expect(result.length).toEqual(1);
350
+ expect(result[0].updateRequest).toMatchInlineSnapshot(`
351
+ Object {
352
+ "Environment": Object {
353
+ "Variables": Object {},
354
+ },
355
+ "FunctionName": "arn:aws:lambda:us-east-1:000000000000:function:autoinstrument-scrapy",
356
+ "Handler": "index.handler",
357
+ }
358
+ `);
359
+ }));
360
+ test('fails when retry count is exceeded', () => __awaiter(void 0, void 0, void 0, function* () {
361
+ const makeMockLambdaListFunctionsError = () => ({
362
+ listFunctions: jest.fn().mockImplementation((args) => ({
363
+ promise: () => Promise.reject(),
364
+ })),
365
+ });
366
+ const lambda = makeMockLambdaListFunctionsError();
367
+ const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
368
+ yield expect(uninstrument_1.getUninstrumentedFunctionConfigsFromRegEx(lambda, cloudWatch, 'fake-pattern', undefined)).rejects.toStrictEqual(new Error('Max retry count exceeded.'));
369
+ }));
370
+ });
298
371
  });