@datadog/datadog-ci 2.40.0 → 2.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/cli.test.d.ts +1 -0
- package/dist/__tests__/cli.test.js +41 -0
- package/dist/__tests__/cli.test.js.map +1 -0
- package/dist/commands/cloud-run/__tests__/fixtures.d.ts +2 -0
- package/dist/commands/cloud-run/__tests__/fixtures.js +12 -0
- package/dist/commands/cloud-run/__tests__/fixtures.js.map +1 -0
- package/dist/commands/cloud-run/__tests__/flare.test.d.ts +1 -0
- package/dist/commands/cloud-run/__tests__/flare.test.js +557 -0
- package/dist/commands/cloud-run/__tests__/flare.test.js.map +1 -0
- package/dist/commands/deployment/__tests__/mark.test.d.ts +1 -0
- package/dist/commands/deployment/__tests__/mark.test.js +47 -0
- package/dist/commands/deployment/__tests__/mark.test.js.map +1 -0
- package/dist/commands/dora/__tests__/deployment.test.d.ts +1 -0
- package/dist/commands/dora/__tests__/deployment.test.js +201 -0
- package/dist/commands/dora/__tests__/deployment.test.js.map +1 -0
- package/dist/commands/dsyms/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/dsyms/__tests__/upload.test.js +346 -0
- package/dist/commands/dsyms/__tests__/upload.test.js.map +1 -0
- package/dist/commands/dsyms/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/dsyms/__tests__/utils.test.js +100 -0
- package/dist/commands/dsyms/__tests__/utils.test.js.map +1 -0
- package/dist/commands/dsyms/upload.js +3 -3
- package/dist/commands/dsyms/upload.js.map +1 -1
- package/dist/commands/dsyms/utils.js +4 -2
- package/dist/commands/dsyms/utils.js.map +1 -1
- package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +1 -0
- package/dist/commands/elf-symbols/__tests__/elf.test.js +813 -0
- package/dist/commands/elf-symbols/__tests__/elf.test.js.map +1 -0
- package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/elf-symbols/__tests__/upload.test.js +249 -0
- package/dist/commands/elf-symbols/__tests__/upload.test.js.map +1 -0
- package/dist/commands/elf-symbols/upload.js +2 -3
- package/dist/commands/elf-symbols/upload.js.map +1 -1
- package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/flutter-symbols/__tests__/upload.test.js +617 -0
- package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +1 -0
- package/dist/commands/flutter-symbols/upload.js +2 -2
- package/dist/commands/flutter-symbols/upload.js.map +1 -1
- package/dist/commands/gate/__tests__/evaluate.test.d.ts +1 -0
- package/dist/commands/gate/__tests__/evaluate.test.js +398 -0
- package/dist/commands/gate/__tests__/evaluate.test.js.map +1 -0
- package/dist/commands/gate/__tests__/scope.test.d.ts +1 -0
- package/dist/commands/gate/__tests__/scope.test.js +29 -0
- package/dist/commands/gate/__tests__/scope.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/git.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/git.test.js +132 -0
- package/dist/commands/git-metadata/__tests__/git.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/gitdb.test.js +1386 -0
- package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/library.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/library.test.js +118 -0
- package/dist/commands/git-metadata/__tests__/library.test.js.map +1 -0
- package/dist/commands/git-metadata/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/git-metadata/__tests__/upload.test.js +52 -0
- package/dist/commands/git-metadata/__tests__/upload.test.js.map +1 -0
- package/dist/commands/junit/__tests__/id.test.d.ts +1 -0
- package/dist/commands/junit/__tests__/id.test.js +24 -0
- package/dist/commands/junit/__tests__/id.test.js.map +1 -0
- package/dist/commands/junit/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/junit/__tests__/upload.test.js +495 -0
- package/dist/commands/junit/__tests__/upload.test.js.map +1 -0
- package/dist/commands/junit/upload.js +5 -3
- package/dist/commands/junit/upload.js.map +1 -1
- package/dist/commands/lambda/__tests__/fixtures.d.ts +51 -0
- package/dist/commands/lambda/__tests__/fixtures.js +146 -0
- package/dist/commands/lambda/__tests__/fixtures.js.map +1 -0
- package/dist/commands/lambda/__tests__/flare.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/flare.test.js +730 -0
- package/dist/commands/lambda/__tests__/flare.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.js +791 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +386 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +721 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +513 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +33 -0
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/instrument.test.js +1511 -0
- package/dist/commands/lambda/__tests__/instrument.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/loggroup.test.js +340 -0
- package/dist/commands/lambda/__tests__/loggroup.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/prompt.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/prompt.test.js +206 -0
- package/dist/commands/lambda/__tests__/prompt.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/tags.test.js +305 -0
- package/dist/commands/lambda/__tests__/tags.test.js.map +1 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js +722 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js.map +1 -0
- package/dist/commands/measure/__tests__/measure.test.d.ts +1 -0
- package/dist/commands/measure/__tests__/measure.test.js +110 -0
- package/dist/commands/measure/__tests__/measure.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/codepush.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/codepush.test.js +161 -0
- package/dist/commands/react-native/__tests__/codepush.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/interfaces.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/interfaces.test.js +33 -0
- package/dist/commands/react-native/__tests__/interfaces.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/upload.test.js +238 -0
- package/dist/commands/react-native/__tests__/upload.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/utils.test.js +27 -0
- package/dist/commands/react-native/__tests__/utils.test.js.map +1 -0
- package/dist/commands/react-native/__tests__/xcode.test.d.ts +1 -0
- package/dist/commands/react-native/__tests__/xcode.test.js +465 -0
- package/dist/commands/react-native/__tests__/xcode.test.js.map +1 -0
- package/dist/commands/sarif/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/sarif/__tests__/upload.test.js +228 -0
- package/dist/commands/sarif/__tests__/upload.test.js.map +1 -0
- package/dist/commands/sarif/upload.js +2 -2
- package/dist/commands/sarif/upload.js.map +1 -1
- package/dist/commands/sbom/__tests__/payload.test.d.ts +1 -0
- package/dist/commands/sbom/__tests__/payload.test.js +262 -0
- package/dist/commands/sbom/__tests__/payload.test.js.map +1 -0
- package/dist/commands/sbom/__tests__/validation.test.d.ts +1 -0
- package/dist/commands/sbom/__tests__/validation.test.js +41 -0
- package/dist/commands/sbom/__tests__/validation.test.js.map +1 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.js +270 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.js.map +1 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.js +31 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.js.map +1 -0
- package/dist/commands/sourcemaps/upload.js +2 -2
- package/dist/commands/sourcemaps/upload.js.map +1 -1
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +192 -0
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +6 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +45 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +5 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +19 -0
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/helpers.test.js +205 -0
- package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/instrument.test.js +431 -0
- package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +1 -0
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +1 -0
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +166 -0
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/api.test.js +422 -0
- package/dist/commands/synthetics/__tests__/api.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.js +1325 -0
- package/dist/commands/synthetics/__tests__/cli.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/fixtures.d.ts +149 -0
- package/dist/commands/synthetics/__tests__/fixtures.js +507 -0
- package/dist/commands/synthetics/__tests__/fixtures.js.map +1 -0
- package/dist/commands/synthetics/__tests__/mobile.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/mobile.test.js +376 -0
- package/dist/commands/synthetics/__tests__/mobile.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.js +354 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/junit.test.js +353 -0
- package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +232 -0
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +735 -0
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/test.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/test.test.js +33 -0
- package/dist/commands/synthetics/__tests__/test.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +21 -0
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +80 -0
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +109 -0
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils/internal.test.js +186 -0
- package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +1 -0
- package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils/public.test.js +1526 -0
- package/dist/commands/synthetics/__tests__/utils/public.test.js.map +1 -0
- package/dist/commands/synthetics/api.d.ts +1 -1
- package/dist/commands/synthetics/api.js +10 -5
- package/dist/commands/synthetics/api.js.map +1 -1
- package/dist/commands/synthetics/run-tests-command.d.ts +1 -0
- package/dist/commands/synthetics/run-tests-command.js +3 -2
- package/dist/commands/synthetics/run-tests-command.js.map +1 -1
- package/dist/commands/synthetics/run-tests-lib.js +0 -4
- package/dist/commands/synthetics/run-tests-lib.js.map +1 -1
- package/dist/commands/synthetics/test.js +9 -1
- package/dist/commands/synthetics/test.js.map +1 -1
- package/dist/commands/synthetics/utils/public.js +3 -3
- package/dist/commands/synthetics/utils/public.js.map +1 -1
- package/dist/commands/tag/__tests__/tag.test.d.ts +1 -0
- package/dist/commands/tag/__tests__/tag.test.js +75 -0
- package/dist/commands/tag/__tests__/tag.test.js.map +1 -0
- package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
- package/dist/commands/trace/__tests__/trace.test.js +145 -0
- package/dist/commands/trace/__tests__/trace.test.js.map +1 -0
- package/dist/commands/trace/trace.js +1 -1
- package/dist/commands/trace/trace.js.map +1 -1
- package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/unity-symbols/__tests__/upload.test.js +369 -0
- package/dist/commands/unity-symbols/__tests__/upload.test.js.map +1 -0
- package/dist/commands/unity-symbols/upload.js +2 -2
- package/dist/commands/unity-symbols/upload.js.map +1 -1
- package/dist/helpers/__tests__/app.test.d.ts +1 -0
- package/dist/helpers/__tests__/app.test.js +31 -0
- package/dist/helpers/__tests__/app.test.js.map +1 -0
- package/dist/helpers/__tests__/ci.test.d.ts +1 -0
- package/dist/helpers/__tests__/ci.test.js +252 -0
- package/dist/helpers/__tests__/ci.test.js.map +1 -0
- package/dist/helpers/__tests__/fixtures.d.ts +33 -0
- package/dist/helpers/__tests__/fixtures.js +71 -0
- package/dist/helpers/__tests__/fixtures.js.map +1 -0
- package/dist/helpers/__tests__/flare.test.d.ts +1 -0
- package/dist/helpers/__tests__/flare.test.js +226 -0
- package/dist/helpers/__tests__/flare.test.js.map +1 -0
- package/dist/helpers/__tests__/fs.test.d.ts +1 -0
- package/dist/helpers/__tests__/fs.test.js +189 -0
- package/dist/helpers/__tests__/fs.test.js.map +1 -0
- package/dist/helpers/__tests__/plist.test.d.ts +1 -0
- package/dist/helpers/__tests__/plist.test.js +43 -0
- package/dist/helpers/__tests__/plist.test.js.map +1 -0
- package/dist/helpers/__tests__/prompt.test.d.ts +1 -0
- package/dist/helpers/__tests__/prompt.test.js +71 -0
- package/dist/helpers/__tests__/prompt.test.js.map +1 -0
- package/dist/helpers/__tests__/retry.test.d.ts +1 -0
- package/dist/helpers/__tests__/retry.test.js +99 -0
- package/dist/helpers/__tests__/retry.test.js.map +1 -0
- package/dist/helpers/__tests__/tags.test.d.ts +1 -0
- package/dist/helpers/__tests__/tags.test.js +71 -0
- package/dist/helpers/__tests__/tags.test.js.map +1 -0
- package/dist/helpers/__tests__/upload.test.d.ts +1 -0
- package/dist/helpers/__tests__/upload.test.js +231 -0
- package/dist/helpers/__tests__/upload.test.js.map +1 -0
- package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
- package/dist/helpers/__tests__/user-provided-git.test.js +119 -0
- package/dist/helpers/__tests__/user-provided-git.test.js.map +1 -0
- package/dist/helpers/__tests__/utils.test.d.ts +1 -0
- package/dist/helpers/__tests__/utils.test.js +429 -0
- package/dist/helpers/__tests__/utils.test.js.map +1 -0
- package/dist/helpers/__tests__/validation.test.d.ts +1 -0
- package/dist/helpers/__tests__/validation.test.js +25 -0
- package/dist/helpers/__tests__/validation.test.js.map +1 -0
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +1 -0
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +103 -0
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +1 -0
- package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +1 -0
- package/dist/helpers/git/__tests__/format-git-span-data.test.js +121 -0
- package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +1 -0
- package/dist/helpers/git/__tests__/get-git-data.test.d.ts +1 -0
- package/dist/helpers/git/__tests__/get-git-data.test.js +72 -0
- package/dist/helpers/git/__tests__/get-git-data.test.js.map +1 -0
- package/package.json +4 -6
|
@@ -0,0 +1,722 @@
|
|
|
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
|