pepr 0.3.0-rc0 → 0.3.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.
- package/README.md +3 -46
- package/dist/package.json +8 -6
- package/dist/src/cli/build.js +1 -1
- package/dist/src/cli/dev.js +4 -1
- package/dist/src/cli/init/index.js +1 -1
- package/dist/src/lib/capability.d.ts +29 -0
- package/dist/src/lib/capability.d.ts.map +1 -0
- package/dist/src/lib/controller.d.ts +18 -0
- package/dist/src/lib/controller.d.ts.map +1 -0
- package/dist/src/lib/fetch.d.ts +24 -0
- package/dist/src/lib/fetch.d.ts.map +1 -0
- package/dist/src/lib/filter.d.ts +11 -0
- package/dist/src/lib/filter.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +15 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/{index.js → src/lib/index.js} +6 -6
- package/dist/src/lib/k8s/index.d.ts +6 -0
- package/dist/src/lib/k8s/index.d.ts.map +1 -0
- package/dist/src/lib/k8s/kinds.d.ts +12 -0
- package/dist/src/lib/k8s/kinds.d.ts.map +1 -0
- package/dist/src/lib/k8s/tls.d.ts +18 -0
- package/dist/src/lib/k8s/tls.d.ts.map +1 -0
- package/dist/src/lib/k8s/types.d.ts +148 -0
- package/dist/src/lib/k8s/types.d.ts.map +1 -0
- package/dist/src/lib/k8s/upstream.d.ts +4 -0
- package/dist/src/lib/k8s/upstream.d.ts.map +1 -0
- package/dist/src/lib/k8s/webhook.d.ts +35 -0
- package/dist/src/lib/k8s/webhook.d.ts.map +1 -0
- package/dist/src/lib/logger.d.ts +56 -0
- package/dist/src/lib/logger.d.ts.map +1 -0
- package/dist/src/lib/module.d.ts +33 -0
- package/dist/src/lib/module.d.ts.map +1 -0
- package/dist/src/lib/processor.d.ts +5 -0
- package/dist/src/lib/processor.d.ts.map +1 -0
- package/dist/src/lib/request.d.ts +78 -0
- package/dist/src/lib/request.d.ts.map +1 -0
- package/dist/src/lib/types.d.ts +188 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/package.json +8 -6
- package/{index.ts → src/lib/index.ts} +6 -6
- package/dist/fixtures/data/cm1.json +0 -75
- package/dist/fixtures/data/deployment1.json +0 -170
- package/dist/fixtures/data/ns1.json +0 -72
- package/dist/fixtures/data/pod1.json +0 -271
- package/dist/fixtures/data/pod2.json +0 -257
- package/dist/fixtures/data/svc1.json +0 -100
- package/dist/fixtures/loader.js +0 -60
- package/dist/src/cli/init/utils.test.js +0 -29
- package/dist/src/cli/init/walkthrough.test.js +0 -21
- package/dist/src/lib/fetch.test.js +0 -98
- package/dist/src/lib/filter.test.js +0 -208
- package/dist/src/lib/k8s/kinds.test.js +0 -296
- package/dist/src/lib/logger.test.js +0 -64
- package/docs/.prettierrc.json +0 -13
- package/docs/actions.md +0 -58
- package/docs/capabilities.md +0 -17
- package/docs/cli.md +0 -58
- package/docs/module.md +0 -90
- package/osv-scanner.toml +0 -4
- package/src/lib/fetch.test.ts +0 -115
- package/src/lib/filter.test.ts +0 -231
- package/src/lib/k8s/kinds.test.ts +0 -333
- package/src/lib/logger.test.ts +0 -80
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"uid": "f7b55ff2-18ef-403c-87fe-bac8435e0ed7",
|
|
3
|
-
"kind": {
|
|
4
|
-
"group": "",
|
|
5
|
-
"version": "v1",
|
|
6
|
-
"kind": "Service"
|
|
7
|
-
},
|
|
8
|
-
"resource": {
|
|
9
|
-
"group": "",
|
|
10
|
-
"version": "v1",
|
|
11
|
-
"resource": "services"
|
|
12
|
-
},
|
|
13
|
-
"requestKind": {
|
|
14
|
-
"group": "",
|
|
15
|
-
"version": "v1",
|
|
16
|
-
"kind": "Service"
|
|
17
|
-
},
|
|
18
|
-
"requestResource": {
|
|
19
|
-
"group": "",
|
|
20
|
-
"version": "v1",
|
|
21
|
-
"resource": "services"
|
|
22
|
-
},
|
|
23
|
-
"name": "my-service",
|
|
24
|
-
"namespace": "apps",
|
|
25
|
-
"operation": "CREATE",
|
|
26
|
-
"userInfo": {
|
|
27
|
-
"username": "kubernetes-admin",
|
|
28
|
-
"groups": ["system:masters", "system:authenticated"]
|
|
29
|
-
},
|
|
30
|
-
"object": {
|
|
31
|
-
"kind": "Service",
|
|
32
|
-
"apiVersion": "v1",
|
|
33
|
-
"metadata": {
|
|
34
|
-
"name": "my-service",
|
|
35
|
-
"namespace": "apps",
|
|
36
|
-
"creationTimestamp": null,
|
|
37
|
-
"annotations": {
|
|
38
|
-
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"name\":\"my-service\",\"namespace\":\"apps\"},\"spec\":{\"ports\":[{\"port\":80,\"protocol\":\"TCP\",\"targetPort\":9376}],\"selector\":{\"app.kubernetes.io/name\":\"MyApp\"}}}\n"
|
|
39
|
-
},
|
|
40
|
-
"managedFields": [
|
|
41
|
-
{
|
|
42
|
-
"manager": "kubectl-client-side-apply",
|
|
43
|
-
"operation": "Update",
|
|
44
|
-
"apiVersion": "v1",
|
|
45
|
-
"time": "2023-03-31T19:08:48Z",
|
|
46
|
-
"fieldsType": "FieldsV1",
|
|
47
|
-
"fieldsV1": {
|
|
48
|
-
"f:metadata": {
|
|
49
|
-
"f:annotations": {
|
|
50
|
-
".": {},
|
|
51
|
-
"f:kubectl.kubernetes.io/last-applied-configuration": {}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"f:spec": {
|
|
55
|
-
"f:ports": {
|
|
56
|
-
".": {},
|
|
57
|
-
"k:{\"port\":80,\"protocol\":\"TCP\"}": {
|
|
58
|
-
".": {},
|
|
59
|
-
"f:port": {},
|
|
60
|
-
"f:protocol": {},
|
|
61
|
-
"f:targetPort": {}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"f:selector": {
|
|
65
|
-
".": {},
|
|
66
|
-
"f:app.kubernetes.io/name": {}
|
|
67
|
-
},
|
|
68
|
-
"f:sessionAffinity": {},
|
|
69
|
-
"f:type": {}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
},
|
|
75
|
-
"spec": {
|
|
76
|
-
"ports": [
|
|
77
|
-
{
|
|
78
|
-
"protocol": "TCP",
|
|
79
|
-
"port": 80,
|
|
80
|
-
"targetPort": 9376
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
"selector": {
|
|
84
|
-
"app.kubernetes.io/name": "MyApp"
|
|
85
|
-
},
|
|
86
|
-
"type": "ClusterIP",
|
|
87
|
-
"sessionAffinity": "None"
|
|
88
|
-
},
|
|
89
|
-
"status": {
|
|
90
|
-
"loadBalancer": {}
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
"oldObject": null,
|
|
94
|
-
"dryRun": false,
|
|
95
|
-
"options": {
|
|
96
|
-
"kind": "CreateOptions",
|
|
97
|
-
"apiVersion": "meta.k8s.io/v1",
|
|
98
|
-
"fieldManager": "kubectl-client-side-apply"
|
|
99
|
-
}
|
|
100
|
-
}
|
package/dist/fixtures/loader.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.NS1 = exports.CM1 = exports.DEPLOYMENT1 = exports.SVC1 = exports.POD2 = exports.POD1 = void 0;
|
|
27
|
-
const cm1 = __importStar(require("./data/cm1.json"));
|
|
28
|
-
const deployment1 = __importStar(require("./data/deployment1.json"));
|
|
29
|
-
const ns1 = __importStar(require("./data/ns1.json"));
|
|
30
|
-
const pod1 = __importStar(require("./data/pod1.json"));
|
|
31
|
-
const pod2 = __importStar(require("./data/pod2.json"));
|
|
32
|
-
const svc1 = __importStar(require("./data/svc1.json"));
|
|
33
|
-
function POD1() {
|
|
34
|
-
return cloneObject(pod1);
|
|
35
|
-
}
|
|
36
|
-
exports.POD1 = POD1;
|
|
37
|
-
function POD2() {
|
|
38
|
-
return cloneObject(pod2);
|
|
39
|
-
}
|
|
40
|
-
exports.POD2 = POD2;
|
|
41
|
-
function SVC1() {
|
|
42
|
-
return cloneObject(svc1);
|
|
43
|
-
}
|
|
44
|
-
exports.SVC1 = SVC1;
|
|
45
|
-
function DEPLOYMENT1() {
|
|
46
|
-
return cloneObject(deployment1);
|
|
47
|
-
}
|
|
48
|
-
exports.DEPLOYMENT1 = DEPLOYMENT1;
|
|
49
|
-
function CM1() {
|
|
50
|
-
return cloneObject(cm1);
|
|
51
|
-
}
|
|
52
|
-
exports.CM1 = CM1;
|
|
53
|
-
function NS1() {
|
|
54
|
-
return cloneObject(ns1);
|
|
55
|
-
}
|
|
56
|
-
exports.NS1 = NS1;
|
|
57
|
-
function cloneObject(obj) {
|
|
58
|
-
// JSON to avoid funky typescript silliness on jsonmodules
|
|
59
|
-
return JSON.parse(JSON.stringify(obj));
|
|
60
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const ava_1 = __importDefault(require("ava"));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
10
|
-
(0, ava_1.default)("sanitizeName() sanitizes names correctly", t => {
|
|
11
|
-
const cases = [
|
|
12
|
-
{
|
|
13
|
-
input: "My Test Module",
|
|
14
|
-
expected: "my-test-module",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
input: "!! 123 @@ Module",
|
|
18
|
-
expected: "123-module",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
input: "---Test-Module---",
|
|
22
|
-
expected: "test-module",
|
|
23
|
-
},
|
|
24
|
-
];
|
|
25
|
-
for (const { input, expected } of cases) {
|
|
26
|
-
const result = (0, utils_1.sanitizeName)(input);
|
|
27
|
-
t.is(result, expected, `sanitizeName(${input}) should be ${expected}`);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const ava_1 = __importDefault(require("ava"));
|
|
9
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
10
|
-
const walkthrough_1 = require("./walkthrough");
|
|
11
|
-
(0, ava_1.default)("walkthrough() returns expected results", async (t) => {
|
|
12
|
-
// Inject predefined answers for the prompts
|
|
13
|
-
prompts_1.default.inject(["My Test Module", "A test module for Pepr", 0]);
|
|
14
|
-
const result = await (0, walkthrough_1.walkthrough)();
|
|
15
|
-
// Check the returned object
|
|
16
|
-
t.deepEqual(result, {
|
|
17
|
-
name: "My Test Module",
|
|
18
|
-
description: "A test module for Pepr",
|
|
19
|
-
errorBehavior: 0,
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
-
// fetch.test.ts
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const ava_1 = __importDefault(require("ava"));
|
|
10
|
-
const http_status_codes_1 = require("http-status-codes");
|
|
11
|
-
const nock_1 = __importDefault(require("nock"));
|
|
12
|
-
const fetch_1 = require("./fetch");
|
|
13
|
-
ava_1.default.beforeEach(() => {
|
|
14
|
-
(0, nock_1.default)("https://jsonplaceholder.typicode.com")
|
|
15
|
-
.get("/todos/1")
|
|
16
|
-
.reply(200, {
|
|
17
|
-
userId: 1,
|
|
18
|
-
id: 1,
|
|
19
|
-
title: "Example title",
|
|
20
|
-
completed: false,
|
|
21
|
-
})
|
|
22
|
-
.post("/todos", {
|
|
23
|
-
title: "test todo",
|
|
24
|
-
userId: 1,
|
|
25
|
-
completed: false,
|
|
26
|
-
})
|
|
27
|
-
.reply(200, (uri, requestBody) => requestBody)
|
|
28
|
-
.get("/todos/empty-null")
|
|
29
|
-
.reply(200, undefined)
|
|
30
|
-
.get("/todos/empty-string")
|
|
31
|
-
.reply(200, "")
|
|
32
|
-
.get("/todos/empty-object")
|
|
33
|
-
.reply(200, {})
|
|
34
|
-
.get("/todos/invalid")
|
|
35
|
-
.replyWithError("Something bad happened");
|
|
36
|
-
});
|
|
37
|
-
(0, ava_1.default)("fetch: should return without type data", async (t) => {
|
|
38
|
-
const url = "https://jsonplaceholder.typicode.com/todos/1";
|
|
39
|
-
const { data, ok } = await (0, fetch_1.fetch)(url);
|
|
40
|
-
t.is(ok, true);
|
|
41
|
-
t.is(data["title"], "Example title");
|
|
42
|
-
});
|
|
43
|
-
(0, ava_1.default)("fetch: should return parsed JSON response as a specific type", async (t) => {
|
|
44
|
-
const url = "https://jsonplaceholder.typicode.com/todos/1";
|
|
45
|
-
const { data, ok } = await (0, fetch_1.fetch)(url);
|
|
46
|
-
t.is(ok, true);
|
|
47
|
-
t.is(data.id, 1);
|
|
48
|
-
t.is(typeof data.title, "string");
|
|
49
|
-
t.is(typeof data.completed, "boolean");
|
|
50
|
-
});
|
|
51
|
-
(0, ava_1.default)("fetch: should handle additional request options", async (t) => {
|
|
52
|
-
const url = "https://jsonplaceholder.typicode.com/todos";
|
|
53
|
-
const requestOptions = {
|
|
54
|
-
method: "POST",
|
|
55
|
-
body: JSON.stringify({
|
|
56
|
-
title: "test todo",
|
|
57
|
-
userId: 1,
|
|
58
|
-
completed: false,
|
|
59
|
-
}),
|
|
60
|
-
headers: {
|
|
61
|
-
"Content-type": "application/json; charset=UTF-8",
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
const { data, ok } = await (0, fetch_1.fetch)(url, requestOptions);
|
|
66
|
-
t.is(ok, true);
|
|
67
|
-
t.is(data["title"], "test todo");
|
|
68
|
-
t.is(data["userId"], 1);
|
|
69
|
-
t.is(data["completed"], false);
|
|
70
|
-
});
|
|
71
|
-
(0, ava_1.default)("fetch: should handle empty (null) responses", async (t) => {
|
|
72
|
-
const url = "https://jsonplaceholder.typicode.com/todos/empty-null";
|
|
73
|
-
const resp = await (0, fetch_1.fetch)(url);
|
|
74
|
-
t.is(resp.data, "");
|
|
75
|
-
t.is(resp.ok, true);
|
|
76
|
-
t.is(resp.status, http_status_codes_1.StatusCodes.OK);
|
|
77
|
-
});
|
|
78
|
-
(0, ava_1.default)("fetch: should handle empty (string) responses", async (t) => {
|
|
79
|
-
const url = "https://jsonplaceholder.typicode.com/todos/empty-string";
|
|
80
|
-
const resp = await (0, fetch_1.fetch)(url);
|
|
81
|
-
t.is(resp.data, "");
|
|
82
|
-
t.is(resp.ok, true);
|
|
83
|
-
t.is(resp.status, http_status_codes_1.StatusCodes.OK);
|
|
84
|
-
});
|
|
85
|
-
(0, ava_1.default)("fetch: should handle empty (object) responses", async (t) => {
|
|
86
|
-
const url = "https://jsonplaceholder.typicode.com/todos/empty-object";
|
|
87
|
-
const resp = await (0, fetch_1.fetch)(url);
|
|
88
|
-
t.deepEqual(resp.data, {});
|
|
89
|
-
t.is(resp.ok, true);
|
|
90
|
-
t.is(resp.status, http_status_codes_1.StatusCodes.OK);
|
|
91
|
-
});
|
|
92
|
-
(0, ava_1.default)("fetch: should handle failed requests without throwing an error", async (t) => {
|
|
93
|
-
const url = "https://jsonplaceholder.typicode.com/todos/invalid";
|
|
94
|
-
const resp = await (0, fetch_1.fetch)(url);
|
|
95
|
-
t.is(resp.data, undefined);
|
|
96
|
-
t.is(resp.ok, false);
|
|
97
|
-
t.is(resp.status, http_status_codes_1.StatusCodes.BAD_REQUEST);
|
|
98
|
-
});
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ava_1 = __importDefault(require("ava"));
|
|
7
|
-
const loader_1 = require("../../fixtures/loader");
|
|
8
|
-
const filter_1 = require("./filter");
|
|
9
|
-
const k8s_1 = require("./k8s");
|
|
10
|
-
const callback = () => undefined;
|
|
11
|
-
(0, ava_1.default)("should reject when name does not match", t => {
|
|
12
|
-
const binding = {
|
|
13
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
14
|
-
filters: {
|
|
15
|
-
name: "bleh",
|
|
16
|
-
namespaces: [],
|
|
17
|
-
labels: {},
|
|
18
|
-
annotations: {},
|
|
19
|
-
},
|
|
20
|
-
callback,
|
|
21
|
-
};
|
|
22
|
-
const pod = (0, loader_1.POD1)();
|
|
23
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
24
|
-
});
|
|
25
|
-
(0, ava_1.default)("should reject when kind does not match", t => {
|
|
26
|
-
const binding = {
|
|
27
|
-
kind: k8s_1.gvkMap.V1ConfigMap,
|
|
28
|
-
filters: {
|
|
29
|
-
name: "",
|
|
30
|
-
namespaces: [],
|
|
31
|
-
labels: {},
|
|
32
|
-
annotations: {},
|
|
33
|
-
},
|
|
34
|
-
callback,
|
|
35
|
-
};
|
|
36
|
-
const pod = (0, loader_1.POD1)();
|
|
37
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
38
|
-
});
|
|
39
|
-
(0, ava_1.default)("should reject when group does not match", t => {
|
|
40
|
-
const binding = {
|
|
41
|
-
kind: k8s_1.gvkMap.V1CronJob,
|
|
42
|
-
filters: {
|
|
43
|
-
name: "",
|
|
44
|
-
namespaces: [],
|
|
45
|
-
labels: {},
|
|
46
|
-
annotations: {},
|
|
47
|
-
},
|
|
48
|
-
callback,
|
|
49
|
-
};
|
|
50
|
-
const pod = (0, loader_1.POD1)();
|
|
51
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
52
|
-
});
|
|
53
|
-
(0, ava_1.default)("should reject when version does not match", t => {
|
|
54
|
-
const binding = {
|
|
55
|
-
kind: {
|
|
56
|
-
group: "",
|
|
57
|
-
version: "v2",
|
|
58
|
-
kind: "Pod",
|
|
59
|
-
},
|
|
60
|
-
filters: {
|
|
61
|
-
name: "",
|
|
62
|
-
namespaces: [],
|
|
63
|
-
labels: {},
|
|
64
|
-
annotations: {},
|
|
65
|
-
},
|
|
66
|
-
callback,
|
|
67
|
-
};
|
|
68
|
-
const pod = (0, loader_1.POD1)();
|
|
69
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
70
|
-
});
|
|
71
|
-
(0, ava_1.default)("should allow when group, version, and kind match", t => {
|
|
72
|
-
const binding = {
|
|
73
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
74
|
-
filters: {
|
|
75
|
-
name: "",
|
|
76
|
-
namespaces: [],
|
|
77
|
-
labels: {},
|
|
78
|
-
annotations: {},
|
|
79
|
-
},
|
|
80
|
-
callback,
|
|
81
|
-
};
|
|
82
|
-
const pod = (0, loader_1.POD1)();
|
|
83
|
-
t.false((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
84
|
-
});
|
|
85
|
-
(0, ava_1.default)("should allow when kind match and others are empty", t => {
|
|
86
|
-
const binding = {
|
|
87
|
-
kind: {
|
|
88
|
-
group: "",
|
|
89
|
-
version: "",
|
|
90
|
-
kind: "Pod",
|
|
91
|
-
},
|
|
92
|
-
filters: {
|
|
93
|
-
name: "",
|
|
94
|
-
namespaces: [],
|
|
95
|
-
labels: {},
|
|
96
|
-
annotations: {},
|
|
97
|
-
},
|
|
98
|
-
callback,
|
|
99
|
-
};
|
|
100
|
-
const pod = (0, loader_1.POD1)();
|
|
101
|
-
t.false((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
102
|
-
});
|
|
103
|
-
(0, ava_1.default)("should reject when namespace does not match", t => {
|
|
104
|
-
const binding = {
|
|
105
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
106
|
-
filters: {
|
|
107
|
-
name: "",
|
|
108
|
-
namespaces: ["bleh"],
|
|
109
|
-
labels: {},
|
|
110
|
-
annotations: {},
|
|
111
|
-
},
|
|
112
|
-
callback,
|
|
113
|
-
};
|
|
114
|
-
const pod = (0, loader_1.POD1)();
|
|
115
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
116
|
-
});
|
|
117
|
-
(0, ava_1.default)("should allow when namespace is match", t => {
|
|
118
|
-
const binding = {
|
|
119
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
120
|
-
filters: {
|
|
121
|
-
name: "",
|
|
122
|
-
namespaces: ["default", "unicorn", "things"],
|
|
123
|
-
labels: {},
|
|
124
|
-
annotations: {},
|
|
125
|
-
},
|
|
126
|
-
callback,
|
|
127
|
-
};
|
|
128
|
-
const pod = (0, loader_1.POD1)();
|
|
129
|
-
t.false((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
130
|
-
});
|
|
131
|
-
(0, ava_1.default)("should reject when label does not match", t => {
|
|
132
|
-
const binding = {
|
|
133
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
134
|
-
filters: {
|
|
135
|
-
name: "",
|
|
136
|
-
namespaces: [],
|
|
137
|
-
labels: {
|
|
138
|
-
foo: "bar",
|
|
139
|
-
},
|
|
140
|
-
annotations: {},
|
|
141
|
-
},
|
|
142
|
-
callback,
|
|
143
|
-
};
|
|
144
|
-
const pod = (0, loader_1.POD1)();
|
|
145
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
146
|
-
});
|
|
147
|
-
(0, ava_1.default)("should allow when label is match", t => {
|
|
148
|
-
const binding = {
|
|
149
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
150
|
-
filters: {
|
|
151
|
-
name: "",
|
|
152
|
-
namespaces: [],
|
|
153
|
-
labels: {
|
|
154
|
-
foo: "bar",
|
|
155
|
-
test: "test1",
|
|
156
|
-
},
|
|
157
|
-
annotations: {},
|
|
158
|
-
},
|
|
159
|
-
callback,
|
|
160
|
-
};
|
|
161
|
-
const pod = (0, loader_1.POD1)();
|
|
162
|
-
pod.object.metadata = pod.object.metadata || {};
|
|
163
|
-
pod.object.metadata.labels = {
|
|
164
|
-
foo: "bar",
|
|
165
|
-
test: "test1",
|
|
166
|
-
test2: "test2",
|
|
167
|
-
};
|
|
168
|
-
t.false((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
169
|
-
});
|
|
170
|
-
(0, ava_1.default)("should reject when annotation does not match", t => {
|
|
171
|
-
const binding = {
|
|
172
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
173
|
-
filters: {
|
|
174
|
-
name: "",
|
|
175
|
-
namespaces: [],
|
|
176
|
-
labels: {},
|
|
177
|
-
annotations: {
|
|
178
|
-
foo: "bar",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
callback,
|
|
182
|
-
};
|
|
183
|
-
const pod = (0, loader_1.POD1)();
|
|
184
|
-
t.true((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
185
|
-
});
|
|
186
|
-
(0, ava_1.default)("should allow when annotation is match", t => {
|
|
187
|
-
const binding = {
|
|
188
|
-
kind: k8s_1.gvkMap.V1Pod,
|
|
189
|
-
filters: {
|
|
190
|
-
name: "",
|
|
191
|
-
namespaces: [],
|
|
192
|
-
labels: {},
|
|
193
|
-
annotations: {
|
|
194
|
-
foo: "bar",
|
|
195
|
-
test: "test1",
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
callback,
|
|
199
|
-
};
|
|
200
|
-
const pod = (0, loader_1.POD1)();
|
|
201
|
-
pod.object.metadata = pod.object.metadata || {};
|
|
202
|
-
pod.object.metadata.annotations = {
|
|
203
|
-
foo: "bar",
|
|
204
|
-
test: "test1",
|
|
205
|
-
test2: "test2",
|
|
206
|
-
};
|
|
207
|
-
t.false((0, filter_1.shouldSkipRequest)(binding, pod));
|
|
208
|
-
});
|