@datadog/datadog-ci 0.17.6-alpha → 0.17.9
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/LICENSE-3rdparty.csv +1 -0
- package/dist/commands/dependencies/__tests__/helpers/context.d.ts +12 -0
- package/dist/commands/dependencies/__tests__/helpers/stream.d.ts +2 -0
- package/dist/commands/dependencies/__tests__/helpers/upload.run.d.ts +13 -0
- package/dist/commands/dependencies/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/dependencies/api.d.ts +2 -0
- package/dist/commands/dependencies/index.d.ts +1 -0
- package/dist/commands/dependencies/interfaces.d.ts +10 -0
- package/dist/commands/dependencies/renderer.d.ts +13 -0
- package/dist/commands/dependencies/upload.d.ts +16 -0
- package/dist/commands/dsyms/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/dsyms/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/dsyms/index.d.ts +1 -0
- package/dist/commands/dsyms/interfaces.d.ts +7 -0
- package/dist/commands/dsyms/renderer.d.ts +9 -0
- package/dist/commands/dsyms/upload.d.ts +11 -0
- package/dist/commands/dsyms/utils.d.ts +9 -0
- package/dist/commands/git-metadata/__tests__/git.test.d.ts +1 -0
- package/dist/commands/{commit → git-metadata}/__tests__/git.test.js +0 -0
- package/dist/commands/git-metadata/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/{commit → git-metadata}/__tests__/upload.test.js +1 -1
- package/dist/commands/git-metadata/api.d.ts +3 -0
- package/dist/commands/{commit → git-metadata}/api.js +0 -0
- package/dist/commands/git-metadata/git.d.ts +8 -0
- package/dist/commands/{commit → git-metadata}/git.js +0 -0
- package/dist/commands/git-metadata/index.d.ts +1 -0
- package/dist/commands/{commit → git-metadata}/index.js +0 -0
- package/dist/commands/git-metadata/interfaces.d.ts +9 -0
- package/dist/commands/{commit → git-metadata}/interfaces.js +0 -0
- package/dist/commands/git-metadata/renderer.d.ts +8 -0
- package/dist/commands/{commit → git-metadata}/renderer.js +5 -8
- package/dist/commands/git-metadata/upload.d.ts +12 -0
- package/dist/commands/{commit → git-metadata}/upload.js +8 -3
- package/dist/commands/junit/__tests__/api.test.d.ts +1 -0
- package/dist/commands/junit/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/junit/api.d.ts +8 -0
- package/dist/commands/junit/index.d.ts +1 -0
- package/dist/commands/junit/interfaces.d.ts +12 -0
- package/dist/commands/junit/renderer.d.ts +8 -0
- package/dist/commands/junit/upload.d.ts +15 -0
- package/dist/commands/junit/upload.js +8 -25
- package/dist/commands/junit/utils.d.ts +1 -0
- package/dist/commands/lambda/__tests__/fixtures.d.ts +42 -0
- package/dist/commands/lambda/__tests__/fixtures.js +73 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.js +171 -0
- package/dist/commands/lambda/__tests__/functions/instrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/{function.test.js → functions/instrument.test.js} +355 -417
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +298 -0
- package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/instrument.test.js +270 -163
- package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/loggroup.test.js +98 -34
- package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/tags.test.js +107 -31
- package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js +223 -0
- package/dist/commands/lambda/constants.d.ts +44 -0
- package/dist/commands/lambda/constants.js +2 -1
- package/dist/commands/lambda/functions/commons.d.ts +71 -0
- package/dist/commands/lambda/functions/commons.js +170 -0
- package/dist/commands/lambda/functions/instrument.d.ts +16 -0
- package/dist/commands/lambda/{function.js → functions/instrument.js} +42 -102
- package/dist/commands/lambda/functions/uninstrument.d.ts +6 -0
- package/dist/commands/lambda/functions/uninstrument.js +110 -0
- package/dist/commands/lambda/index.d.ts +1 -0
- package/dist/commands/lambda/index.js +2 -1
- package/dist/commands/lambda/instrument.d.ts +29 -0
- package/dist/commands/lambda/instrument.js +85 -40
- package/dist/commands/lambda/interfaces.d.ts +70 -0
- package/dist/commands/lambda/loggroup.d.ts +14 -0
- package/dist/commands/lambda/loggroup.js +27 -4
- package/dist/commands/lambda/tags.d.ts +6 -0
- package/dist/commands/lambda/tags.js +19 -3
- package/dist/commands/lambda/uninstrument.d.ts +11 -0
- package/dist/commands/lambda/uninstrument.js +127 -0
- package/dist/commands/sourcemaps/__tests__/git.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/sourcemaps/git.d.ts +20 -0
- package/dist/commands/sourcemaps/index.d.ts +1 -0
- package/dist/commands/sourcemaps/interfaces.d.ts +15 -0
- package/dist/commands/sourcemaps/renderer.d.ts +12 -0
- package/dist/commands/sourcemaps/upload.d.ts +25 -0
- package/dist/commands/sourcemaps/utils.d.ts +3 -0
- package/dist/commands/sourcemaps/validation.d.ts +6 -0
- package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.js +232 -0
- package/dist/commands/synthetics/__tests__/crypto.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/fixtures.d.ts +71 -0
- package/dist/commands/synthetics/__tests__/fixtures.js +17 -2
- package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.js +5 -4
- package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/run-test.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/run-test.test.js +48 -319
- package/dist/commands/synthetics/__tests__/tunnel.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils.test.js +13 -1
- package/dist/commands/synthetics/__tests__/websocket.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/websocket.test.js +6 -5
- package/dist/commands/synthetics/api.d.ts +24 -0
- package/dist/commands/synthetics/cli.d.ts +26 -0
- package/dist/commands/synthetics/cli.js +229 -0
- package/dist/commands/synthetics/crypto.d.ts +5 -0
- package/dist/commands/synthetics/errors.d.ts +9 -0
- package/dist/commands/synthetics/errors.js +25 -0
- package/dist/commands/synthetics/index.d.ts +1 -0
- package/dist/commands/synthetics/index.js +2 -2
- package/dist/commands/synthetics/interfaces.d.ts +342 -0
- package/dist/commands/synthetics/reporters/default.d.ts +18 -0
- package/dist/commands/synthetics/reporters/default.js +4 -3
- package/dist/commands/synthetics/reporters/junit.d.ts +95 -0
- package/dist/commands/synthetics/run-test.d.ts +74 -0
- package/dist/commands/synthetics/run-test.js +135 -319
- package/dist/commands/synthetics/tunnel.d.ts +43 -0
- package/dist/commands/synthetics/utils.d.ts +27 -0
- package/dist/commands/synthetics/utils.js +24 -5
- package/dist/commands/synthetics/websocket.d.ts +38 -0
- package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
- package/dist/commands/trace/api.d.ts +6 -0
- package/dist/commands/trace/index.d.ts +1 -0
- package/dist/commands/trace/interfaces.d.ts +23 -0
- package/dist/commands/trace/trace.d.ts +17 -0
- package/dist/commands/trace/trace.js +32 -3
- package/dist/helpers/__tests__/ci.test.d.ts +1 -0
- package/dist/helpers/__tests__/ci.test.js +23 -0
- package/dist/helpers/__tests__/git.test.d.ts +1 -0
- package/dist/helpers/__tests__/retry.test.d.ts +1 -0
- package/dist/helpers/__tests__/retry.test.js +98 -0
- package/dist/helpers/__tests__/tags.test.d.ts +1 -0
- package/dist/helpers/__tests__/upload.test.d.ts +1 -0
- package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
- package/dist/helpers/__tests__/utils.test.d.ts +1 -0
- package/dist/helpers/apikey.d.ts +14 -0
- package/dist/helpers/ci.d.ts +15 -0
- package/dist/helpers/ci.js +13 -6
- package/dist/helpers/errors.d.ts +2 -0
- package/dist/helpers/formatting.d.ts +5 -0
- package/dist/helpers/git.d.ts +2 -0
- package/dist/helpers/interfaces.d.ts +19 -0
- package/dist/helpers/metrics.d.ts +11 -0
- package/dist/helpers/retry.d.ts +2 -0
- package/dist/helpers/retry.js +38 -0
- package/dist/helpers/tags.d.ts +28 -0
- package/dist/helpers/upload.d.ts +44 -0
- package/dist/helpers/upload.js +4 -26
- package/dist/helpers/user-provided-git.d.ts +1 -0
- package/dist/helpers/utils.d.ts +31 -0
- package/dist/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,30 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const constants_1 = require("../constants");
|
|
12
13
|
const loggroup_1 = require("../loggroup");
|
|
13
|
-
const
|
|
14
|
-
createLogGroup: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
15
|
-
deleteSubscriptionFilter: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
16
|
-
describeLogGroups: jest.fn().mockImplementation(({ logGroupNamePrefix }) => {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
const groups = (_b = (_a = logGroups[logGroupNamePrefix]) === null || _a === void 0 ? void 0 : _a.config) !== null && _b !== void 0 ? _b : { logGroups: [] };
|
|
19
|
-
return {
|
|
20
|
-
promise: () => Promise.resolve(groups),
|
|
21
|
-
};
|
|
22
|
-
}),
|
|
23
|
-
describeSubscriptionFilters: jest.fn().mockImplementation(({ logGroupName }) => {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
const groups = (_b = (_a = logGroups[logGroupName]) === null || _a === void 0 ? void 0 : _a.filters) !== null && _b !== void 0 ? _b : { subscriptionFilters: [] };
|
|
26
|
-
return {
|
|
27
|
-
promise: () => Promise.resolve(groups),
|
|
28
|
-
};
|
|
29
|
-
}),
|
|
30
|
-
putSubscriptionFilter: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
31
|
-
});
|
|
14
|
+
const fixtures_1 = require("./fixtures");
|
|
32
15
|
describe('loggroup', () => {
|
|
33
16
|
describe('calculateLogGroupUpdateRequest', () => {
|
|
34
17
|
test("creates a new log group when one doesn't exist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
const logs =
|
|
18
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({});
|
|
36
19
|
const result = yield loggroup_1.calculateLogGroupUpdateRequest(logs, '/aws/lambda/my-func', 'my-forwarder');
|
|
37
20
|
expect(result).toMatchInlineSnapshot(`
|
|
38
21
|
Object {
|
|
@@ -50,7 +33,7 @@ describe('loggroup', () => {
|
|
|
50
33
|
`);
|
|
51
34
|
}));
|
|
52
35
|
test("adds a subscription filter when one doesn't exist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const logs =
|
|
36
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
54
37
|
'/aws/lambda/my-func': {
|
|
55
38
|
config: {
|
|
56
39
|
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
@@ -72,7 +55,7 @@ describe('loggroup', () => {
|
|
|
72
55
|
`);
|
|
73
56
|
}));
|
|
74
57
|
test('updates a subscription filter when an owned one already exists', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
const logs =
|
|
58
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
76
59
|
'/aws/lambda/my-func': {
|
|
77
60
|
config: {
|
|
78
61
|
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
@@ -81,7 +64,7 @@ describe('loggroup', () => {
|
|
|
81
64
|
subscriptionFilters: [
|
|
82
65
|
{
|
|
83
66
|
destinationArn: 'wrong-destination',
|
|
84
|
-
filterName:
|
|
67
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
85
68
|
logGroupName: '/aws/lambda/my-func',
|
|
86
69
|
},
|
|
87
70
|
],
|
|
@@ -102,7 +85,7 @@ describe('loggroup', () => {
|
|
|
102
85
|
`);
|
|
103
86
|
}));
|
|
104
87
|
test('throws an exception when an unowned subscription filter exists', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
-
const logs =
|
|
88
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
106
89
|
'/aws/lambda/my-func': {
|
|
107
90
|
config: {
|
|
108
91
|
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
@@ -122,7 +105,7 @@ describe('loggroup', () => {
|
|
|
122
105
|
yield expect(promise).rejects.toEqual(Error('Unknown subscription filter already on log group /aws/lambda/my-func. Only one subscription is allowed.'));
|
|
123
106
|
}));
|
|
124
107
|
test("doesn't update a subscription when filter is already correct", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
-
const logs =
|
|
108
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
126
109
|
'/aws/lambda/my-func': {
|
|
127
110
|
config: {
|
|
128
111
|
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
@@ -131,7 +114,7 @@ describe('loggroup', () => {
|
|
|
131
114
|
subscriptionFilters: [
|
|
132
115
|
{
|
|
133
116
|
destinationArn: 'my-forwarder',
|
|
134
|
-
filterName:
|
|
117
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
135
118
|
logGroupName: '/aws/lambda/my-func',
|
|
136
119
|
},
|
|
137
120
|
],
|
|
@@ -142,21 +125,102 @@ describe('loggroup', () => {
|
|
|
142
125
|
expect(result).toMatchInlineSnapshot('undefined');
|
|
143
126
|
}));
|
|
144
127
|
});
|
|
128
|
+
describe('calculateLogGroupRemoveRequest', () => {
|
|
129
|
+
test('deletes the subscription filter that matches the forwarder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
131
|
+
'/aws/lambda/my-func': {
|
|
132
|
+
config: {
|
|
133
|
+
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
134
|
+
},
|
|
135
|
+
filters: {
|
|
136
|
+
subscriptionFilters: [
|
|
137
|
+
{
|
|
138
|
+
destinationArn: 'my-forwarder',
|
|
139
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
140
|
+
logGroupName: '/aws/lambda/my-func',
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
const result = yield loggroup_1.calculateLogGroupRemoveRequest(logs, '/aws/lambda/my-func', 'my-forwarder');
|
|
147
|
+
expect(result.deleteSubscriptionFilterRequest).toMatchInlineSnapshot(`
|
|
148
|
+
Object {
|
|
149
|
+
"filterName": "datadog-ci-filter",
|
|
150
|
+
"logGroupName": "/aws/lambda/my-func",
|
|
151
|
+
}
|
|
152
|
+
`);
|
|
153
|
+
}));
|
|
154
|
+
test('deletes the subscription filter that matches the datadog subscription filter constant name', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
156
|
+
'/aws/lambda/my-func': {
|
|
157
|
+
config: {
|
|
158
|
+
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
159
|
+
},
|
|
160
|
+
filters: {
|
|
161
|
+
subscriptionFilters: [
|
|
162
|
+
{
|
|
163
|
+
destinationArn: 'wrong-destination',
|
|
164
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
165
|
+
logGroupName: '/aws/lambda/my-func',
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
const result = yield loggroup_1.calculateLogGroupRemoveRequest(logs, '/aws/lambda/my-func', 'my-forwarder');
|
|
172
|
+
expect(result.deleteSubscriptionFilterRequest).toMatchInlineSnapshot(`
|
|
173
|
+
Object {
|
|
174
|
+
"filterName": "datadog-ci-filter",
|
|
175
|
+
"logGroupName": "/aws/lambda/my-func",
|
|
176
|
+
}
|
|
177
|
+
`);
|
|
178
|
+
}));
|
|
179
|
+
test('returns log group configuration without delete request when forwarder and filter name does not match', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({
|
|
181
|
+
'/aws/lambda/my-func': {
|
|
182
|
+
config: {
|
|
183
|
+
logGroups: [{ logGroupName: '/aws/lambda/my-func' }],
|
|
184
|
+
},
|
|
185
|
+
filters: {
|
|
186
|
+
subscriptionFilters: [
|
|
187
|
+
{
|
|
188
|
+
destinationArn: 'some-destination',
|
|
189
|
+
filterName: 'not-datadog',
|
|
190
|
+
logGroupName: '/aws/lambda/my-func',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
destinationArn: 'some-other-destination',
|
|
194
|
+
filterName: 'not-datadog-either',
|
|
195
|
+
logGroupName: '/aws/lambda/my-func',
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
const result = yield loggroup_1.calculateLogGroupRemoveRequest(logs, '/aws/lambda/my-func', 'my-forwarder');
|
|
202
|
+
expect(result).toMatchInlineSnapshot(`
|
|
203
|
+
Object {
|
|
204
|
+
"logGroupName": "/aws/lambda/my-func",
|
|
205
|
+
}
|
|
206
|
+
`);
|
|
207
|
+
}));
|
|
208
|
+
});
|
|
145
209
|
describe('applyLogGroupConfiguration', () => {
|
|
146
210
|
test('applies specified changes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
-
const logs =
|
|
211
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({});
|
|
148
212
|
const config = {
|
|
149
213
|
createLogGroupRequest: {
|
|
150
214
|
logGroupName: '/aws/lambda/my-func',
|
|
151
215
|
},
|
|
152
216
|
deleteSubscriptionFilterRequest: {
|
|
153
|
-
filterName:
|
|
217
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
154
218
|
logGroupName: '/aws/lambda/my-func',
|
|
155
219
|
},
|
|
156
220
|
logGroupName: '/aws/lambda/my-func',
|
|
157
221
|
subscriptionFilterRequest: {
|
|
158
222
|
destinationArn: 'my-forwarder',
|
|
159
|
-
filterName:
|
|
223
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
160
224
|
filterPattern: '',
|
|
161
225
|
logGroupName: '/aws/lambda/my-func',
|
|
162
226
|
},
|
|
@@ -166,23 +230,23 @@ describe('loggroup', () => {
|
|
|
166
230
|
logGroupName: '/aws/lambda/my-func',
|
|
167
231
|
});
|
|
168
232
|
expect(logs.deleteSubscriptionFilter).toHaveBeenCalledWith({
|
|
169
|
-
filterName:
|
|
233
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
170
234
|
logGroupName: '/aws/lambda/my-func',
|
|
171
235
|
});
|
|
172
236
|
expect(logs.putSubscriptionFilter).toHaveBeenCalledWith({
|
|
173
237
|
destinationArn: 'my-forwarder',
|
|
174
|
-
filterName:
|
|
238
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
175
239
|
filterPattern: '',
|
|
176
240
|
logGroupName: '/aws/lambda/my-func',
|
|
177
241
|
});
|
|
178
242
|
}));
|
|
179
243
|
test("doesn't apply unspecified changes", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
-
const logs =
|
|
244
|
+
const logs = fixtures_1.makeMockCloudWatchLogs({});
|
|
181
245
|
const config = {
|
|
182
246
|
logGroupName: '/aws/lambda/my-func',
|
|
183
247
|
subscriptionFilterRequest: {
|
|
184
248
|
destinationArn: 'my-forwarder',
|
|
185
|
-
filterName:
|
|
249
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
186
250
|
filterPattern: '',
|
|
187
251
|
logGroupName: '/aws/lambda/my-func',
|
|
188
252
|
},
|
|
@@ -192,7 +256,7 @@ describe('loggroup', () => {
|
|
|
192
256
|
expect(logs.deleteSubscriptionFilter).not.toHaveBeenCalled();
|
|
193
257
|
expect(logs.putSubscriptionFilter).toHaveBeenCalledWith({
|
|
194
258
|
destinationArn: 'my-forwarder',
|
|
195
|
-
filterName:
|
|
259
|
+
filterName: constants_1.SUBSCRIPTION_FILTER_NAME,
|
|
196
260
|
filterPattern: '',
|
|
197
261
|
logGroupName: '/aws/lambda/my-func',
|
|
198
262
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,11 +14,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
jest.mock('../loggroup');
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const constants_1 = require("../constants");
|
|
17
18
|
const tags_1 = require("../tags");
|
|
18
19
|
// tslint:disable-next-line
|
|
19
20
|
const { version } = require(path_1.default.join(__dirname, '../../../../package.json'));
|
|
20
|
-
const makeMockLambda = (
|
|
21
|
-
listTags: jest.fn().mockImplementation((
|
|
21
|
+
const makeMockLambda = (functions) => ({
|
|
22
|
+
listTags: jest.fn().mockImplementation(({ Resource }) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const tags = (_b = (_a = functions[Resource]) === null || _a === void 0 ? void 0 : _a.tagsResponse) !== null && _b !== void 0 ? _b : { Tags: {} };
|
|
25
|
+
return {
|
|
26
|
+
promise: () => Promise.resolve(tags),
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
22
29
|
tagResource: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
23
30
|
});
|
|
24
31
|
const VERSION_REGEX = /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/;
|
|
@@ -27,9 +34,11 @@ describe('tags', () => {
|
|
|
27
34
|
test('Calls tagResource with config data', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
35
|
const lambda = makeMockLambda({
|
|
29
36
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
config: {
|
|
38
|
+
FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument',
|
|
39
|
+
Handler: 'index.handler',
|
|
40
|
+
Runtime: 'nodejs12.x',
|
|
41
|
+
},
|
|
33
42
|
},
|
|
34
43
|
});
|
|
35
44
|
const config = {
|
|
@@ -47,9 +56,11 @@ describe('tags', () => {
|
|
|
47
56
|
test('Handles undefined config', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
57
|
const lambda = makeMockLambda({
|
|
49
58
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
config: {
|
|
60
|
+
FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument',
|
|
61
|
+
Handler: 'index.handler',
|
|
62
|
+
Runtime: 'nodejs12.x',
|
|
63
|
+
},
|
|
53
64
|
},
|
|
54
65
|
});
|
|
55
66
|
const config = {
|
|
@@ -65,9 +76,11 @@ describe('tags', () => {
|
|
|
65
76
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
66
77
|
const lambda = makeMockLambda({
|
|
67
78
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
config: {
|
|
80
|
+
FunctionArn: functionARN,
|
|
81
|
+
Handler: 'index.handler',
|
|
82
|
+
Runtime: 'nodejs12.x',
|
|
83
|
+
},
|
|
71
84
|
},
|
|
72
85
|
});
|
|
73
86
|
const result = yield tags_1.calculateTagUpdateRequest(lambda, functionARN);
|
|
@@ -85,9 +98,11 @@ describe('tags', () => {
|
|
|
85
98
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
86
99
|
const lambda = makeMockLambda({
|
|
87
100
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
config: {
|
|
102
|
+
FunctionArn: functionARN,
|
|
103
|
+
Handler: 'index.handler',
|
|
104
|
+
Runtime: 'nodejs12.x',
|
|
105
|
+
},
|
|
91
106
|
},
|
|
92
107
|
});
|
|
93
108
|
lambda.listTags.mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: { dd_sls_ci: 'v0.0.0' } }) }));
|
|
@@ -106,9 +121,11 @@ describe('tags', () => {
|
|
|
106
121
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
107
122
|
const lambda = makeMockLambda({
|
|
108
123
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
124
|
+
config: {
|
|
125
|
+
FunctionArn: functionARN,
|
|
126
|
+
Handler: 'index.handler',
|
|
127
|
+
Runtime: 'nodejs12.x',
|
|
128
|
+
},
|
|
112
129
|
},
|
|
113
130
|
});
|
|
114
131
|
lambda.listTags.mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: { dd_sls_ci: `v${version}` } }) }));
|
|
@@ -117,14 +134,63 @@ describe('tags', () => {
|
|
|
117
134
|
expect(lambda.listTags).toHaveBeenCalledWith({ Resource: functionARN });
|
|
118
135
|
}));
|
|
119
136
|
});
|
|
137
|
+
describe('calculateTagRemoveRequest', () => {
|
|
138
|
+
test('returns untag resource configuration with the keys to delete', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
+
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
140
|
+
const lambda = makeMockLambda({
|
|
141
|
+
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
142
|
+
config: {
|
|
143
|
+
FunctionArn: functionARN,
|
|
144
|
+
Handler: 'index.handler',
|
|
145
|
+
Runtime: 'nodejs12.x',
|
|
146
|
+
},
|
|
147
|
+
tagsResponse: {
|
|
148
|
+
Tags: { dd_sls_ci: `v${version}` },
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
const result = yield tags_1.calculateTagRemoveRequest(lambda, functionARN);
|
|
153
|
+
expect(result).toMatchInlineSnapshot(`
|
|
154
|
+
Object {
|
|
155
|
+
"untagResourceRequest": Object {
|
|
156
|
+
"Resource": "${functionARN}",
|
|
157
|
+
"TagKeys": Array [
|
|
158
|
+
"${constants_1.TAG_VERSION_NAME}",
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
`);
|
|
163
|
+
expect(lambda.listTags).toHaveBeenCalledWith({ Resource: functionARN });
|
|
164
|
+
}));
|
|
165
|
+
test('returns undefined when no tags need to be removed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
+
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
167
|
+
const lambda = makeMockLambda({
|
|
168
|
+
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
169
|
+
config: {
|
|
170
|
+
FunctionArn: functionARN,
|
|
171
|
+
Handler: 'index.handler',
|
|
172
|
+
Runtime: 'nodejs12.x',
|
|
173
|
+
},
|
|
174
|
+
tagsResponse: {
|
|
175
|
+
Tags: { not_datadog: 'some-tag' },
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
const result = yield tags_1.calculateTagRemoveRequest(lambda, functionARN);
|
|
180
|
+
expect(result).toBeUndefined();
|
|
181
|
+
expect(lambda.listTags).toHaveBeenCalledWith({ Resource: functionARN });
|
|
182
|
+
}));
|
|
183
|
+
});
|
|
120
184
|
describe('hasVersionTag', () => {
|
|
121
185
|
test('handles no tags', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
186
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
123
187
|
const lambda = makeMockLambda({
|
|
124
188
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
189
|
+
config: {
|
|
190
|
+
FunctionArn: functionARN,
|
|
191
|
+
Handler: 'index.handler',
|
|
192
|
+
Runtime: 'nodejs12.x',
|
|
193
|
+
},
|
|
128
194
|
},
|
|
129
195
|
});
|
|
130
196
|
const result = yield tags_1.hasVersionTag(lambda, functionARN);
|
|
@@ -135,9 +201,11 @@ describe('tags', () => {
|
|
|
135
201
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
136
202
|
const lambda = makeMockLambda({
|
|
137
203
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
204
|
+
config: {
|
|
205
|
+
FunctionArn: functionARN,
|
|
206
|
+
Handler: 'index.handler',
|
|
207
|
+
Runtime: 'nodejs12.x',
|
|
208
|
+
},
|
|
141
209
|
},
|
|
142
210
|
});
|
|
143
211
|
lambda.listTags.mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: { foo: 'bar' } }) }));
|
|
@@ -149,12 +217,16 @@ describe('tags', () => {
|
|
|
149
217
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
150
218
|
const lambda = makeMockLambda({
|
|
151
219
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
220
|
+
config: {
|
|
221
|
+
FunctionArn: functionARN,
|
|
222
|
+
Handler: 'index.handler',
|
|
223
|
+
Runtime: 'nodejs12.x',
|
|
224
|
+
},
|
|
225
|
+
tagsResponse: {
|
|
226
|
+
Tags: { dd_sls_ci: 'v0.0.0' },
|
|
227
|
+
},
|
|
155
228
|
},
|
|
156
229
|
});
|
|
157
|
-
lambda.listTags.mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: { dd_sls_ci: 'v0.0.0' } }) }));
|
|
158
230
|
const result = yield tags_1.hasVersionTag(lambda, functionARN);
|
|
159
231
|
expect(result).toBe(false);
|
|
160
232
|
expect(lambda.listTags).toHaveBeenCalledWith({ Resource: functionARN });
|
|
@@ -163,12 +235,16 @@ describe('tags', () => {
|
|
|
163
235
|
const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument';
|
|
164
236
|
const lambda = makeMockLambda({
|
|
165
237
|
'arn:aws:lambda:us-east-1:000000000000:function:autoinstrument': {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
238
|
+
config: {
|
|
239
|
+
FunctionArn: functionARN,
|
|
240
|
+
Handler: 'index.handler',
|
|
241
|
+
Runtime: 'nodejs12.x',
|
|
242
|
+
},
|
|
243
|
+
tagsResponse: {
|
|
244
|
+
Tags: { dd_sls_ci: `v${version}` },
|
|
245
|
+
},
|
|
169
246
|
},
|
|
170
247
|
});
|
|
171
|
-
lambda.listTags.mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: { dd_sls_ci: `v${version}` } }) }));
|
|
172
248
|
const result = yield tags_1.hasVersionTag(lambda, functionARN);
|
|
173
249
|
expect(result).toBe(true);
|
|
174
250
|
expect(lambda.listTags).toHaveBeenCalledWith({ Resource: functionARN });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|