@datadog/datadog-ci 2.18.0 → 2.18.1

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 (73) hide show
  1. package/dist/commands/cloud-run/cli.d.ts +1 -0
  2. package/dist/commands/cloud-run/cli.js +5 -0
  3. package/dist/commands/cloud-run/cli.js.map +1 -0
  4. package/dist/commands/cloud-run/constants.d.ts +1 -0
  5. package/dist/commands/cloud-run/constants.js +22 -0
  6. package/dist/commands/cloud-run/constants.js.map +1 -0
  7. package/dist/commands/cloud-run/flare.d.ts +60 -0
  8. package/dist/commands/cloud-run/flare.js +369 -0
  9. package/dist/commands/cloud-run/flare.js.map +1 -0
  10. package/dist/commands/cloud-run/interfaces.d.ts +27 -0
  11. package/dist/commands/cloud-run/interfaces.js +3 -0
  12. package/dist/commands/cloud-run/interfaces.js.map +1 -0
  13. package/dist/commands/cloud-run/renderer.d.ts +4 -0
  14. package/dist/commands/cloud-run/renderer.js +38 -0
  15. package/dist/commands/cloud-run/renderer.js.map +1 -0
  16. package/dist/commands/lambda/constants.d.ts +10 -8
  17. package/dist/commands/lambda/constants.js +41 -25
  18. package/dist/commands/lambda/constants.js.map +1 -1
  19. package/dist/commands/lambda/flare.d.ts +10 -45
  20. package/dist/commands/lambda/flare.js +121 -215
  21. package/dist/commands/lambda/flare.js.map +1 -1
  22. package/dist/commands/lambda/functions/commons.d.ts +7 -13
  23. package/dist/commands/lambda/functions/commons.js +39 -56
  24. package/dist/commands/lambda/functions/commons.js.map +1 -1
  25. package/dist/commands/lambda/functions/instrument.js +46 -45
  26. package/dist/commands/lambda/functions/instrument.js.map +1 -1
  27. package/dist/commands/lambda/functions/uninstrument.js +29 -28
  28. package/dist/commands/lambda/functions/uninstrument.js.map +1 -1
  29. package/dist/commands/lambda/instrument.js +19 -16
  30. package/dist/commands/lambda/instrument.js.map +1 -1
  31. package/dist/commands/lambda/prompt.d.ts +0 -2
  32. package/dist/commands/lambda/prompt.js +16 -35
  33. package/dist/commands/lambda/prompt.js.map +1 -1
  34. package/dist/commands/lambda/renderers/common-renderer.d.ts +0 -26
  35. package/dist/commands/lambda/renderers/common-renderer.js +4 -32
  36. package/dist/commands/lambda/renderers/common-renderer.js.map +1 -1
  37. package/dist/commands/lambda/renderers/instrument-uninstrument-renderer.js +27 -27
  38. package/dist/commands/lambda/renderers/instrument-uninstrument-renderer.js.map +1 -1
  39. package/dist/commands/lambda/uninstrument.js +9 -7
  40. package/dist/commands/lambda/uninstrument.js.map +1 -1
  41. package/dist/commands/sarif/api.js +2 -18
  42. package/dist/commands/sarif/api.js.map +1 -1
  43. package/dist/commands/synthetics/interfaces.d.ts +2 -1
  44. package/dist/commands/synthetics/interfaces.js.map +1 -1
  45. package/dist/commands/synthetics/reporters/default.js +3 -5
  46. package/dist/commands/synthetics/reporters/default.js.map +1 -1
  47. package/dist/commands/synthetics/utils.js +1 -0
  48. package/dist/commands/synthetics/utils.js.map +1 -1
  49. package/dist/constants.d.ts +10 -0
  50. package/dist/constants.js +14 -1
  51. package/dist/constants.js.map +1 -1
  52. package/dist/helpers/flare.d.ts +19 -0
  53. package/dist/helpers/flare.js +81 -0
  54. package/dist/helpers/flare.js.map +1 -0
  55. package/dist/helpers/fs.d.ts +31 -0
  56. package/dist/helpers/fs.js +117 -0
  57. package/dist/helpers/fs.js.map +1 -0
  58. package/dist/helpers/prompt.d.ts +6 -0
  59. package/dist/helpers/prompt.js +39 -0
  60. package/dist/helpers/prompt.js.map +1 -0
  61. package/dist/helpers/renderer.d.ts +36 -0
  62. package/dist/helpers/renderer.js +47 -0
  63. package/dist/helpers/renderer.js.map +1 -0
  64. package/dist/helpers/utils.d.ts +8 -0
  65. package/dist/helpers/utils.js +40 -1
  66. package/dist/helpers/utils.js.map +1 -1
  67. package/package.json +8 -2
  68. package/dist/commands/lambda/renderers/flare-renderer.d.ts +0 -9
  69. package/dist/commands/lambda/renderers/flare-renderer.js +0 -22
  70. package/dist/commands/lambda/renderers/flare-renderer.js.map +0 -1
  71. package/dist/helpers/file.d.ts +0 -1
  72. package/dist/helpers/file.js +0 -9
  73. package/dist/helpers/file.js.map +0 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const flare_1 = require("./flare");
