@datadog/datadog-ci 2.40.3 → 2.41.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.
Files changed (252) hide show
  1. package/README.md +1 -0
  2. package/dist/commands/deployment/cli.js +2 -1
  3. package/dist/commands/deployment/cli.js.map +1 -1
  4. package/dist/commands/deployment/correlate.d.ts +18 -0
  5. package/dist/commands/deployment/correlate.js +154 -0
  6. package/dist/commands/deployment/correlate.js.map +1 -0
  7. package/dist/commands/dsyms/utils.js +2 -4
  8. package/dist/commands/dsyms/utils.js.map +1 -1
  9. package/dist/helpers/git/get-git-data.d.ts +2 -0
  10. package/dist/helpers/git/get-git-data.js +11 -1
  11. package/dist/helpers/git/get-git-data.js.map +1 -1
  12. package/package.json +3 -2
  13. package/dist/__tests__/cli.test.d.ts +0 -1
  14. package/dist/__tests__/cli.test.js +0 -41
  15. package/dist/__tests__/cli.test.js.map +0 -1
  16. package/dist/commands/cloud-run/__tests__/fixtures.d.ts +0 -2
  17. package/dist/commands/cloud-run/__tests__/fixtures.js +0 -12
  18. package/dist/commands/cloud-run/__tests__/fixtures.js.map +0 -1
  19. package/dist/commands/cloud-run/__tests__/flare.test.d.ts +0 -1
  20. package/dist/commands/cloud-run/__tests__/flare.test.js +0 -557
  21. package/dist/commands/cloud-run/__tests__/flare.test.js.map +0 -1
  22. package/dist/commands/deployment/__tests__/mark.test.d.ts +0 -1
  23. package/dist/commands/deployment/__tests__/mark.test.js +0 -47
  24. package/dist/commands/deployment/__tests__/mark.test.js.map +0 -1
  25. package/dist/commands/dora/__tests__/deployment.test.d.ts +0 -1
  26. package/dist/commands/dora/__tests__/deployment.test.js +0 -201
  27. package/dist/commands/dora/__tests__/deployment.test.js.map +0 -1
  28. package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
  29. package/dist/commands/dsyms/__tests__/upload.test.js +0 -346
  30. package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
  31. package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
  32. package/dist/commands/dsyms/__tests__/utils.test.js +0 -103
  33. package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
  34. package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +0 -1
  35. package/dist/commands/elf-symbols/__tests__/elf.test.js +0 -813
  36. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +0 -1
  37. package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +0 -1
  38. package/dist/commands/elf-symbols/__tests__/upload.test.js +0 -249
  39. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +0 -1
  40. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
  41. package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -617
  42. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
  43. package/dist/commands/gate/__tests__/evaluate.test.d.ts +0 -1
  44. package/dist/commands/gate/__tests__/evaluate.test.js +0 -398
  45. package/dist/commands/gate/__tests__/evaluate.test.js.map +0 -1
  46. package/dist/commands/gate/__tests__/scope.test.d.ts +0 -1
  47. package/dist/commands/gate/__tests__/scope.test.js +0 -29
  48. package/dist/commands/gate/__tests__/scope.test.js.map +0 -1
  49. package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
  50. package/dist/commands/git-metadata/__tests__/git.test.js +0 -132
  51. package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
  52. package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +0 -1
  53. package/dist/commands/git-metadata/__tests__/gitdb.test.js +0 -1386
  54. package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +0 -1
  55. package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
  56. package/dist/commands/git-metadata/__tests__/library.test.js +0 -118
  57. package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
  58. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
  59. package/dist/commands/git-metadata/__tests__/upload.test.js +0 -52
  60. package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
  61. package/dist/commands/junit/__tests__/id.test.d.ts +0 -1
  62. package/dist/commands/junit/__tests__/id.test.js +0 -24
  63. package/dist/commands/junit/__tests__/id.test.js.map +0 -1
  64. package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
  65. package/dist/commands/junit/__tests__/upload.test.js +0 -495
  66. package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
  67. package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -51
  68. package/dist/commands/lambda/__tests__/fixtures.js +0 -146
  69. package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
  70. package/dist/commands/lambda/__tests__/flare.test.d.ts +0 -1
  71. package/dist/commands/lambda/__tests__/flare.test.js +0 -730
  72. package/dist/commands/lambda/__tests__/flare.test.js.map +0 -1
  73. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
  74. package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -791
  75. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
  76. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
  77. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -386
  78. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
  79. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
  80. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -721
  81. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
  82. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
  83. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -513
  84. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
  85. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
  86. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
  87. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
  88. package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
  89. package/dist/commands/lambda/__tests__/instrument.test.js +0 -1511
  90. package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
  91. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
  92. package/dist/commands/lambda/__tests__/loggroup.test.js +0 -340
  93. package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
  94. package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
  95. package/dist/commands/lambda/__tests__/prompt.test.js +0 -206
  96. package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
  97. package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
  98. package/dist/commands/lambda/__tests__/tags.test.js +0 -305
  99. package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
  100. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
  101. package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -722
  102. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
  103. package/dist/commands/measure/__tests__/measure.test.d.ts +0 -1
  104. package/dist/commands/measure/__tests__/measure.test.js +0 -110
  105. package/dist/commands/measure/__tests__/measure.test.js.map +0 -1
  106. package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
  107. package/dist/commands/react-native/__tests__/codepush.test.js +0 -161
  108. package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
  109. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
  110. package/dist/commands/react-native/__tests__/interfaces.test.js +0 -33
  111. package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
  112. package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
  113. package/dist/commands/react-native/__tests__/upload.test.js +0 -238
  114. package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
  115. package/dist/commands/react-native/__tests__/utils.test.d.ts +0 -1
  116. package/dist/commands/react-native/__tests__/utils.test.js +0 -27
  117. package/dist/commands/react-native/__tests__/utils.test.js.map +0 -1
  118. package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
  119. package/dist/commands/react-native/__tests__/xcode.test.js +0 -465
  120. package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
  121. package/dist/commands/sarif/__tests__/upload.test.d.ts +0 -1
  122. package/dist/commands/sarif/__tests__/upload.test.js +0 -228
  123. package/dist/commands/sarif/__tests__/upload.test.js.map +0 -1
  124. package/dist/commands/sbom/__tests__/payload.test.d.ts +0 -1
  125. package/dist/commands/sbom/__tests__/payload.test.js +0 -262
  126. package/dist/commands/sbom/__tests__/payload.test.js.map +0 -1
  127. package/dist/commands/sbom/__tests__/validation.test.d.ts +0 -1
  128. package/dist/commands/sbom/__tests__/validation.test.js +0 -41
  129. package/dist/commands/sbom/__tests__/validation.test.js.map +0 -1
  130. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
  131. package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
  132. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
  133. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
  134. package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
  135. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
  136. package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +0 -1
  137. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +0 -192
  138. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +0 -1
  139. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +0 -6
  140. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +0 -45
  141. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +0 -1
  142. package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +0 -5
  143. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +0 -19
  144. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +0 -1
  145. package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +0 -1
  146. package/dist/commands/stepfunctions/__tests__/helpers.test.js +0 -205
  147. package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +0 -1
  148. package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +0 -1
  149. package/dist/commands/stepfunctions/__tests__/instrument.test.js +0 -431
  150. package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +0 -1
  151. package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +0 -1
  152. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +0 -166
  153. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +0 -1
  154. package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
  155. package/dist/commands/synthetics/__tests__/api.test.js +0 -422
  156. package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
  157. package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
  158. package/dist/commands/synthetics/__tests__/cli.test.js +0 -1325
  159. package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
  160. package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -149
  161. package/dist/commands/synthetics/__tests__/fixtures.js +0 -507
  162. package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
  163. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
  164. package/dist/commands/synthetics/__tests__/mobile.test.js +0 -376
  165. package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
  166. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
  167. package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -354
  168. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
  169. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
  170. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -353
  171. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
  172. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +0 -1
  173. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +0 -232
  174. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +0 -1
  175. package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +0 -1
  176. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +0 -735
  177. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +0 -1
  178. package/dist/commands/synthetics/__tests__/test.test.d.ts +0 -1
  179. package/dist/commands/synthetics/__tests__/test.test.js +0 -33
  180. package/dist/commands/synthetics/__tests__/test.test.js.map +0 -1
  181. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
  182. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
  183. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
  184. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
  185. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
  186. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
  187. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
  188. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -109
  189. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
  190. package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +0 -1
  191. package/dist/commands/synthetics/__tests__/utils/internal.test.js +0 -186
  192. package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +0 -1
  193. package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +0 -1
  194. package/dist/commands/synthetics/__tests__/utils/public.test.js +0 -1526
  195. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +0 -1
  196. package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
  197. package/dist/commands/tag/__tests__/tag.test.js +0 -75
  198. package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
  199. package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
  200. package/dist/commands/trace/__tests__/trace.test.js +0 -145
  201. package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
  202. package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +0 -1
  203. package/dist/commands/unity-symbols/__tests__/upload.test.js +0 -369
  204. package/dist/commands/unity-symbols/__tests__/upload.test.js.map +0 -1
  205. package/dist/helpers/__tests__/app.test.d.ts +0 -1
  206. package/dist/helpers/__tests__/app.test.js +0 -31
  207. package/dist/helpers/__tests__/app.test.js.map +0 -1
  208. package/dist/helpers/__tests__/ci.test.d.ts +0 -1
  209. package/dist/helpers/__tests__/ci.test.js +0 -252
  210. package/dist/helpers/__tests__/ci.test.js.map +0 -1
  211. package/dist/helpers/__tests__/fixtures.d.ts +0 -33
  212. package/dist/helpers/__tests__/fixtures.js +0 -71
  213. package/dist/helpers/__tests__/fixtures.js.map +0 -1
  214. package/dist/helpers/__tests__/flare.test.d.ts +0 -1
  215. package/dist/helpers/__tests__/flare.test.js +0 -226
  216. package/dist/helpers/__tests__/flare.test.js.map +0 -1
  217. package/dist/helpers/__tests__/fs.test.d.ts +0 -1
  218. package/dist/helpers/__tests__/fs.test.js +0 -189
  219. package/dist/helpers/__tests__/fs.test.js.map +0 -1
  220. package/dist/helpers/__tests__/plist.test.d.ts +0 -1
  221. package/dist/helpers/__tests__/plist.test.js +0 -43
  222. package/dist/helpers/__tests__/plist.test.js.map +0 -1
  223. package/dist/helpers/__tests__/prompt.test.d.ts +0 -1
  224. package/dist/helpers/__tests__/prompt.test.js +0 -71
  225. package/dist/helpers/__tests__/prompt.test.js.map +0 -1
  226. package/dist/helpers/__tests__/retry.test.d.ts +0 -1
  227. package/dist/helpers/__tests__/retry.test.js +0 -99
  228. package/dist/helpers/__tests__/retry.test.js.map +0 -1
  229. package/dist/helpers/__tests__/tags.test.d.ts +0 -1
  230. package/dist/helpers/__tests__/tags.test.js +0 -71
  231. package/dist/helpers/__tests__/tags.test.js.map +0 -1
  232. package/dist/helpers/__tests__/upload.test.d.ts +0 -1
  233. package/dist/helpers/__tests__/upload.test.js +0 -231
  234. package/dist/helpers/__tests__/upload.test.js.map +0 -1
  235. package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
  236. package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
  237. package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
  238. package/dist/helpers/__tests__/utils.test.d.ts +0 -1
  239. package/dist/helpers/__tests__/utils.test.js +0 -429
  240. package/dist/helpers/__tests__/utils.test.js.map +0 -1
  241. package/dist/helpers/__tests__/validation.test.d.ts +0 -1
  242. package/dist/helpers/__tests__/validation.test.js +0 -25
  243. package/dist/helpers/__tests__/validation.test.js.map +0 -1
  244. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
  245. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -103
  246. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
  247. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
  248. package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -121
  249. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
  250. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
  251. package/dist/helpers/git/__tests__/get-git-data.test.js +0 -72
  252. package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
