@datadog/datadog-ci 0.17.7 → 0.17.11

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 (86) hide show
  1. package/LICENSE-3rdparty.csv +2 -0
  2. package/README.md +3 -1
  3. package/dist/{commands/dependencies/index.d.ts → cli.d.ts} +0 -0
  4. package/dist/cli.js +34 -0
  5. package/dist/commands/{dsyms/index.d.ts → dependencies/cli.d.ts} +0 -0
  6. package/dist/commands/dependencies/{index.js → cli.js} +0 -0
  7. package/dist/commands/dependencies/upload.d.ts +1 -1
  8. package/dist/commands/{git-metadata/index.d.ts → dsyms/cli.d.ts} +0 -0
  9. package/dist/commands/dsyms/{index.js → cli.js} +0 -0
  10. package/dist/commands/dsyms/upload.d.ts +1 -1
  11. package/dist/commands/{junit/index.d.ts → git-metadata/cli.d.ts} +0 -0
  12. package/dist/commands/git-metadata/{index.js → cli.js} +0 -0
  13. package/dist/commands/git-metadata/upload.d.ts +1 -1
  14. package/dist/commands/git-metadata/upload.js +6 -1
  15. package/dist/commands/{lambda/__tests__/function.test.d.ts → junit/cli.d.ts} +0 -0
  16. package/dist/commands/junit/{index.js → cli.js} +0 -0
  17. package/dist/commands/junit/upload.d.ts +1 -1
  18. package/dist/commands/lambda/__tests__/fixtures.d.ts +42 -0
  19. package/dist/commands/lambda/__tests__/fixtures.js +73 -0
  20. package/dist/commands/lambda/{index.d.ts → __tests__/functions/commons.test.d.ts} +0 -0
  21. package/dist/commands/lambda/__tests__/functions/commons.test.js +350 -0
  22. package/dist/commands/{sourcemaps/index.d.ts → lambda/__tests__/functions/instrument.test.d.ts} +0 -0
  23. package/dist/commands/lambda/__tests__/{function.test.js → functions/instrument.test.js} +504 -476
  24. package/dist/commands/{trace/index.d.ts → lambda/__tests__/functions/uninstrument.test.d.ts} +0 -0
  25. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +371 -0
  26. package/dist/commands/lambda/__tests__/instrument.test.js +351 -234
  27. package/dist/commands/lambda/__tests__/loggroup.test.js +98 -34
  28. package/dist/commands/lambda/__tests__/tags.test.js +107 -31
  29. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
  30. package/dist/commands/lambda/__tests__/uninstrument.test.js +281 -0
  31. package/dist/commands/lambda/cli.d.ts +1 -0
  32. package/dist/commands/lambda/cli.js +5 -0
  33. package/dist/commands/lambda/constants.d.ts +18 -6
  34. package/dist/commands/lambda/constants.js +30 -6
  35. package/dist/commands/lambda/functions/commons.d.ts +101 -0
  36. package/dist/commands/lambda/functions/commons.js +258 -0
  37. package/dist/commands/lambda/functions/instrument.d.ts +7 -0
  38. package/dist/commands/lambda/functions/instrument.js +186 -0
  39. package/dist/commands/lambda/functions/uninstrument.d.ts +7 -0
  40. package/dist/commands/lambda/functions/uninstrument.js +121 -0
  41. package/dist/commands/lambda/instrument.d.ts +4 -4
  42. package/dist/commands/lambda/instrument.js +103 -57
  43. package/dist/commands/lambda/interfaces.d.ts +53 -0
  44. package/dist/commands/lambda/loggroup.d.ts +4 -7
  45. package/dist/commands/lambda/loggroup.js +30 -5
  46. package/dist/commands/lambda/tags.d.ts +3 -4
  47. package/dist/commands/lambda/tags.js +19 -3
  48. package/dist/commands/lambda/uninstrument.d.ts +12 -0
  49. package/dist/commands/lambda/uninstrument.js +166 -0
  50. package/dist/commands/sourcemaps/cli.d.ts +1 -0
  51. package/dist/commands/sourcemaps/{index.js → cli.js} +0 -0
  52. package/dist/commands/sourcemaps/upload.d.ts +1 -1
  53. package/dist/commands/synthetics/__tests__/cli.test.js +13 -13
  54. package/dist/commands/synthetics/__tests__/fixtures.js +0 -1
  55. package/dist/commands/synthetics/__tests__/reporters/default.test.js +3 -2
  56. package/dist/commands/synthetics/__tests__/run-test.test.js +6 -6
  57. package/dist/commands/synthetics/__tests__/utils.test.js +9 -5
  58. package/dist/commands/synthetics/__tests__/websocket.test.js +3 -3
  59. package/dist/commands/synthetics/cli.d.ts +1 -26
  60. package/dist/commands/synthetics/cli.js +2 -227
  61. package/dist/commands/synthetics/command.d.ts +26 -0
  62. package/dist/commands/synthetics/command.js +229 -0
  63. package/dist/commands/synthetics/index.d.ts +5 -1
  64. package/dist/commands/synthetics/index.js +31 -2
  65. package/dist/commands/synthetics/interfaces.d.ts +1 -1
  66. package/dist/commands/synthetics/reporters/default.d.ts +3 -3
  67. package/dist/commands/synthetics/reporters/default.js +4 -3
  68. package/dist/commands/synthetics/utils.d.ts +1 -3
  69. package/dist/commands/synthetics/utils.js +14 -15
  70. package/dist/commands/trace/cli.d.ts +1 -0
  71. package/dist/commands/trace/{index.js → cli.js} +0 -0
  72. package/dist/commands/trace/trace.d.ts +1 -1
  73. package/dist/helpers/__tests__/ci.test.js +51 -114
  74. package/dist/helpers/__tests__/user-provided-git.test.js +14 -2
  75. package/dist/helpers/__tests__/utils.test.js +4 -0
  76. package/dist/helpers/ci.js +62 -96
  77. package/dist/helpers/interfaces.d.ts +28 -2
  78. package/dist/helpers/user-provided-git.js +11 -2
  79. package/dist/helpers/utils.d.ts +4 -0
  80. package/dist/helpers/utils.js +18 -1
  81. package/dist/index.d.ts +3 -1
  82. package/dist/index.js +23 -31
  83. package/package.json +8 -6
  84. package/dist/commands/lambda/function.d.ts +0 -43
  85. package/dist/commands/lambda/function.js +0 -273
  86. package/dist/commands/lambda/index.js +0 -4