4
+ module.exports = [flare_1.CloudRunFlareCommand];
5
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/cloud-run/cli.ts"],"names":[],"mappings":";;AAAA,mCAA4C;AAE5C,MAAM,CAAC,OAAO,GAAG,CAAC,4BAAoB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const SKIP_MASKING_CLOUDRUN_ENV_VARS: Set<string>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SKIP_MASKING_CLOUDRUN_ENV_VARS = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const NODE_OPTIONS_ENV_VAR = 'NODE_OPTIONS';
6
+ const DD_TRACE_PROPAGATION_STYLE_ENV_VAR = 'DD_TRACE_PROPAGATION_STYLE';
7
+ const DD_SOURCE_ENV_VAR = 'DD_SOURCE';
8
+ const DD_TAGS_ENV_VAR = 'DD_TAGS';
9
+ const DD_OLTP_HTTPS_ENV_VAR = 'DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT';
10
+ const DD_OLTP_GRPC_ENV_VAR = 'DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT';
11
+ exports.SKIP_MASKING_CLOUDRUN_ENV_VARS = new Set([
12
+ constants_1.SITE_ENV_VAR,
13
+ constants_1.SERVICE_ENV_VAR,
14
+ constants_1.ENVIRONMENT_ENV_VAR,
15
+ NODE_OPTIONS_ENV_VAR,
16
+ DD_TRACE_PROPAGATION_STYLE_ENV_VAR,
17
+ DD_SOURCE_ENV_VAR,
18
+ DD_TAGS_ENV_VAR,
19
+ DD_OLTP_HTTPS_ENV_VAR,
20
+ DD_OLTP_GRPC_ENV_VAR,
21
+ ]);
22
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/commands/cloud-run/constants.ts"],"names":[],"mappings":";;;AAAA,+CAAkF;AAElF,MAAM,oBAAoB,GAAG,cAAc,CAAA;AAC3C,MAAM,kCAAkC,GAAG,4BAA4B,CAAA;AACvE,MAAM,iBAAiB,GAAG,WAAW,CAAA;AACrC,MAAM,eAAe,GAAG,SAAS,CAAA;AACjC,MAAM,qBAAqB,GAAG,iDAAiD,CAAA;AAC/E,MAAM,oBAAoB,GAAG,iDAAiD,CAAA;AAEjE,QAAA,8BAA8B,GAAG,IAAI,GAAG,CAAC;IACpD,wBAAY;IACZ,2BAAe;IACf,+BAAmB;IACnB,oBAAoB;IACpB,kCAAkC;IAClC,iBAAiB;IACjB,eAAe;IACf,qBAAqB;IACrB,oBAAoB;CACrB,CAAC,CAAA"}
@@ -0,0 +1,60 @@
1
+ import IService = google.cloud.run.v2.IService;
2
+ import { Logging } from '@google-cloud/logging';
3
+ import { ServicesClient } from '@google-cloud/run';
4
+ import { google } from '@google-cloud/run/build/protos/protos';
5
+ import { Command } from 'clipanion';
6
+ import { CloudRunLog } from './interfaces';
7
+ export declare const MAX_LOGS = 1000;
8
+ export declare class CloudRunFlareCommand extends Command {
9
+ private isDryRun;
10
+ private withLogs;
11
+ private service?;
12
+ private project?;
13
+ private region?;
14
+ private caseId?;
15
+ private email?;
16
+ private apiKey?;
17
+ /**
18
+ * Entry point for the `cloud-run flare` command.
19
+ * Gathers Cloud Run service configuration and sends it to Datadog.
20
+ * @returns 0 if the command ran successfully, 1 otherwise.
21
+ */
22
+ execute(): Promise<1 | 0>;
23
+ }
24
+ /**
25
+ * Check if the user is authenticated with GCP.
26
+ * @returns true if the user is authenticated, false otherwise
27
+ */
28
+ export declare const checkAuthentication: () => Promise<boolean>;
29
+ /**
30
+ * Call the google-cloud run sdk to get the configuration
31
+ * for the given service.
32
+ * @param runClient the google-cloud run sdk client
33
+ * @param serviceName the name of the service
34
+ * @param projectName the project where the service is deployed
35
+ * @param region the region where the service is deployed
36
+ * @returns the configuration for the given service
37
+ */
38
+ export declare const getCloudRunServiceConfig: (runClient: ServicesClient, serviceName: string, projectName: string, region: string) => Promise<IService>;
39
+ /**
40
+ * Masks environment variables in a Cloud Run service configuration.
41
+ * Makes a copy as to not modify the config in place.
42
+ * @param config
43
+ * @returns masked config
44
+ */
45
+ export declare const maskConfig: (config: any) => IService;
46
+ /**
47
+ * Gets recent logs
48
+ * @param logClient Logging client
49
+ * @param serviceId
50
+ * @param location
51
+ * @param severityFilter if included, adds the string to the filter
52
+ * @returns array of logs as CloudRunLog interfaces
53
+ */
54
+ export declare const getLogs: (logClient: Logging, serviceId: string, location: string, severityFilter?: string | undefined) => Promise<CloudRunLog[]>;
55
+ /**
56
+ * Save logs in a CSV format
57
+ * @param logs array of logs stored as CloudRunLog interfaces
58
+ * @param filePath path to save the CSV file
59
+ */
60
+ export declare const saveLogsFile: (logs: CloudRunLog[], filePath: string) => void;
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.saveLogsFile = exports.getLogs = exports.maskConfig = exports.getCloudRunServiceConfig = exports.checkAuthentication = exports.CloudRunFlareCommand = exports.MAX_LOGS = void 0;
35
+ const fs_1 = __importDefault(require("fs"));
36
+ const path_1 = __importDefault(require("path"));
37
+ const process_1 = __importDefault(require("process"));
38
+ const util_1 = __importDefault(require("util"));
39
+ const logging_1 = require("@google-cloud/logging");
40
+ const run_1 = require("@google-cloud/run");
41
+ const chalk_1 = __importDefault(require("chalk"));
42
+ const clipanion_1 = require("clipanion");
43
+ const google_auth_library_1 = require("google-auth-library");
44
+ const constants_1 = require("../../constants");
45
+ const flare_1 = require("../../helpers/flare");
46
+ const fs_2 = require("../../helpers/fs");
47
+ const prompt_1 = require("../../helpers/prompt");
48
+ const helpersRenderer = __importStar(require("../../helpers/renderer"));
49
+ const utils_1 = require("../../helpers/utils");
50
+ const constants_2 = require("./constants");
51
+ const renderer_1 = require("./renderer");
52
+ const SERVICE_CONFIG_FILE_NAME = 'service_config.json';
53
+ const FLARE_ZIP_FILE_NAME = 'cloudrun-flare-output.zip';
54
+ const ALL_LOGS_FILE_NAME = 'all_logs.csv';
55
+ const WARNING_LOGS_FILE_NAME = 'warning_logs.csv';
56
+ const ERRORS_LOGS_FILE_NAME = 'error_logs.csv';
57
+ const DEBUG_LOGS_FILE_NAME = 'debug_logs.csv';
58
+ // Must be in range 0 - 1000. If more logs are needed, pagination must be implemented
59
+ exports.MAX_LOGS = 1000;
60
+ // How old the logs can be in minutes. Skip older logs
61
+ const MAX_LOG_AGE_MINUTES = 1440;
62
+ const FILTER_ORDER = 'timestamp asc';
63
+ // Types of log files to create
64
+ const LOG_CONFIGS = [
65
+ { type: 'total', fileName: ALL_LOGS_FILE_NAME },
66
+ { type: 'warning', severityFilter: ' AND severity>="WARNING"', fileName: WARNING_LOGS_FILE_NAME },
67
+ { type: 'error', severityFilter: ' AND severity>="ERROR"', fileName: ERRORS_LOGS_FILE_NAME },
68
+ { type: 'debug', severityFilter: ' AND severity="DEBUG"', fileName: DEBUG_LOGS_FILE_NAME },
69
+ ];
70
+ class CloudRunFlareCommand extends clipanion_1.Command {
71
+ constructor() {
72
+ super(...arguments);
73
+ this.isDryRun = false;
74
+ this.withLogs = false;
75
+ }
76
+ /**
77
+ * Entry point for the `cloud-run flare` command.
78
+ * Gathers Cloud Run service configuration and sends it to Datadog.
79
+ * @returns 0 if the command ran successfully, 1 otherwise.
80
+ */
81
+ execute() {
82
+ var _a;
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ this.context.stdout.write(helpersRenderer.renderFlareHeader('Cloud Run', this.isDryRun));
85
+ const errorMessages = [];
86
+ // Validate service
87
+ if (this.service === undefined) {
88
+ errorMessages.push(helpersRenderer.renderError('No service specified. [-s,--service]'));
89
+ }
90
+ // Validate project
91
+ if (this.project === undefined) {
92
+ errorMessages.push(helpersRenderer.renderError('No project specified. [-p,--project]'));
93
+ }
94
+ // Validate region
95
+ if (this.region === undefined) {
96
+ errorMessages.push(helpersRenderer.renderError('No region specified. [-r,--region]'));
97
+ }
98
+ // Validate Datadog API key
99
+ this.apiKey = (_a = process_1.default.env[constants_1.CI_API_KEY_ENV_VAR]) !== null && _a !== void 0 ? _a : process_1.default.env[constants_1.API_KEY_ENV_VAR];
100
+ if (this.apiKey === undefined) {
101
+ errorMessages.push(helpersRenderer.renderError('No Datadog API key specified. Set an API key with the DATADOG_API_KEY environment variable.'));
102
+ }
103
+ // Validate case ID
104
+ if (this.caseId === undefined) {
105
+ errorMessages.push(helpersRenderer.renderError('No case ID specified. [-c,--case-id]'));
106
+ }
107
+ // Validate email
108
+ if (this.email === undefined) {
109
+ errorMessages.push(helpersRenderer.renderError('No email specified. [-e,--email]'));
110
+ }
111
+ // If there are errors, print them and exit
112
+ if (errorMessages.length > 0) {
113
+ for (const message of errorMessages) {
114
+ this.context.stderr.write(message);
115
+ }
116
+ return 1;
117
+ }
118
+ // Verify GCP credentials
119
+ this.context.stdout.write(chalk_1.default.bold('\n🔑 Verifying GCP credentials...\n'));
120
+ const authenticated = yield exports.checkAuthentication();
121
+ if (!authenticated) {
122
+ this.context.stderr.write(renderer_1.renderAuthenticationInstructions());
123
+ return 1;
124
+ }
125
+ this.context.stdout.write('GCP credentials verified!\n');
126
+ // Get and print service configuration
127
+ this.context.stdout.write(chalk_1.default.bold('\n🔍 Fetching service configuration...\n'));
128
+ const runClient = new run_1.ServicesClient();
129
+ let config;
130
+ try {
131
+ config = yield exports.getCloudRunServiceConfig(runClient, this.service, this.project, this.region);
132
+ }
133
+ catch (err) {
134
+ if (err instanceof Error) {
135
+ this.context.stderr.write(helpersRenderer.renderError(`Unable to fetch service configuration: ${err.message}`));
136
+ }
137
+ return 1;
138
+ }
139
+ config = exports.maskConfig(config);
140
+ // 10 is the depth when inspecting the config file. Cloud-run configs have high depth, so
141
+ // we must raise the depth from the default depth of 2.
142
+ const configStr = util_1.default.inspect(config, false, 10, true);
143
+ this.context.stdout.write(`\n${configStr}\n`);
144
+ // Get logs
145
+ const logFileMappings = new Map();
146
+ if (this.withLogs) {
147
+ this.context.stdout.write(chalk_1.default.bold('\n📖 Getting logs...\n'));
148
+ const logClient = new logging_1.Logging({ projectId: this.project });
149
+ for (const logConfig of LOG_CONFIGS) {
150
+ try {
151
+ const logs = yield exports.getLogs(logClient, this.service, this.region, logConfig.severityFilter);
152
+ if (logs.length === 0) {
153
+ this.context.stdout.write(`• No ${logConfig.type} logs were found\n`);
154
+ }
155
+ else {
156
+ this.context.stdout.write(`• Found ${logs.length} ${logConfig.type} logs\n`);
157
+ logFileMappings.set(logConfig.fileName, logs);
158
+ }
159
+ }
160
+ catch (err) {
161
+ const msg = err instanceof Error ? err.message : '';
162
+ this.context.stderr.write(`• Unable to get ${logConfig.type} logs: ${msg}\n`);
163
+ }
164
+ }
165
+ }
166
+ try {
167
+ // Create folders
168
+ const rootFolderPath = path_1.default.join(process_1.default.cwd(), constants_1.FLARE_OUTPUT_DIRECTORY);
169
+ const logsFolderPath = path_1.default.join(rootFolderPath, constants_1.LOGS_DIRECTORY);
170
+ this.context.stdout.write(chalk_1.default.bold(`\n💾 Saving files to ${rootFolderPath}...\n`));
171
+ if (fs_1.default.existsSync(rootFolderPath)) {
172
+ fs_2.deleteFolder(rootFolderPath);
173
+ }
174
+ const subFolders = [];
175
+ if (logFileMappings.size > 0) {
176
+ subFolders.push(logsFolderPath);
177
+ }
178
+ fs_2.createDirectories(rootFolderPath, subFolders);
179
+ // Write config file
180
+ const configFilePath = path_1.default.join(rootFolderPath, SERVICE_CONFIG_FILE_NAME);
181
+ fs_2.writeFile(configFilePath, JSON.stringify(config, undefined, 2));
182
+ this.context.stdout.write(`• Saved function config to ./${SERVICE_CONFIG_FILE_NAME}\n`);
183
+ // Write logs
184
+ for (const [fileName, logs] of logFileMappings) {
185
+ const logFilePath = path_1.default.join(logsFolderPath, fileName);
186
+ exports.saveLogsFile(logs, logFilePath);
187
+ this.context.stdout.write(`• Saved logs to ./${constants_1.LOGS_DIRECTORY}/${fileName}\n`);
188
+ }
189
+ // Exit if dry run
190
+ const outputMsg = `\nℹ️ Your output files are located at: ${rootFolderPath}\n\n`;
191
+ if (this.isDryRun) {
192
+ this.context.stdout.write('\n🚫 The flare files were not sent as it was executed in dry run mode.');
193
+ this.context.stdout.write(outputMsg);
194
+ return 0;
195
+ }
196
+ // Confirm before sending
197
+ this.context.stdout.write('\n');
198
+ const confirmSendFiles = yield prompt_1.requestConfirmation('Are you sure you want to send the flare file to Datadog Support?', false);
199
+ if (!confirmSendFiles) {
200
+ this.context.stdout.write('\n🚫 The flare files were not sent based on your selection.');
201
+ this.context.stdout.write(outputMsg);
202
+ return 0;
203
+ }
204
+ // Zip folder
205
+ const zipPath = path_1.default.join(rootFolderPath, FLARE_ZIP_FILE_NAME);
206
+ yield fs_2.zipContents(rootFolderPath, zipPath);
207
+ // Send to Datadog
208
+ this.context.stdout.write(chalk_1.default.bold('\n🚀 Sending to Datadog Support...\n'));
209
+ yield flare_1.sendToDatadog(zipPath, this.caseId, this.email, this.apiKey, rootFolderPath);
210
+ this.context.stdout.write(chalk_1.default.bold('\n✅ Successfully sent flare file to Datadog Support!\n'));
211
+ // Delete contents
212
+ fs_2.deleteFolder(rootFolderPath);
213
+ }
214
+ catch (err) {
215
+ if (err instanceof Error) {
216
+ this.context.stderr.write(helpersRenderer.renderError(err.message));
217
+ }
218
+ return 1;
219
+ }
220
+ return 0;
221
+ });
222
+ }
223
+ }
224
+ exports.CloudRunFlareCommand = CloudRunFlareCommand;
225
+ /**
226
+ * Check if the user is authenticated with GCP.
227
+ * @returns true if the user is authenticated, false otherwise
228
+ */
229
+ const checkAuthentication = () => __awaiter(void 0, void 0, void 0, function* () {
230
+ const auth = new google_auth_library_1.GoogleAuth();
231
+ try {
232
+ yield auth.getApplicationDefault();
233
+ return true;
234
+ }
235
+ catch (_) {
236
+ return false;
237
+ }
238
+ });
239
+ exports.checkAuthentication = checkAuthentication;
240
+ /**
241
+ * Call the google-cloud run sdk to get the configuration
242
+ * for the given service.
243
+ * @param runClient the google-cloud run sdk client
244
+ * @param serviceName the name of the service
245
+ * @param projectName the project where the service is deployed
246
+ * @param region the region where the service is deployed
247
+ * @returns the configuration for the given service
248
+ */
249
+ const getCloudRunServiceConfig = (runClient, serviceName, projectName, region) => __awaiter(void 0, void 0, void 0, function* () {
250
+ const request = {
251
+ name: runClient.servicePath(projectName, region, serviceName),
252
+ };
253
+ const [response] = yield runClient.getService(request);
254
+ return response;
255
+ });
256
+ exports.getCloudRunServiceConfig = getCloudRunServiceConfig;
257
+ /**
258
+ * Masks environment variables in a Cloud Run service configuration.
259
+ * Makes a copy as to not modify the config in place.
260
+ * @param config
261
+ * @returns masked config
262
+ */
263
+ const maskConfig = (config) => {
264
+ var _a, _b;
265
+ // We stringify and parse again to make a deep copy
266
+ const configCopy = JSON.parse(JSON.stringify(config));
267
+ const containers = (_a = configCopy.template) === null || _a === void 0 ? void 0 : _a.containers;
268
+ if (!containers) {
269
+ return configCopy;
270
+ }
271
+ for (const container of containers) {
272
+ const env = (_b = container.env) !== null && _b !== void 0 ? _b : [];
273
+ for (const envVar of env) {
274
+ const name = envVar.name;
275
+ const val = envVar.value;
276
+ if (!name || !val) {
277
+ continue;
278
+ }
279
+ if (!constants_2.SKIP_MASKING_CLOUDRUN_ENV_VARS.has(name)) {
280
+ envVar.value = utils_1.maskString(val);
281
+ }
282
+ }
283
+ }
284
+ return configCopy;
285
+ };
286
+ exports.maskConfig = maskConfig;
287
+ /**
288
+ * Gets recent logs
289
+ * @param logClient Logging client
290
+ * @param serviceId
291
+ * @param location
292
+ * @param severityFilter if included, adds the string to the filter
293
+ * @returns array of logs as CloudRunLog interfaces
294
+ */
295
+ const getLogs = (logClient, serviceId, location, severityFilter) => __awaiter(void 0, void 0, void 0, function* () {
296
+ var _a, _b, _c, _d, _e, _f, _g, _h;
297
+ const logs = [];
298
+ // Only get recent logs
299
+ const date = new Date();
300
+ date.setMinutes(date.getMinutes() - MAX_LOG_AGE_MINUTES);
301
+ const formattedDate = date.toISOString();
302
+ // Query options
303
+ let filter = `resource.labels.service_name="${serviceId}" AND resource.labels.location="${location}" AND timestamp>="${formattedDate}" AND (textPayload:* OR httpRequest:*)`;
304
+ // We only want to get logs from the last `MAX_LOG_AGE_MINUTES` to make sure they are relevant.
305
+ // We also only want to include logs with a textPayload or logs that were an HTTP request.
306
+ // Any other logs are just audit logs which are spammy and don't have any relevant information.
307
+ filter += severityFilter !== null && severityFilter !== void 0 ? severityFilter : '';
308
+ const options = {
309
+ filter,
310
+ orderBy: FILTER_ORDER,
311
+ pageSize: exports.MAX_LOGS,
312
+ };
313
+ const [entries] = yield logClient.getEntries(options);
314
+ for (const entry of entries) {
315
+ let msg = '';
316
+ if (entry.metadata.textPayload) {
317
+ msg = entry.metadata.textPayload;
318
+ }
319
+ if (entry.metadata.httpRequest) {
320
+ const request = entry.metadata.httpRequest;
321
+ const status = (_a = request.status) !== null && _a !== void 0 ? _a : '';
322
+ let ms = 'unknown';
323
+ const latency = request.latency;
324
+ if (latency) {
325
+ ms = (Number(latency.seconds) * 1000 + Math.round(Number(latency.nanos) / 1000000)).toString();
326
+ }
327
+ const bytes = utils_1.formatBytes(Number(request.responseSize));
328
+ const method = (_b = request.requestMethod) !== null && _b !== void 0 ? _b : '';
329
+ const requestUrl = (_c = request.requestUrl) !== null && _c !== void 0 ? _c : '';
330
+ msg += `${method} ${status}. responseSize: ${bytes}. latency: ${ms} ms. requestUrl: ${requestUrl}`;
331
+ }
332
+ const log = {
333
+ severity: (_e = (_d = entry.metadata.severity) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : '',
334
+ timestamp: (_g = (_f = entry.metadata.timestamp) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : '',
335
+ logName: (_h = entry.metadata.logName) !== null && _h !== void 0 ? _h : '',
336
+ message: `"${msg}"`,
337
+ };
338
+ logs.push(log);
339
+ }
340
+ return logs;
341
+ });
342
+ exports.getLogs = getLogs;
343
+ /**
344
+ * Save logs in a CSV format
345
+ * @param logs array of logs stored as CloudRunLog interfaces
346
+ * @param filePath path to save the CSV file
347
+ */
348
+ const saveLogsFile = (logs, filePath) => {
349
+ const rows = [['severity', 'timestamp', 'logName', 'message']];
350
+ logs.forEach((log) => {
351
+ const severity = `"${log.severity}"`;
352
+ const timestamp = `"${log.timestamp}"`;
353
+ const logName = `"${log.logName}"`;
354
+ const logMessage = `"${log.message}"`;
355
+ rows.push([severity, timestamp, logName, logMessage]);
356
+ });
357
+ const data = rows.join('\n');
358
+ fs_2.writeFile(filePath, data);
359
+ };
360
+ exports.saveLogsFile = saveLogsFile;
361
+ CloudRunFlareCommand.addPath('cloud-run', 'flare');
362
+ CloudRunFlareCommand.addOption('isDryRun', clipanion_1.Command.Boolean('-d,--dry'));
363
+ CloudRunFlareCommand.addOption('withLogs', clipanion_1.Command.Boolean('--with-logs'));
364
+ CloudRunFlareCommand.addOption('service', clipanion_1.Command.String('-s,--service'));
365
+ CloudRunFlareCommand.addOption('project', clipanion_1.Command.String('-p,--project'));
366
+ CloudRunFlareCommand.addOption('region', clipanion_1.Command.String('-r,--region,-l,--location'));
367
+ CloudRunFlareCommand.addOption('caseId', clipanion_1.Command.String('-c,--case-id'));
368
+ CloudRunFlareCommand.addOption('email', clipanion_1.Command.String('-e,--email'));
369
+ //# sourceMappingURL=flare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flare.js","sourceRoot":"","sources":["../../../src/commands/cloud-run/flare.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAAmB;AACnB,gDAAuB;AACvB,sDAA6B;AAC7B,gDAAuB;AAEvB,mDAA6C;AAC7C,2CAAgD;AAEhD,kDAAyB;AACzB,yCAAiC;AACjC,6DAA8C;AAE9C,+CAA2G;AAC3G,+CAAiD;AACjD,yCAAwF;AACxF,iDAAwD;AACxD,wEAAyD;AACzD,+CAA2D;AAE3D,2CAA0D;AAE1D,yCAA2D;AAE3D,MAAM,wBAAwB,GAAG,qBAAqB,CAAA;AACtD,MAAM,mBAAmB,GAAG,2BAA2B,CAAA;AACvD,MAAM,kB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CAAC,CAAA;AACrF,oBAAoB,CAAC,SAAS,CAAC,QAAQ,EAAE,mBAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAA;AACxE,oBAAoB,CAAC,SAAS,CAAC,OAAO,EAAE,mBAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Summarize relevant information about a Cloud Run log.
3
+ * Also used to build CSV log files.
4
+ * @typedef {Object} CloudRunLog
5
+ * @property {string} severity - The level of severity of the log. It can be values such as 'DEBUG', 'INFO', 'ERROR', etc.
6
+ * @property {string} timestamp - The timestamp of when the log was generated.
7
+ * @property {string} logName - The name of the log
8
+ * @property {string} message - The actual log message detailing what event occurred.
9
+ */
10
+ export interface CloudRunLog {
11
+ severity: string;
12
+ timestamp: string;
13
+ logName: string;
14
+ message: string;
15
+ }
16
+ /**
17
+ * Contains all the information used to create a log file.
18
+ * @typedef {Object} LogConfig
19
+ * @property {string} type - string name of the type of log. Used when printing CLI messages.
20
+ * @property {string} fileName - The name of the log file (such as 'all_logs.csv' or 'error_logs.csv')
21
+ * @property {string} [severityFilter] - Optional filter to modify the Logging query. Example: ' AND severity="DEBUG"'
22
+ */
23
+ export interface LogConfig {
24
+ type: string;
25
+ fileName: string;
26
+ severityFilter?: string;
27
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/commands/cloud-run/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @returns instructions on how to authenticate with GCP.
3
+ */
4
+ export declare const renderAuthenticationInstructions: () => string;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.renderAuthenticationInstructions = void 0;
23
+ const helpersRenderer = __importStar(require("../../helpers/renderer"));
24
+ const AUTHENTICATION_INSTRUCTIONS = [
25
+ '\n' + helpersRenderer.renderError('Unable to authenticate with GCP.'),
26
+ 'To authenticate with GCP, please follow these steps:',
27
+ "1. If you haven't already, install the Google Cloud SDK: https://cloud.google.com/sdk/docs/install",
28
+ '2. Run "gcloud auth application-default login" and follow the prompts in your browser to log in.',
29
+ '3. After logging in, run the `datadog-ci cloud-run flare` command again.\n',
30
+ ];
31
+ /**
32
+ * @returns instructions on how to authenticate with GCP.
33
+ */
34
+ const renderAuthenticationInstructions = () => {
35
+ return AUTHENTICATION_INSTRUCTIONS.join('\n');
36
+ };
37
+ exports.renderAuthenticationInstructions = renderAuthenticationInstructions;
38
+ //# sourceMappingURL=renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/commands/cloud-run/renderer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wEAAyD;AAEzD,MAAM,2BAA2B,GAAG;IAClC,IAAI,GAAG,eAAe,CAAC,WAAW,CAAC,kCAAkC,CAAC;IACtE,sDAAsD;IACtD,oGAAoG;IACpG,kGAAkG;IAClG,4EAA4E;CAC7E,CAAA;AACD;;GAEG;AACI,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACnD,OAAO,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/C,CAAC,CAAA;AAFY,QAAA,gCAAgC,oCAE5C"}
@@ -15,6 +15,7 @@ export declare const LAYER_LOOKUP: {
15
15
  readonly 'python3.8': "Datadog-Python38";
16
16
  readonly 'python3.9': "Datadog-Python39";
17
17
  readonly 'python3.10': "Datadog-Python310";
18
+ readonly 'python3.11': "Datadog-Python311";
18
19
  readonly 'ruby2.7': "Datadog-Ruby2-7";
19
20
  readonly 'ruby3.2': "Datadog-Ruby3-2";
20
21
  };
@@ -41,6 +42,7 @@ export declare const RUNTIME_LOOKUP: {
41
42
  'python3.8': RuntimeType;
42
43
  'python3.9': RuntimeType;
43
44
  'python3.10': RuntimeType;
45
+ 'python3.11': RuntimeType;
44
46
  'ruby2.7': RuntimeType;
45
47
  'ruby3.2': RuntimeType;
46
48
  };
@@ -61,18 +63,13 @@ export declare const CORECLR_ENABLE_PROFILING = "1";
61
63
  export declare const CORECLR_PROFILER = "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}";
62
64
  export declare const CORECLR_PROFILER_PATH = "/opt/datadog/Datadog.Trace.ClrProfiler.Native.so";
63
65
  export declare const DD_DOTNET_TRACER_HOME = "/opt/datadog";
64
- export declare const API_KEY_ENV_VAR = "DD_API_KEY";
65
66
  export declare const API_KEY_SECRET_ARN_ENV_VAR = "DD_API_KEY_SECRET_ARN";
66
67
  export declare const KMS_API_KEY_ENV_VAR = "DD_KMS_API_KEY";
67
- export declare const SITE_ENV_VAR = "DD_SITE";
68
68
  export declare const TRACE_ENABLED_ENV_VAR = "DD_TRACE_ENABLED";
69
69
  export declare const MERGE_XRAY_TRACES_ENV_VAR = "DD_MERGE_XRAY_TRACES";
70
70
  export declare const FLUSH_TO_LOG_ENV_VAR = "DD_FLUSH_TO_LOG";
71
71
  export declare const LOG_LEVEL_ENV_VAR = "DD_LOG_LEVEL";
72
72
  export declare const LAMBDA_HANDLER_ENV_VAR = "DD_LAMBDA_HANDLER";
73
- export declare const SERVICE_ENV_VAR = "DD_SERVICE";
74
- export declare const VERSION_ENV_VAR = "DD_VERSION";
75
- export declare const ENVIRONMENT_ENV_VAR = "DD_ENV";
76
73
  export declare const EXTRA_TAGS_ENV_VAR = "DD_TAGS";
77
74
  export declare const CAPTURE_LAMBDA_PAYLOAD_ENV_VAR = "DD_CAPTURE_LAMBDA_PAYLOAD";
78
75
  export declare const APM_FLUSH_DEADLINE_MILLISECONDS_ENV_VAR = "DD_APM_FLUSH_DEADLINE_MILLISECONDS";
@@ -80,8 +77,6 @@ export declare const ENABLE_PROFILING_ENV_VAR = "CORECLR_ENABLE_PROFILING";
80
77
  export declare const PROFILER_ENV_VAR = "CORECLR_PROFILER";
81
78
  export declare const PROFILER_PATH_ENV_VAR = "CORECLR_PROFILER_PATH";
82
79
  export declare const DOTNET_TRACER_HOME_ENV_VAR = "DD_DOTNET_TRACER_HOME";
83
- export declare const CI_SITE_ENV_VAR = "DATADOG_SITE";
84
- export declare const CI_API_KEY_ENV_VAR = "DATADOG_API_KEY";
85
80
  export declare const CI_API_KEY_SECRET_ARN_ENV_VAR = "DATADOG_API_KEY_SECRET_ARN";
86
81
  export declare const CI_KMS_API_KEY_ENV_VAR = "DATADOG_KMS_API_KEY";
87
82
  export declare const AWS_ACCESS_KEY_ID_ENV_VAR = "AWS_ACCESS_KEY_ID";
@@ -97,5 +92,12 @@ export declare const AWS_SECRET_ACCESS_KEY_REG_EXP: RegExp;
97
92
  export declare const AWS_SECRET_ARN_REG_EXP: RegExp;
98
93
  export declare const DATADOG_API_KEY_REG_EXP: RegExp;
99
94
  export declare const DATADOG_APP_KEY_REG_EXP: RegExp;
100
- export declare const SKIP_MASKING_ENV_VARS: Set<string>;
95
+ export declare const SKIP_MASKING_LAMBDA_ENV_VARS: Set<string>;
96
+ export declare enum DeploymentFrameworks {
97
+ ServerlessFramework = "Serverless Framework",
98
+ AwsCdk = "AWS CDK",
99
+ AwsCloudFormation = "AWS CloudFormation",
100
+ Unknown = "Unknown"
101
+ }
102
+ export declare const FRAMEWORK_FILES_MAPPING: Map<string, DeploymentFrameworks>;
101
103
  export declare const PROJECT_FILES: string[];