@@ -1,722 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- jest.mock('fs');
36
- jest.mock('@aws-sdk/credential-providers', () => (Object.assign(Object.assign({}, jest.requireActual('@aws-sdk/credential-providers')), { fromIni: jest.fn() })));
37
- jest.mock('../prompt');
38
- jest.mock('../renderers/instrument-uninstrument-renderer');
39
- jest.mock('../../../helpers/prompt');
40
- jest.mock('../../../../package.json', () => ({ version: 'XXXX' }));
41
- const fs = __importStar(require("fs"));
42
- const client_lambda_1 = require("@aws-sdk/client-lambda");
43
- const credential_providers_1 = require("@aws-sdk/credential-providers");
44
- const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
45
- const constants_1 = require("../../../constants");
46
- const fixtures_1 = require("../../../helpers/__tests__/fixtures");
47
- const prompt_1 = require("../../../helpers/prompt");
48
- require("aws-sdk-client-mock-jest");
49
- const constants_2 = require("../constants");
50
- const prompt_2 = require("../prompt");
51
- const uninstrument_1 = require("../uninstrument");
52
- const fixtures_2 = require("./fixtures");
53
- describe('lambda', () => {
54
- const lambdaClientMock = (0, aws_sdk_client_mock_1.mockClient)(client_lambda_1.LambdaClient);
55
- describe('uninstrument', () => {
56
- describe('execute', () => {
57
- const OLD_ENV = process.env;
58
- beforeEach(() => {
59
- lambdaClientMock.reset();
60
- (0, fixtures_2.mockLambdaClientCommands)(lambdaClientMock);
61
- jest.resetModules();
62
- process.env = {};
63
- });
64
- afterAll(() => {
65
- process.env = OLD_ENV;
66
- });
67
- test('prints dry run data for a valid uninstrumentation', () => __awaiter(void 0, void 0, void 0, function* () {
68
- ;
69
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
70
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
71
- 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument': {
72
- config: {
73
- Architectures: ['x86_64'],
74
- Environment: {
75
- Variables: {
76
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
77
- [constants_2.FLUSH_TO_LOG_ENV_VAR]: 'true',
78
- [constants_2.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
79
- [constants_2.LOG_LEVEL_ENV_VAR]: 'debug',
80
- [constants_2.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
81
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
82
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
83
- [constants_2.TRACE_ENABLED_ENV_VAR]: 'true',
84
- [constants_1.VERSION_ENV_VAR]: '0.2',
85
- [constants_2.APM_FLUSH_DEADLINE_MILLISECONDS_ENV_VAR]: '42',
86
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
87
- },
88
- },
89
- FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument',
90
- Handler: 'datadog_lambda.handler.handler',
91
- Layers: [
92
- {
93
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
94
- CodeSize: 0,
95
- SigningJobArn: 'some-signing-job-arn',
96
- SigningProfileVersionArn: 'some-signing-profile',
97
- },
98
- {
99
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
100
- CodeSize: 0,
101
- SigningJobArn: 'some-signing-job-arn',
102
- SigningProfileVersionArn: 'some-signing-profile',
103
- },
104
- ],
105
- Runtime: 'python3.8',
106
- },
107
- },
108
- });
109
- const cli = (0, fixtures_2.makeCli)();
110
- const context = (0, fixtures_1.createMockContext)();
111
- const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument';
112
- process.env.DATADOG_API_KEY = '1234';
113
- const code = yield cli.run(['lambda', 'uninstrument', '-f', functionARN, '-r', 'us-east-1', '-d'], context);
114
- const output = context.stdout.toString();
115
- expect(code).toBe(0);
116
- expect(output).toMatchInlineSnapshot(`
117
- "
118
- [Dry Run] 🐶 Uninstrumenting Lambda function
119
-
120
- [!] Functions to be updated:
121
- - arn:aws:lambda:us-east-1:000000000000:function:uninstrument
122
-
123
- [Dry Run] Will apply the following updates:
124
- UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:000000000000:function:uninstrument
125
- {
126
- "FunctionName": "arn:aws:lambda:us-east-1:000000000000:function:uninstrument",
127
- "Handler": "lambda_function.lambda_handler",
128
- "Environment": {
129
- "Variables": {
130
- "USER_VARIABLE": "sh**********tion"
131
- }
132
- },
133
- "Layers": []
134
- }
135
- "
136
- `);
137
- }));
138
- test('runs function update command for valid uninstrumentation', () => __awaiter(void 0, void 0, void 0, function* () {
139
- ;
140
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
141
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
142
- 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument': {
143
- config: {
144
- Environment: {
145
- Variables: {
146
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
147
- [constants_2.FLUSH_TO_LOG_ENV_VAR]: 'true',
148
- [constants_2.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
149
- [constants_2.LOG_LEVEL_ENV_VAR]: 'debug',
150
- [constants_2.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
151
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
152
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
153
- [constants_2.TRACE_ENABLED_ENV_VAR]: 'true',
154
- [constants_1.VERSION_ENV_VAR]: '0.2',
155
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
156
- },
157
- },
158
- FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument',
159
- Handler: 'datadog_lambda.handler.handler',
160
- Layers: [
161
- {
162
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
163
- CodeSize: 0,
164
- SigningJobArn: 'some-signing-job-arn',
165
- SigningProfileVersionArn: 'some-signing-profile',
166
- },
167
- {
168
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
169
- CodeSize: 0,
170
- SigningJobArn: 'some-signing-job-arn',
171
- SigningProfileVersionArn: 'some-signing-profile',
172
- },
173
- ],
174
- Runtime: 'python3.8',
175
- },
176
- },
177
- });
178
- const cli = (0, fixtures_2.makeCli)();
179
- const context = (0, fixtures_1.createMockContext)();
180
- const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument';
181
- process.env.DATADOG_API_KEY = '1234';
182
- yield cli.run(['lambda', 'uninstrument', '-f', functionARN, '-r', 'us-east-1'], context);
183
- expect(lambdaClientMock).toHaveReceivedCommand(client_lambda_1.UpdateFunctionConfigurationCommand);
184
- }));
185
- test('aborts early when the aws-sdk throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
186
- ;
187
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
188
- lambdaClientMock.on(client_lambda_1.GetFunctionCommand).rejects('Lambda Failed');
189
- process.env = {};
190
- const command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
191
- command['functions'] = ['my-func'];
192
- command['region'] = 'us-east-1';
193
- const code = yield command['execute']();
194
- const output = command.context.stdout.toString();
195
- expect(code).toBe(1);
196
- expect(output).toMatchInlineSnapshot(`
197
- "
198
- 🐶 Uninstrumenting Lambda function
199
- [Error] Couldn't fetch Lambda functions. Error: Lambda Failed
200
- "
201
- `);
202
- }));
203
- test("aborts early when function regions can't be found", () => __awaiter(void 0, void 0, void 0, function* () {
204
- ;
205
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
206
- const cli = (0, fixtures_2.makeCli)();
207
- const context = (0, fixtures_1.createMockContext)();
208
- const code = yield cli.run(['lambda', 'uninstrument', '--function', 'my-func'], context);
209
- const output = context.stdout.toString();
210
- expect(code).toBe(1);
211
- expect(output).toMatch('No default region specified for ["my-func"]. Use -r, --region, or use a full functionARN');
212
- }));
213
- test('aborts early when no functions are specified', () => __awaiter(void 0, void 0, void 0, function* () {
214
- ;
215
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
216
- const cli = (0, fixtures_2.makeCli)();
217
- const context = (0, fixtures_1.createMockContext)();
218
- const code = yield cli.run(['lambda', 'uninstrument'], context);
219
- const output = context.stdout.toString();
220
- expect(code).toBe(1);
221
- expect(output).toMatchInlineSnapshot(`
222
- "
223
- 🐶 Uninstrumenting Lambda function
224
- [Error] No functions specified to remove instrumentation.
225
- "
226
- `);
227
- }));
228
- test('aborts early when no functions are specified while using config file', () => __awaiter(void 0, void 0, void 0, function* () {
229
- ;
230
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
231
- process.env = {};
232
- const command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
233
- command['config']['region'] = 'ap-southeast-1';
234
- yield command['execute']();
235
- const output = command.context.stdout.toString();
236
- expect(output).toMatchInlineSnapshot(`
237
- "
238
- 🐶 Uninstrumenting Lambda function
239
- [Error] No functions specified to remove instrumentation.
240
- "
241
- `);
242
- }));
243
- test('aborts if functions and a pattern are set at the same time', () => __awaiter(void 0, void 0, void 0, function* () {
244
- ;
245
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
246
- process.env = {};
247
- let command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
248
- command['config']['region'] = 'ap-southeast-1';
249
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
250
- command['regExPattern'] = 'valid-pattern';
251
- yield command['execute']();
252
- let output = command.context.stdout.toString();
253
- expect(output).toMatch('Functions in config file and "--functions-regex" should not be used at the same time.\n');
254
- command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
255
- command['region'] = 'ap-southeast-1';
256
- command['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
257
- command['regExPattern'] = 'valid-pattern';
258
- yield command['execute']();
259
- output = command.context.stdout.toString();
260
- expect(output).toMatch('"--functions" and "--functions-regex" should not be used at the same time.\n');
261
- }));
262
- test('aborts if the regEx pattern is an ARN', () => __awaiter(void 0, void 0, void 0, function* () {
263
- ;
264
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
265
- process.env = {};
266
- const command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
267
- command['region'] = 'ap-southeast-1';
268
- command['regExPattern'] = 'arn:aws:lambda:ap-southeast-1:123456789012:function:*';
269
- const code = yield command['execute']();
270
- const output = command.context.stdout.toString();
271
- expect(code).toBe(1);
272
- expect(output).toMatch(`"--functions-regex" isn't meant to be used with ARNs.\n`);
273
- }));
274
- test('aborts if the regEx pattern is set but no region is specified', () => __awaiter(void 0, void 0, void 0, function* () {
275
- ;
276
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
277
- process.env = {};
278
- const command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
279
- command['regExPattern'] = 'my-function';
280
- const code = yield command['execute']();
281
- const output = command.context.stdout.toString();
282
- expect(code).toBe(1);
283
- expect(output).toMatch('No default region specified. [-r,--region]');
284
- }));
285
- test('aborts if the the aws-sdk fails', () => __awaiter(void 0, void 0, void 0, function* () {
286
- ;
287
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
288
- process.env = {};
289
- lambdaClientMock.on(client_lambda_1.ListFunctionsCommand).rejects('ListFunctionsError');
290
- const command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
291
- command['region'] = 'ap-southeast-1';
292
- command['regExPattern'] = 'my-function';
293
- const code = yield command['execute']();
294
- const output = command.context.stdout.toString();
295
- expect(code).toBe(1);
296
- expect(output).toMatchInlineSnapshot(`
297
- "
298
- 🐶 Uninstrumenting Lambda function
299
- [Error] Couldn't fetch Lambda functions. Error: ListFunctionsError
300
- "
301
- `);
302
- }));
303
- test('uninstrument multiple functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
304
- ;
305
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
306
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
307
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
308
- config: {
309
- Architectures: ['x86_64'],
310
- Environment: {
311
- Variables: {
312
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
313
- [constants_2.FLUSH_TO_LOG_ENV_VAR]: 'true',
314
- [constants_2.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
315
- [constants_2.LOG_LEVEL_ENV_VAR]: 'debug',
316
- [constants_2.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
317
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
318
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
319
- [constants_2.TRACE_ENABLED_ENV_VAR]: 'true',
320
- [constants_1.VERSION_ENV_VAR]: '0.2',
321
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
322
- },
323
- },
324
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
325
- FunctionName: 'lambda-hello-world',
326
- Handler: 'datadog_lambda.handler.handler',
327
- Layers: [
328
- {
329
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
330
- CodeSize: 0,
331
- SigningJobArn: 'some-signing-job-arn',
332
- SigningProfileVersionArn: 'some-signing-profile',
333
- },
334
- {
335
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
336
- CodeSize: 0,
337
- SigningJobArn: 'some-signing-job-arn',
338
- SigningProfileVersionArn: 'some-signing-profile',
339
- },
340
- ],
341
- Runtime: 'python3.8',
342
- },
343
- },
344
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2': {
345
- config: {
346
- Architectures: ['x86_64'],
347
- Environment: {
348
- Variables: {
349
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
350
- [constants_2.FLUSH_TO_LOG_ENV_VAR]: 'true',
351
- [constants_2.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
352
- [constants_2.LOG_LEVEL_ENV_VAR]: 'debug',
353
- [constants_2.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
354
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
355
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
356
- [constants_2.TRACE_ENABLED_ENV_VAR]: 'true',
357
- [constants_1.VERSION_ENV_VAR]: '0.2',
358
- },
359
- },
360
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
361
- FunctionName: 'lambda-hello-world-2',
362
- Handler: 'datadog_lambda.handler.handler',
363
- Layers: [
364
- {
365
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
366
- CodeSize: 0,
367
- SigningJobArn: 'some-signing-job-arn',
368
- SigningProfileVersionArn: 'some-signing-profile',
369
- },
370
- {
371
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python39:49',
372
- CodeSize: 0,
373
- SigningJobArn: 'some-signing-job-arn',
374
- SigningProfileVersionArn: 'some-signing-profile',
375
- },
376
- ],
377
- Runtime: 'python3.9',
378
- },
379
- },
380
- });
381
- prompt_2.requestAWSCredentials.mockImplementation(() => {
382
- process.env[constants_2.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_2.mockAwsAccessKeyId;
383
- process.env[constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_2.mockAwsSecretAccessKey;
384
- process.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
385
- });
386
- prompt_2.requestFunctionSelection.mockImplementation(() => [
387
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
388
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
389
- ]);
390
- prompt_1.requestConfirmation.mockImplementation(() => true);
391
- const cli = (0, fixtures_2.makeCli)();
392
- const context = (0, fixtures_1.createMockContext)();
393
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
394
- const output = context.stdout.toString();
395
- expect(code).toBe(0);
396
- expect(output).toMatchSnapshot();
397
- }));
398
- test('uninstrument multiple specified functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
399
- ;
400
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
401
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
402
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
403
- config: {
404
- Architectures: ['x86_64'],
405
- Environment: {
406
- Variables: {
407
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
408
- [constants_2.FLUSH_TO_LOG_ENV_VAR]: 'true',
409
- [constants_2.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
410
- [constants_2.LOG_LEVEL_ENV_VAR]: 'debug',
411
- [constants_2.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
412
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
413
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
414
- [constants_2.TRACE_ENABLED_ENV_VAR]: 'true',
415
- [constants_1.VERSION_ENV_VAR]: '0.2',
416
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
417
- },
418
- },
419
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
420
- FunctionName: 'lambda-hello-world',
421
- Handler: 'datadog_lambda.handler.handler',
422
- Layers: [
423
- {
424
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
425
- CodeSize: 0,
426
- SigningJobArn: 'some-signing-job-arn',
427
- SigningProfileVersionArn: 'some-signing-profile',
428
- },
429
- {
430
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
431
- CodeSize: 0,
432
- SigningJobArn: 'some-signing-job-arn',
433
- SigningProfileVersionArn: 'some-signing-profile',
434
- },
435
- ],
436
- Runtime: 'python3.8',
437
- },
438
- },
439
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2': {
440
- config: {
441
- Architectures: ['x86_64'],
442
- Environment: {
443
- Variables: {
444
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
445
- [constants_2.FLUSH_TO_LOG_ENV_VAR]: 'true',
446
- [constants_2.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
447
- [constants_2.LOG_LEVEL_ENV_VAR]: 'debug',
448
- [constants_2.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
449
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
450
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
451
- [constants_2.TRACE_ENABLED_ENV_VAR]: 'true',
452
- [constants_1.VERSION_ENV_VAR]: '0.2',
453
- },
454
- },
455
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
456
- FunctionName: 'lambda-hello-world-2',
457
- Handler: 'datadog_lambda.handler.handler',
458
- Layers: [
459
- {
460
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
461
- CodeSize: 0,
462
- SigningJobArn: 'some-signing-job-arn',
463
- SigningProfileVersionArn: 'some-signing-profile',
464
- },
465
- {
466
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python39:49',
467
- CodeSize: 0,
468
- SigningJobArn: 'some-signing-job-arn',
469
- SigningProfileVersionArn: 'some-signing-profile',
470
- },
471
- ],
472
- Runtime: 'python3.9',
473
- },
474
- },
475
- });
476
- prompt_2.requestAWSCredentials.mockImplementation(() => {
477
- process.env[constants_2.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_2.mockAwsAccessKeyId;
478
- process.env[constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_2.mockAwsSecretAccessKey;
479
- process.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
480
- });
481
- prompt_2.requestFunctionSelection.mockImplementation(() => [
482
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
483
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
484
- ]);
485
- prompt_1.requestConfirmation.mockImplementation(() => true);
486
- const cli = (0, fixtures_2.makeCli)();
487
- const context = (0, fixtures_1.createMockContext)();
488
- const code = yield cli.run([
489
- 'lambda',
490
- 'uninstrument',
491
- '-i',
492
- '-f',
493
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
494
- '-f',
495
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
496
- ], context);
497
- const output = context.stdout.toString();
498
- expect(code).toBe(0);
499
- expect(output).toMatchSnapshot();
500
- }));
501
- test('aborts if a problem occurs while setting the AWS credentials interactively', () => __awaiter(void 0, void 0, void 0, function* () {
502
- ;
503
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
504
- prompt_2.requestAWSCredentials.mockImplementation(() => Promise.reject('Unexpected error'));
505
- const cli = (0, fixtures_2.makeCli)();
506
- const context = (0, fixtures_1.createMockContext)();
507
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
508
- const output = context.stdout.toString();
509
- expect(code).toBe(1);
510
- expect(output).toMatchInlineSnapshot(`
511
- "
512
- 🐶 Uninstrumenting Lambda function
513
- [!] 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.
514
- [Error] Unexpected error
515
- "
516
- `);
517
- }));
518
- test('aborts if there are no functions to uninstrument in the user AWS account', () => __awaiter(void 0, void 0, void 0, function* () {
519
- ;
520
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
521
- process.env = {
522
- [constants_2.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_2.mockAwsAccessKeyId,
523
- [constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_2.mockAwsSecretAccessKey,
524
- [constants_2.AWS_DEFAULT_REGION_ENV_VAR]: 'sa-east-1',
525
- };
526
- const cli = (0, fixtures_2.makeCli)();
527
- const context = (0, fixtures_1.createMockContext)();
528
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
529
- const output = context.stdout.toString();
530
- expect(code).toBe(1);
531
- expect(output).toMatchInlineSnapshot(`
532
- "
533
- 🐶 Uninstrumenting Lambda function
534
- [Error] Couldn't find any Lambda functions in the specified region.
535
- "
536
- `);
537
- }));
538
- test('aborts early when the aws-sdk throws an error while uninstrumenting interactively', () => __awaiter(void 0, void 0, void 0, function* () {
539
- ;
540
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
541
- process.env = {
542
- [constants_2.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_2.mockAwsAccessKeyId,
543
- [constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_2.mockAwsSecretAccessKey,
544
- [constants_2.AWS_DEFAULT_REGION_ENV_VAR]: 'sa-east-1',
545
- };
546
- lambdaClientMock.on(client_lambda_1.ListFunctionsCommand).rejects('ListFunctionsError');
547
- const cli = (0, fixtures_2.makeCli)();
548
- const context = (0, fixtures_1.createMockContext)();
549
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
550
- const output = context.stdout.toString();
551
- expect(code).toBe(1);
552
- expect(output).toMatchInlineSnapshot(`
553
- "
554
- 🐶 Uninstrumenting Lambda function
555
- [Error] Couldn't fetch Lambda functions. Error: ListFunctionsError
556
- "
557
- `);
558
- }));
559
- test('prints error when updating aws profile credentials fails', () => __awaiter(void 0, void 0, void 0, function* () {
560
- ;
561
- credential_providers_1.fromIni.mockImplementation(() => {
562
- throw Error('Update failed!');
563
- });
564
- const cli = (0, fixtures_2.makeCli)();
565
- const context = (0, fixtures_1.createMockContext)();
566
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
567
- const code = yield cli.run(['lambda', 'uninstrument', '-f', functionARN, '--profile', 'SOME-AWS-PROFILE'], context);
568
- const output = context.stdout.toString();
569
- expect(code).toBe(1);
570
- expect(output).toMatchInlineSnapshot(`
571
- "
572
- 🐶 Uninstrumenting Lambda function
573
- [Error] Error: Couldn't set AWS profile credentials. Update failed!
574
- "
575
- `);
576
- }));
577
- test('prints which functions failed to uninstrument without aborting when at least one function was uninstrumented correctly', () => __awaiter(void 0, void 0, void 0, function* () {
578
- ;
579
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
580
- const failingLambdas = [
581
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
582
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
583
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
584
- ];
585
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
586
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1': {
587
- config: {
588
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
589
- FunctionName: 'lambda-1-us-east-1',
590
- Handler: 'index.handler',
591
- Runtime: 'nodejs16.x',
592
- },
593
- },
594
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1': {
595
- config: {
596
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
597
- FunctionName: 'lambda-2-us-east-1',
598
- Handler: 'index.handler',
599
- Runtime: 'nodejs16.x',
600
- },
601
- },
602
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1': {
603
- config: {
604
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1',
605
- FunctionName: 'lambda-3-us-east-1',
606
- Handler: 'index.handler',
607
- Runtime: 'nodejs16.x',
608
- },
609
- },
610
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2': {
611
- config: {
612
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
613
- FunctionName: 'lambda-1-us-east-2',
614
- Handler: 'index.handler',
615
- Runtime: 'nodejs18.x',
616
- },
617
- },
618
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2': {
619
- config: {
620
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2',
621
- FunctionName: 'lambda-2-us-east-2',
622
- Handler: 'index.handler',
623
- Runtime: 'nodejs18.x',
624
- },
625
- },
626
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-3-us-east-2': {
627
- config: {
628
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-3-us-east-2',
629
- FunctionName: 'lambda-3-us-east-2',
630
- Handler: 'index.handler',
631
- Runtime: 'nodejs20.x',
632
- },
633
- },
634
- });
635
- for (const failingLambda of failingLambdas) {
636
- lambdaClientMock
637
- .on(client_lambda_1.UpdateFunctionConfigurationCommand, { FunctionName: failingLambda })
638
- .rejects('Unexpected error updating request');
639
- }
640
- const cli = (0, fixtures_2.makeCli)();
641
- const context = (0, fixtures_1.createMockContext)();
642
- const code = yield cli.run([
643
- 'lambda',
644
- 'instrument',
645
- '-f',
646
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
647
- '-f',
648
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
649
- '-f',
650
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1',
651
- '-f',
652
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
653
- '-f',
654
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2',
655
- '-f',
656
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-3-us-east-2',
657
- ], context);
658
- const output = context.stdout.toString();
659
- expect(code).toBe(0);
660
- expect(output).toMatchSnapshot();
661
- }));
662
- test('aborts when every lambda function fails to update on uninstrument', () => __awaiter(void 0, void 0, void 0, function* () {
663
- ;
664
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
665
- const failingLambdas = [
666
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
667
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
668
- ];
669
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
670
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1': {
671
- config: {
672
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
673
- FunctionName: 'lambda-1-us-east-1',
674
- Handler: 'index.handler',
675
- Runtime: 'nodejs16.x',
676
- },
677
- },
678
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2': {
679
- config: {
680
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
681
- FunctionName: 'lambda-1-us-east-2',
682
- Handler: 'index.handler',
683
- Runtime: 'nodejs18.x',
684
- },
685
- },
686
- });
687
- for (const failingLambda of failingLambdas) {
688
- lambdaClientMock
689
- .on(client_lambda_1.UpdateFunctionConfigurationCommand, { FunctionName: failingLambda })
690
- .rejects('Unexpected error updating request');
691
- }
692
- const cli = (0, fixtures_2.makeCli)();
693
- const context = (0, fixtures_1.createMockContext)();
694
- const code = yield cli.run([
695
- 'lambda',
696
- 'instrument',
697
- '-f',
698
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
699
- '-f',
700
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
701
- ], context);
702
- const output = context.stdout.toString();
703
- expect(code).toBe(1);
704
- expect(output).toMatchSnapshot();
705
- }));
706
- });
707
- describe('printPlannedActions', () => {
708
- test('prints no output when list is empty', () => {
709
- process.env = {};
710
- const command = (0, fixtures_1.createCommand)(uninstrument_1.UninstrumentCommand);
711
- command['printPlannedActions']([]);
712
- const output = command.context.stdout.toString();
713
- expect(output).toMatchInlineSnapshot(`
714
- "
715
- No updates will be applied.
716
- "
717
- `);
718
- });
719
- });
720
- });
721
- });
722
- //# sourceMappingURL=uninstrument.test.js.map