@@ -35,43 +35,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
35
  jest.mock('fs');
36
36
  jest.mock('aws-sdk');
37
37
  const aws_sdk_1 = require("aws-sdk");
38
- const fs = __importStar(require("fs"));
38
+ const chalk_1 = require("chalk");
39
39
  const advanced_1 = require("clipanion/lib/advanced");
40
+ const fs = __importStar(require("fs"));
40
41
  const path_1 = __importDefault(require("path"));
41
- const constants_1 = require("../constants");
42
42
  const instrument_1 = require("../instrument");
43
+ const fixtures_1 = require("./fixtures");
43
44
  // tslint:disable-next-line
44
45
  const { version } = require(path_1.default.join(__dirname, '../../../../package.json'));
45
46
  describe('lambda', () => {
46
- const createMockContext = () => {
47
- let data = '';
48
- return {
49
- stdout: {
50
- toString: () => data,
51
- write: (input) => {
52
- data += input;
53
- },
54
- },
55
- };
56
- };
57
- const createCommand = () => {
58
- const command = new instrument_1.InstrumentCommand();
59
- command.context = createMockContext();
60
- return command;
61
- };
62
- const makeCli = () => {
63
- const cli = new advanced_1.Cli();
64
- cli.register(instrument_1.InstrumentCommand);
65
- return cli;
66
- };
67
- const makeMockLambda = (functionConfigs) => ({
68
- getFunction: jest.fn().mockImplementation(({ FunctionName }) => ({
69
- promise: () => Promise.resolve({ Configuration: functionConfigs[FunctionName] }),
70
- })),
71
- listTags: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: {} }) })),
72
- tagResource: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve({}) })),
73
- updateFunctionConfiguration: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
74
- });
75
47
  describe('instrument', () => {
76
48
  describe('execute', () => {
77
49
  const OLD_ENV = process.env;
@@ -85,15 +57,15 @@ describe('lambda', () => {
85
57
  test('prints dry run data for lambda library layer', () => __awaiter(void 0, void 0, void 0, function* () {
86
58
  ;
87
59
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
88
- aws_sdk_1.Lambda.mockImplementation(() => makeMockLambda({
60
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
89
61
  'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
90
62
  FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
91
63
  Handler: 'index.handler',
92
64
  Runtime: 'nodejs12.x',
93
65
  },
94
66
  }));
95
- const cli = makeCli();
96
- const context = createMockContext();
67
+ const cli = fixtures_1.makeCli();
68
+ const context = fixtures_1.createMockContext();
97
69
  const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
98
70
  const code = yield cli.run([
99
71
  'lambda',
@@ -117,48 +89,51 @@ describe('lambda', () => {
117
89
  const output = context.stdout.toString();
118
90
  expect(code).toBe(0);
119
91
  expect(output).toMatchInlineSnapshot(`
120
- "[Dry Run] Will apply the following updates:
121
- UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
122
- {
123
- \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\\",
124
- \\"Handler\\": \\"/opt/nodejs/node_modules/datadog-lambda-js/handler.handler\\",
125
- \\"Environment\\": {
126
- \\"Variables\\": {
127
- \\"DD_LAMBDA_HANDLER\\": \\"index.handler\\",
128
- \\"DD_SITE\\": \\"datadoghq.com\\",
129
- \\"DD_ENV\\": \\"staging\\",
130
- \\"DD_TAGS\\": \\"layer:api,team:intake\\",
131
- \\"DD_FLUSH_TO_LOG\\": \\"true\\",
132
- \\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
133
- \\"DD_SERVICE\\": \\"middletier\\",
134
- \\"DD_TRACE_ENABLED\\": \\"true\\",
135
- \\"DD_VERSION\\": \\"0.2\\",
136
- \\"DD_LOG_LEVEL\\": \\"debug\\"
137
- }
138
- },
139
- \\"Layers\\": [
140
- \\"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node12-x:10\\"
141
- ]
142
- }
143
- TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
144
- {
145
- \\"dd_sls_ci\\": \\"v${version}\\"
146
- }
147
- "
148
- `);
92
+ "${chalk_1.bold(chalk_1.yellow('[Warning]'))} Instrument your ${chalk_1.hex('#FF9900').bold('Lambda')} functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`${chalk_1.bold('uninstrument')}\` with the same arguments to revert the changes.
93
+ \n${chalk_1.bold(chalk_1.yellow('[!]'))} Functions to be updated:
94
+ \t- ${chalk_1.bold('arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world')}\n
95
+ ${chalk_1.bold(chalk_1.cyan('[Dry Run] '))}Will apply the following updates:
96
+ UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
97
+ {
98
+ \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\\",
99
+ \\"Handler\\": \\"/opt/nodejs/node_modules/datadog-lambda-js/handler.handler\\",
100
+ \\"Environment\\": {
101
+ \\"Variables\\": {
102
+ \\"DD_LAMBDA_HANDLER\\": \\"index.handler\\",
103
+ \\"DD_SITE\\": \\"datadoghq.com\\",
104
+ \\"DD_ENV\\": \\"staging\\",
105
+ \\"DD_TAGS\\": \\"layer:api,team:intake\\",
106
+ \\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
107
+ \\"DD_SERVICE\\": \\"middletier\\",
108
+ \\"DD_TRACE_ENABLED\\": \\"true\\",
109
+ \\"DD_VERSION\\": \\"0.2\\",
110
+ \\"DD_FLUSH_TO_LOG\\": \\"true\\",
111
+ \\"DD_LOG_LEVEL\\": \\"debug\\"
112
+ }
113
+ },
114
+ \\"Layers\\": [
115
+ \\"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node12-x:10\\"
116
+ ]
117
+ }
118
+ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
119
+ {
120
+ \\"dd_sls_ci\\": \\"v${version}\\"
121
+ }
122
+ "
123
+ `);
149
124
  }));
150
125
  test('prints dry run data for lambda extension layer', () => __awaiter(void 0, void 0, void 0, function* () {
151
126
  ;
152
127
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
153
- aws_sdk_1.Lambda.mockImplementation(() => makeMockLambda({
128
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
154
129
  'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
155
130
  FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
156
131
  Handler: 'index.handler',
157
132
  Runtime: 'nodejs12.x',
158
133
  },
159
134
  }));
160
- const cli = makeCli();
161
- const context = createMockContext();
135
+ const cli = fixtures_1.makeCli();
136
+ const context = fixtures_1.createMockContext();
162
137
  const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
163
138
  process.env.DATADOG_API_KEY = '1234';
164
139
  const code = yield cli.run([
@@ -181,40 +156,259 @@ describe('lambda', () => {
181
156
  const output = context.stdout.toString();
182
157
  expect(code).toBe(0);
183
158
  expect(output).toMatchInlineSnapshot(`
184
- "[Dry Run] Will apply the following updates:
185
- UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
186
- {
187
- \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\\",
188
- \\"Handler\\": \\"/opt/nodejs/node_modules/datadog-lambda-js/handler.handler\\",
189
- \\"Environment\\": {
190
- \\"Variables\\": {
191
- \\"DD_LAMBDA_HANDLER\\": \\"index.handler\\",
192
- \\"DD_API_KEY\\": \\"1234\\",
193
- \\"DD_SITE\\": \\"datadoghq.com\\",
194
- \\"DD_ENV\\": \\"staging\\",
195
- \\"DD_TAGS\\": \\"layer:api,team:intake\\",
196
- \\"DD_FLUSH_TO_LOG\\": \\"true\\",
197
- \\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
198
- \\"DD_SERVICE\\": \\"middletier\\",
199
- \\"DD_TRACE_ENABLED\\": \\"true\\",
200
- \\"DD_VERSION\\": \\"0.2\\"
201
- }
202
- },
203
- \\"Layers\\": [
204
- \\"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:6\\"
205
- ]
206
- }
207
- TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
208
- {
209
- \\"dd_sls_ci\\": \\"v${version}\\"
210
- }
211
- "
212
- `);
159
+ "${chalk_1.bold(chalk_1.yellow('[Warning]'))} Instrument your ${chalk_1.hex('#FF9900').bold('Lambda')} functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`${chalk_1.bold('uninstrument')}\` with the same arguments to revert the changes.
160
+ \n${chalk_1.bold(chalk_1.yellow('[!]'))} Functions to be updated:
161
+ \t- ${chalk_1.bold('arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world')}\n
162
+ ${chalk_1.bold(chalk_1.cyan('[Dry Run] '))}Will apply the following updates:
163
+ UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
164
+ {
165
+ \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\\",
166
+ \\"Handler\\": \\"/opt/nodejs/node_modules/datadog-lambda-js/handler.handler\\",
167
+ \\"Environment\\": {
168
+ \\"Variables\\": {
169
+ \\"DD_LAMBDA_HANDLER\\": \\"index.handler\\",
170
+ \\"DD_API_KEY\\": \\"1234\\",
171
+ \\"DD_SITE\\": \\"datadoghq.com\\",
172
+ \\"DD_ENV\\": \\"staging\\",
173
+ \\"DD_TAGS\\": \\"layer:api,team:intake\\",
174
+ \\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
175
+ \\"DD_SERVICE\\": \\"middletier\\",
176
+ \\"DD_TRACE_ENABLED\\": \\"true\\",
177
+ \\"DD_VERSION\\": \\"0.2\\"
178
+ }
179
+ },
180
+ \\"Layers\\": [
181
+ \\"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:6\\"
182
+ ]
183
+ }
184
+ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
185
+ {
186
+ \\"dd_sls_ci\\": \\"v${version}\\"
187
+ }
188
+ "
189
+ `);
190
+ }));
191
+ test('instrumenting with source code integrations fails if not run within a git repo', () => __awaiter(void 0, void 0, void 0, function* () {
192
+ ;
193
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
194
+ const lambda = fixtures_1.makeMockLambda({
195
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
196
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
197
+ Handler: 'index.handler',
198
+ Runtime: 'nodejs12.x',
199
+ },
200
+ });
201
+ aws_sdk_1.Lambda.mockImplementation(() => lambda);
202
+ process.env.DATADOG_API_KEY = '1234';
203
+ const cli = fixtures_1.makeCli();
204
+ const context = fixtures_1.createMockContext();
205
+ yield cli.run([
206
+ 'lambda',
207
+ 'instrument',
208
+ '--function',
209
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
210
+ '--layerVersion',
211
+ '10',
212
+ '-s',
213
+ '--service',
214
+ 'dummy',
215
+ '--env',
216
+ 'dummy',
217
+ '--version',
218
+ '0.1',
219
+ ], context);
220
+ const output = context.stdout.toString();
221
+ expect(output).toMatch(/.*Make sure the command is running within your git repository\..*/i);
222
+ }));
223
+ test('instrumenting with source code integrations fails if DATADOG_API_KEY is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
224
+ ;
225
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
226
+ const lambda = fixtures_1.makeMockLambda({
227
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
228
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
229
+ Handler: 'index.handler',
230
+ Runtime: 'nodejs12.x',
231
+ },
232
+ });
233
+ aws_sdk_1.Lambda.mockImplementation(() => lambda);
234
+ const cli = fixtures_1.makeCli();
235
+ const context = fixtures_1.createMockContext();
236
+ yield cli.run([
237
+ 'lambda',
238
+ 'instrument',
239
+ '--function',
240
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
241
+ '--layerVersion',
242
+ '10',
243
+ '-s',
244
+ '--service',
245
+ 'dummy',
246
+ '--env',
247
+ 'dummy',
248
+ '--version',
249
+ '0.1',
250
+ ], context);
251
+ const output = context.stdout.toString();
252
+ expect(output).toMatch(/.*Missing DATADOG_API_KEY in your environment.*/i);
253
+ }));
254
+ test('ensure the instrument command ran from a dirty git repo fails', () => __awaiter(void 0, void 0, void 0, function* () {
255
+ ;
256
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
257
+ const lambda = fixtures_1.makeMockLambda({
258
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
259
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
260
+ Handler: 'index.handler',
261
+ Runtime: 'nodejs12.x',
262
+ },
263
+ });
264
+ aws_sdk_1.Lambda.mockImplementation(() => lambda);
265
+ process.env.DATADOG_API_KEY = '1234';
266
+ const context = fixtures_1.createMockContext();
267
+ const instrumentCommand = instrument_1.InstrumentCommand;
268
+ const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
269
+ mockGitStatus.mockImplementation(() => ({
270
+ ahead: 0,
271
+ isClean: false,
272
+ }));
273
+ const cli = new advanced_1.Cli();
274
+ cli.register(instrumentCommand);
275
+ yield cli.run([
276
+ 'lambda',
277
+ 'instrument',
278
+ '--function',
279
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
280
+ '--layerVersion',
281
+ '10',
282
+ '-s',
283
+ '--service',
284
+ 'dummy',
285
+ '--env',
286
+ 'dummy',
287
+ '--version',
288
+ '0.1',
289
+ ], context);
290
+ const output = context.stdout.toString();
291
+ expect(output).toMatch('Error: Local git repository is dirty');
292
+ }));
293
+ test('ensure source code integration flag works from a clean repo', () => __awaiter(void 0, void 0, void 0, function* () {
294
+ ;
295
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
296
+ const lambda = fixtures_1.makeMockLambda({
297
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
298
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
299
+ Handler: 'index.handler',
300
+ Runtime: 'nodejs12.x',
301
+ },
302
+ });
303
+ aws_sdk_1.Lambda.mockImplementation(() => lambda);
304
+ process.env.DATADOG_API_KEY = '1234';
305
+ const context = fixtures_1.createMockContext();
306
+ const instrumentCommand = instrument_1.InstrumentCommand;
307
+ const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
308
+ mockGitStatus.mockImplementation(() => ({
309
+ ahead: 0,
310
+ hash: '1be168ff837f043bde17c0314341c84271047b31',
311
+ isClean: true,
312
+ }));
313
+ const mockUploadFunction = jest.spyOn(instrumentCommand.prototype, 'uploadGitData');
314
+ mockUploadFunction.mockImplementation(() => {
315
+ return;
316
+ });
317
+ const cli = new advanced_1.Cli();
318
+ cli.register(instrumentCommand);
319
+ yield cli.run([
320
+ 'lambda',
321
+ 'instrument',
322
+ '--function',
323
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
324
+ '--layerVersion',
325
+ '10',
326
+ '-s',
327
+ '--service',
328
+ 'dummy',
329
+ '--env',
330
+ 'dummy',
331
+ '--version',
332
+ '0.1',
333
+ ], context);
334
+ const output = context.stdout.toString();
335
+ expect(output).toMatchInlineSnapshot(`
336
+ "${chalk_1.bold(chalk_1.yellow('[Warning]'))} Instrument your ${chalk_1.hex('#FF9900').bold('Lambda')} functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`${chalk_1.bold('uninstrument')}\` with the same arguments to revert the changes.
337
+ \n${chalk_1.bold(chalk_1.yellow('[!]'))} Functions to be updated:
338
+ \t- ${chalk_1.bold('arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world')}\n
339
+ Will apply the following updates:
340
+ UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
341
+ {
342
+ \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\\",
343
+ \\"Handler\\": \\"/opt/nodejs/node_modules/datadog-lambda-js/handler.handler\\",
344
+ \\"Environment\\": {
345
+ \\"Variables\\": {
346
+ \\"DD_LAMBDA_HANDLER\\": \\"index.handler\\",
347
+ \\"DD_API_KEY\\": \\"1234\\",
348
+ \\"DD_SITE\\": \\"datadoghq.com\\",
349
+ \\"DD_ENV\\": \\"dummy\\",
350
+ \\"DD_TAGS\\": \\"git.commit.sha:1be168ff837f043bde17c0314341c84271047b31\\",
351
+ \\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
352
+ \\"DD_SERVICE\\": \\"dummy\\",
353
+ \\"DD_TRACE_ENABLED\\": \\"true\\",
354
+ \\"DD_VERSION\\": \\"0.1\\",
355
+ \\"DD_FLUSH_TO_LOG\\": \\"true\\"
356
+ }
357
+ },
358
+ \\"Layers\\": [
359
+ \\"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node12-x:10\\"
360
+ ]
361
+ }
362
+ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
363
+ {
364
+ \\"dd_sls_ci\\": \\"v${version}\\"
365
+ }
366
+ "
367
+ `);
368
+ }));
369
+ test('ensure the instrument command ran from a local git repo ahead of the origin fails', () => __awaiter(void 0, void 0, void 0, function* () {
370
+ ;
371
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
372
+ const lambda = fixtures_1.makeMockLambda({
373
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
374
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
375
+ Handler: 'index.handler',
376
+ Runtime: 'nodejs12.x',
377
+ },
378
+ });
379
+ aws_sdk_1.Lambda.mockImplementation(() => lambda);
380
+ process.env.DATADOG_API_KEY = '1234';
381
+ const context = fixtures_1.createMockContext();
382
+ const instrumentCommand = instrument_1.InstrumentCommand;
383
+ const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
384
+ mockGitStatus.mockImplementation(() => ({
385
+ ahead: 1,
386
+ isClean: true,
387
+ }));
388
+ const cli = new advanced_1.Cli();
389
+ cli.register(instrumentCommand);
390
+ yield cli.run([
391
+ 'lambda',
392
+ 'instrument',
393
+ '--function',
394
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
395
+ '--layerVersion',
396
+ '10',
397
+ '-s',
398
+ '--service',
399
+ 'dummy',
400
+ '--env',
401
+ 'dummy',
402
+ '--version',
403
+ '0.1',
404
+ ], context);
405
+ const output = context.stdout.toString();
406
+ expect(output).toMatch('Error: Local changes have not been pushed remotely. Aborting git upload.');
213
407
  }));
214
408
  test('runs function update command for lambda library layer', () => __awaiter(void 0, void 0, void 0, function* () {
215
409
  ;
216
410
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
217
- const lambda = makeMockLambda({
411
+ const lambda = fixtures_1.makeMockLambda({
218
412
  'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
219
413
  FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
220
414
  Handler: 'index.handler',
@@ -222,8 +416,8 @@ describe('lambda', () => {
222
416
  },
223
417
  });
224
418
  aws_sdk_1.Lambda.mockImplementation(() => lambda);
225
- const cli = makeCli();
226
- const context = createMockContext();
419
+ const cli = fixtures_1.makeCli();
420
+ const context = fixtures_1.createMockContext();
227
421
  yield cli.run([
228
422
  'lambda',
229
423
  'instrument',
@@ -237,7 +431,7 @@ describe('lambda', () => {
237
431
  test('runs function update command for lambda extension layer', () => __awaiter(void 0, void 0, void 0, function* () {
238
432
  ;
239
433
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
240
- const lambda = makeMockLambda({
434
+ const lambda = fixtures_1.makeMockLambda({
241
435
  'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
242
436
  FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
243
437
  Handler: 'index.handler',
@@ -245,8 +439,8 @@ describe('lambda', () => {
245
439
  },
246
440
  });
247
441
  aws_sdk_1.Lambda.mockImplementation(() => lambda);
248
- const cli = makeCli();
249
- const context = createMockContext();
442
+ const cli = fixtures_1.makeCli();
443
+ const context = fixtures_1.createMockContext();
250
444
  process.env.DATADOG_API_KEY = '1234';
251
445
  yield cli.run([
252
446
  'lambda',
@@ -261,9 +455,9 @@ describe('lambda', () => {
261
455
  test('aborts early when no functions are specified', () => __awaiter(void 0, void 0, void 0, function* () {
262
456
  ;
263
457
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
264
- aws_sdk_1.Lambda.mockImplementation(() => makeMockLambda({}));
265
- const cli = makeCli();
266
- const context = createMockContext();
458
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({}));
459
+ const cli = fixtures_1.makeCli();
460
+ const context = fixtures_1.createMockContext();
267
461
  const code = yield cli.run([
268
462
  'lambda',
269
463
  'instrument',
@@ -287,7 +481,7 @@ describe('lambda', () => {
287
481
  ;
288
482
  fs.readFile.mockImplementation((a, b, callback) => callback({}));
289
483
  process.env = {};
290
- const command = createCommand();
484
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
291
485
  command['config']['layerVersion'] = '60';
292
486
  command['config']['extensionVersion'] = '10';
293
487
  command['config']['region'] = 'ap-southeast-1';
@@ -304,9 +498,9 @@ describe('lambda', () => {
304
498
  test("aborts early when function regions can't be found", () => __awaiter(void 0, void 0, void 0, function* () {
305
499
  ;
306
500
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
307
- aws_sdk_1.Lambda.mockImplementation(() => makeMockLambda({}));
308
- const cli = makeCli();
309
- const context = createMockContext();
501
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({}));
502
+ const cli = fixtures_1.makeCli();
503
+ const context = fixtures_1.createMockContext();
310
504
  const code = yield cli.run([
311
505
  'lambda',
312
506
  'instrument',
@@ -323,15 +517,12 @@ describe('lambda', () => {
323
517
  ], context);
324
518
  const output = context.stdout.toString();
325
519
  expect(code).toBe(1);
326
- expect(output).toMatchInlineSnapshot(`
327
- "'No default region specified for [\\"my-func\\"]. Use -r,--region, or use a full functionARN
328
- "
329
- `);
520
+ expect(output).toMatch(`Couldn't group functions. Error: No default region specified for ["my-func"]. Use -r, --region, or use a full functionARN\n`);
330
521
  }));
331
522
  test('aborts if a function is not in an Active state with LastUpdateStatus Successful', () => __awaiter(void 0, void 0, void 0, function* () {
332
523
  ;
333
524
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
334
- aws_sdk_1.Lambda.mockImplementation(() => makeMockLambda({
525
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
335
526
  'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
336
527
  FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
337
528
  Handler: 'index.handler',
@@ -340,8 +531,8 @@ describe('lambda', () => {
340
531
  State: 'Failed',
341
532
  },
342
533
  }));
343
- const cli = makeCli();
344
- const context = createMockContext();
534
+ const cli = fixtures_1.makeCli();
535
+ const context = fixtures_1.createMockContext();
345
536
  const code = yield cli.run([
346
537
  'lambda',
347
538
  'instrument',
@@ -366,9 +557,9 @@ describe('lambda', () => {
366
557
  test('aborts early when extensionVersion and forwarder are set', () => __awaiter(void 0, void 0, void 0, function* () {
367
558
  ;
368
559
  fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
369
- aws_sdk_1.Lambda.mockImplementation(() => makeMockLambda({}));
370
- const cli = makeCli();
371
- const context = createMockContext();
560
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({}));
561
+ const cli = fixtures_1.makeCli();
562
+ const context = fixtures_1.createMockContext();
372
563
  const code = yield cli.run([
373
564
  'lambda',
374
565
  'instrument',
@@ -398,7 +589,7 @@ describe('lambda', () => {
398
589
  ;
399
590
  fs.readFile.mockImplementation((a, b, callback) => callback({}));
400
591
  process.env = {};
401
- const command = createCommand();
592
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
402
593
  command['config']['layerVersion'] = '60';
403
594
  command['config']['extensionVersion'] = '10';
404
595
  command['config']['region'] = 'ap-southeast-1';
@@ -410,7 +601,7 @@ describe('lambda', () => {
410
601
  ;
411
602
  fs.readFile.mockImplementation((a, b, callback) => callback({}));
412
603
  process.env = {};
413
- let command = createCommand();
604
+ let command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
414
605
  command['config']['environment'] = 'staging';
415
606
  command['config']['service'] = 'middletier';
416
607
  command['config']['version'] = '2';
@@ -420,7 +611,7 @@ describe('lambda', () => {
420
611
  yield command['execute']();
421
612
  let output = command.context.stdout.toString();
422
613
  expect(output).toMatch('Functions in config file and "--functions-regex" should not be used at the same time.\n');
423
- command = createCommand();
614
+ command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
424
615
  command['environment'] = 'staging';
425
616
  command['service'] = 'middletier';
426
617
  command['version'] = '2';
@@ -435,7 +626,7 @@ describe('lambda', () => {
435
626
  ;
436
627
  fs.readFile.mockImplementation((a, b, callback) => callback({}));
437
628
  process.env = {};
438
- const command = createCommand();
629
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
439
630
  command['environment'] = 'staging';
440
631
  command['service'] = 'middletier';
441
632
  command['version'] = '2';
@@ -449,7 +640,7 @@ describe('lambda', () => {
449
640
  describe('getSettings', () => {
450
641
  test('uses config file settings', () => {
451
642
  process.env = {};
452
- const command = createCommand();
643
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
453
644
  command['config']['flushMetricsToLogs'] = 'false';
454
645
  command['config']['forwarder'] = 'my-forwarder';
455
646
  command['config']['layerVersion'] = '2';
@@ -459,19 +650,23 @@ describe('lambda', () => {
459
650
  command['config']['tracing'] = 'false';
460
651
  command['config']['logLevel'] = 'debug';
461
652
  expect(command['getSettings']()).toEqual({
653
+ environment: undefined,
462
654
  extensionVersion: 6,
655
+ extraTags: undefined,
463
656
  flushMetricsToLogs: false,
464
657
  forwarderARN: 'my-forwarder',
465
658
  layerAWSAccount: 'another-account',
466
659
  layerVersion: 2,
467
660
  logLevel: 'debug',
468
661
  mergeXrayTraces: false,
662
+ service: undefined,
469
663
  tracingEnabled: false,
664
+ version: undefined,
470
665
  });
471
666
  });
472
667
  test('prefers command line arguments over config file', () => {
473
668
  process.env = {};
474
- const command = createCommand();
669
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
475
670
  command['forwarder'] = 'my-forwarder';
476
671
  command['config']['forwarder'] = 'another-forwarder';
477
672
  command['layerVersion'] = '1';
@@ -498,7 +693,7 @@ describe('lambda', () => {
498
693
  });
499
694
  test("returns undefined when layer version can't be parsed", () => {
500
695
  process.env = {};
501
- const command = createCommand();
696
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
502
697
  command.context = {
503
698
  stdout: { write: jest.fn() },
504
699
  };
@@ -507,7 +702,7 @@ describe('lambda', () => {
507
702
  });
508
703
  test("returns undefined when extension version can't be parsed", () => {
509
704
  process.env = {};
510
- const command = createCommand();
705
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
511
706
  command.context = {
512
707
  stdout: { write: jest.fn() },
513
708
  };
@@ -516,7 +711,7 @@ describe('lambda', () => {
516
711
  });
517
712
  test('converts string boolean from command line and config file correctly', () => {
518
713
  process.env = {};
519
- const command = createCommand();
714
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
520
715
  const validSettings = {
521
716
  extensionVersion: undefined,
522
717
  flushMetricsToLogs: false,
@@ -555,12 +750,12 @@ describe('lambda', () => {
555
750
  'tracing',
556
751
  ];
557
752
  for (const option of stringBooleans) {
558
- let command = createCommand();
753
+ let command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
559
754
  command['config'][option] = 'NotBoolean';
560
755
  command['getSettings']();
561
756
  let output = command.context.stdout.toString();
562
757
  expect(output).toMatch(`Invalid boolean specified for ${option}.\n`);
563
- command = createCommand();
758
+ command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
564
759
  command[option] = 'NotBoolean';
565
760
  command['getSettings']();
566
761
  output = command.context.stdout.toString();
@@ -571,26 +766,26 @@ describe('lambda', () => {
571
766
  ;
572
767
  fs.readFile.mockImplementation((a, b, callback) => callback({}));
573
768
  process.env = {};
574
- let command = createCommand();
769
+ let command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
575
770
  command['config']['region'] = 'ap-southeast-1';
576
771
  command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
577
772
  yield command['getSettings']();
578
773
  let output = command.context.stdout.toString();
579
- expect(output).toMatch('Warning: The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.\n');
580
- command = createCommand();
774
+ expect(output).toMatch(`${chalk_1.bold(chalk_1.yellow('[Warning]'))} The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: ${chalk_1.underline(chalk_1.blueBright('https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.'))}\n`);
775
+ command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
581
776
  command['config']['region'] = 'ap-southeast-1';
582
777
  command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
583
778
  command['config']['environment'] = 'b';
584
779
  command['config']['service'] = 'middletier';
585
780
  yield command['getSettings']();
586
781
  output = command.context.stdout.toString();
587
- expect(output).toMatch('Warning: The version tag has not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.\n');
782
+ expect(output).toMatch(`${chalk_1.bold(chalk_1.yellow('[Warning]'))} The version tag has not been configured. Learn more about Datadog unified service tagging: ${chalk_1.underline(chalk_1.blueBright('https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.'))}\n`);
588
783
  }));
589
784
  test('aborts early if extraTags do not comply with expected key:value list', () => __awaiter(void 0, void 0, void 0, function* () {
590
785
  ;
591
786
  fs.readFile.mockImplementation((a, b, callback) => callback({}));
592
787
  process.env = {};
593
- const command = createCommand();
788
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
594
789
  command['config']['region'] = 'ap-southeast-1';
595
790
  command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
596
791
  command['config']['service'] = 'middletier';
@@ -602,88 +797,25 @@ describe('lambda', () => {
602
797
  expect(output).toMatch('Extra tags do not comply with the <key>:<value> array.\n');
603
798
  }));
604
799
  });
605
- describe('collectFunctionsByRegion', () => {
606
- test('groups functions with region read from arn', () => {
607
- process.env = {};
608
- const command = createCommand();
609
- command['functions'] = [
610
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
611
- 'arn:aws:lambda:us-east-1:123456789012:function:another',
612
- 'arn:aws:lambda:us-east-2:123456789012:function:third-func',
613
- ];
614
- expect(command['collectFunctionsByRegion']()).toEqual({
615
- 'us-east-1': [
616
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
617
- 'arn:aws:lambda:us-east-1:123456789012:function:another',
618
- ],
619
- 'us-east-2': ['arn:aws:lambda:us-east-2:123456789012:function:third-func'],
620
- });
621
- });
622
- test('groups functions in the config object', () => {
623
- process.env = {};
624
- const command = createCommand();
625
- command['config'].functions = [
626
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
627
- 'arn:aws:lambda:us-east-1:123456789012:function:another',
628
- 'arn:aws:lambda:us-east-2:123456789012:function:third-func',
629
- ];
630
- expect(command['collectFunctionsByRegion']()).toEqual({
631
- 'us-east-1': [
632
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
633
- 'arn:aws:lambda:us-east-1:123456789012:function:another',
634
- ],
635
- 'us-east-2': ['arn:aws:lambda:us-east-2:123456789012:function:third-func'],
636
- });
637
- });
638
- test('uses default region for functions not in arn format', () => {
639
- process.env = {};
640
- const command = createCommand();
641
- command['functions'] = [
642
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
643
- 'arn:aws:lambda:*:123456789012:function:func-with-wildcard',
644
- 'func-without-region',
645
- 'arn:aws:lambda:us-east-2:123456789012:function:third-func',
646
- ];
647
- command['region'] = 'ap-south-1';
648
- expect(command['collectFunctionsByRegion']()).toEqual({
649
- 'ap-south-1': ['arn:aws:lambda:*:123456789012:function:func-with-wildcard', 'func-without-region'],
650
- 'us-east-1': ['arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world'],
651
- 'us-east-2': ['arn:aws:lambda:us-east-2:123456789012:function:third-func'],
652
- });
653
- });
654
- test('fails to collect when there are regionless functions and no default region is set', () => {
655
- process.env = {};
656
- const command = createCommand();
657
- command['functions'] = [
658
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
659
- 'arn:aws:lambda:*:123456789012:function:func-with-wildcard',
660
- 'func-without-region',
661
- 'arn:aws:lambda:us-east-2:123456789012:function:third-func',
662
- ];
663
- command['region'] = undefined;
664
- command['config']['region'] = undefined;
665
- expect(command['collectFunctionsByRegion']()).toBeUndefined();
666
- });
667
- });
668
800
  describe('printPlannedActions', () => {
669
801
  test('prints no output when list is empty', () => {
670
802
  process.env = {};
671
- const command = createCommand();
803
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
672
804
  command['printPlannedActions']([]);
673
805
  const output = command.context.stdout.toString();
674
806
  expect(output).toMatchInlineSnapshot(`
675
- "No updates will be applied
807
+ "
808
+ No updates will be applied
676
809
  "
677
810
  `);
678
811
  });
679
812
  test('prints log group actions', () => {
680
813
  process.env = {};
681
- const command = createCommand();
814
+ const command = fixtures_1.createCommand(instrument_1.InstrumentCommand);
682
815
  command['printPlannedActions']([
683
816
  {
684
817
  functionARN: 'my-func',
685
818
  lambdaConfig: {},
686
- lambdaLibraryLayerArn: 'my-layer',
687
819
  logGroupConfiguration: {
688
820
  createLogGroupRequest: { logGroupName: 'my-log-group' },
689
821
  deleteSubscriptionFilterRequest: { filterName: 'my-filter' },
@@ -694,39 +826,24 @@ describe('lambda', () => {
694
826
  ]);
695
827
  const output = command.context.stdout.toString();
696
828
  expect(output).toMatchInlineSnapshot(`
697
- "Will apply the following updates:
698
- CreateLogGroup -> my-log-group
699
- {
700
- \\"logGroupName\\": \\"my-log-group\\"
701
- }
702
- DeleteSubscriptionFilter -> my-log-group
703
- {
704
- \\"filterName\\": \\"my-filter\\"
705
- }
706
- PutSubscriptionFilter -> my-log-group
707
- {
708
- \\"filterName\\": \\"my-filter\\"
709
- }
710
- "
711
- `);
712
- });
713
- });
714
- describe('sentenceMatchesRegEx', () => {
715
- const tags = [
716
- ['not-complying:regex-should-fail', false],
717
- ['1first-char-is-number:should-fail', false],
718
- ['_also-not-complying:should-fail', false],
719
- ['complying_tag:accepted/with/slashes.and.dots,but-empty-tag', false],
720
- ['also_complying:success,1but_is_illegal:should-fail', false],
721
- ['this:complies,also_this_one:yes,numb3r_in_name:should-succeed,dots:al.lo.wed', true],
722
- ['complying_ip_address_4:192.342.3134.231', true],
723
- ['complying:alone', true],
724
- ['one_divided_by_two:1/2,one_divided_by_four:0.25,three_minus_one_half:3-1/2', true],
725
- ['this_is_a_valid_t4g:yes/it.is-42', true],
726
- ];
727
- test.each(tags)('check if the tags match the expected result from the regex', (tag, expectedResult) => {
728
- const result = !!instrument_1.sentenceMatchesRegEx(tag, constants_1.EXTRA_TAGS_REG_EXP);
729
- expect(result).toEqual(expectedResult);
829
+ "${chalk_1.bold(chalk_1.yellow('[Warning]'))} Instrument your ${chalk_1.hex('#FF9900').bold('Lambda')} functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`${chalk_1.bold('uninstrument')}\` with the same arguments to revert the changes.
830
+ \n${chalk_1.bold(chalk_1.yellow('[!]'))} Functions to be updated:
831
+ \t- ${chalk_1.bold('my-func')}\n
832
+ Will apply the following updates:
833
+ CreateLogGroup -> my-log-group
834
+ {
835
+ \\"logGroupName\\": \\"my-log-group\\"
836
+ }
837
+ DeleteSubscriptionFilter -> my-log-group
838
+ {
839
+ \\"filterName\\": \\"my-filter\\"
840
+ }
841
+ PutSubscriptionFilter -> my-log-group
842
+ {
843
+ \\"filterName\\": \\"my-filter\\"
844
+ }
845
+ "
846
+ `);
730
847
  });
731
848
  });
732
849
  });