pepr 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +1 -1
- package/dist/src/cli/index.js +3 -3
- package/dist/src/cli/init/templates.js +2 -3
- package/dist/src/lib/controller.d.ts +1 -0
- package/dist/src/lib/controller.js +6 -0
- package/dist/src/lib/module.js +5 -5
- package/dist/src/lib/request.js +6 -3
- package/package.json +1 -1
- package/.env +0 -0
- package/dist/src/cli/version.d.ts +0 -1
- package/dist/src/cli/version.js +0 -6
package/dist/package.json
CHANGED
package/dist/src/cli/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const package_json_1 = require("../../package.json");
|
|
8
9
|
const banner_1 = require("./banner");
|
|
9
10
|
const build_1 = __importDefault(require("./build"));
|
|
10
11
|
const capability_1 = __importDefault(require("./capability"));
|
|
@@ -13,11 +14,10 @@ const dev_1 = __importDefault(require("./dev"));
|
|
|
13
14
|
const init_1 = __importDefault(require("./init"));
|
|
14
15
|
const root_1 = require("./root");
|
|
15
16
|
const test_1 = __importDefault(require("./test"));
|
|
16
|
-
const version_1 = require("./version");
|
|
17
17
|
const program = new root_1.RootCmd();
|
|
18
18
|
program
|
|
19
|
-
.version(
|
|
20
|
-
.description(`Pepr Kubernetes Thingy (v${
|
|
19
|
+
.version(package_json_1.version)
|
|
20
|
+
.description(`Pepr Kubernetes Thingy (v${package_json_1.version})`)
|
|
21
21
|
.action(() => {
|
|
22
22
|
if (program.args.length < 1) {
|
|
23
23
|
console.log(banner_1.banner);
|
|
@@ -7,7 +7,6 @@ const client_node_1 = require("@kubernetes/client-node");
|
|
|
7
7
|
const util_1 = require("util");
|
|
8
8
|
const uuid_1 = require("uuid");
|
|
9
9
|
const package_json_1 = require("../../../package.json");
|
|
10
|
-
const version_1 = require("../version");
|
|
11
10
|
const utils_1 = require("./utils");
|
|
12
11
|
function genPeprTS() {
|
|
13
12
|
return {
|
|
@@ -44,7 +43,7 @@ function genPkgJSON(opts) {
|
|
|
44
43
|
keywords: ["pepr", "k8s", "policy-engine", "pepr-module", "security"],
|
|
45
44
|
pepr: {
|
|
46
45
|
name: opts.name.trim(),
|
|
47
|
-
version:
|
|
46
|
+
version: package_json_1.version,
|
|
48
47
|
uuid,
|
|
49
48
|
onError: opts.errorBehavior,
|
|
50
49
|
alwaysIgnore: {
|
|
@@ -57,7 +56,7 @@ function genPkgJSON(opts) {
|
|
|
57
56
|
start: "pepr dev",
|
|
58
57
|
},
|
|
59
58
|
dependencies: {
|
|
60
|
-
pepr: `^${
|
|
59
|
+
pepr: `^${package_json_1.version}`,
|
|
61
60
|
},
|
|
62
61
|
devDependencies: {
|
|
63
62
|
typescript,
|
|
@@ -4,6 +4,7 @@ export declare class Controller {
|
|
|
4
4
|
private readonly config;
|
|
5
5
|
private readonly capabilities;
|
|
6
6
|
private readonly app;
|
|
7
|
+
private running;
|
|
7
8
|
constructor(config: ModuleConfig, capabilities: Capability[]);
|
|
8
9
|
/** Start the webhook server */
|
|
9
10
|
startServer: (port: number) => void;
|
|
@@ -20,11 +20,17 @@ class Controller {
|
|
|
20
20
|
this.config = config;
|
|
21
21
|
this.capabilities = capabilities;
|
|
22
22
|
this.app = (0, express_1.default)();
|
|
23
|
+
this.running = false;
|
|
23
24
|
/** Start the webhook server */
|
|
24
25
|
this.startServer = (port) => {
|
|
26
|
+
if (this.running) {
|
|
27
|
+
throw new Error("Cannot start Pepr module: Pepr module was not instantiated with deferStart=true");
|
|
28
|
+
}
|
|
25
29
|
// Create HTTPS server
|
|
26
30
|
https_1.default.createServer(options, this.app).listen(port, () => {
|
|
27
31
|
console.log(`Server listening on port ${port}`);
|
|
32
|
+
// Track that the server is running
|
|
33
|
+
this.running = true;
|
|
28
34
|
});
|
|
29
35
|
};
|
|
30
36
|
this.logger = (req, res, next) => {
|
package/dist/src/lib/module.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
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
|
+
};
|
|
4
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
8
|
exports.PeprModule = void 0;
|
|
6
|
-
const
|
|
9
|
+
const ramda_1 = __importDefault(require("ramda"));
|
|
7
10
|
const controller_1 = require("./controller");
|
|
8
11
|
const alwaysIgnore = {
|
|
9
12
|
namespaces: ["kube-system", "pepr-system"],
|
|
@@ -19,7 +22,7 @@ class PeprModule {
|
|
|
19
22
|
*/
|
|
20
23
|
constructor({ description, pepr }, capabilities = [], _deferStart = false) {
|
|
21
24
|
this._deferStart = _deferStart;
|
|
22
|
-
const config =
|
|
25
|
+
const config = ramda_1.default.mergeDeepWith(ramda_1.default.concat, pepr, alwaysIgnore);
|
|
23
26
|
config.description = description;
|
|
24
27
|
this._controller = new controller_1.Controller(config, capabilities);
|
|
25
28
|
if (!_deferStart) {
|
|
@@ -33,9 +36,6 @@ class PeprModule {
|
|
|
33
36
|
* @param port
|
|
34
37
|
*/
|
|
35
38
|
start(port = 3000) {
|
|
36
|
-
if (!this._deferStart) {
|
|
37
|
-
throw new Error("Cannot start Pepr module: Pepr module was not instantiated with deferStart=true");
|
|
38
|
-
}
|
|
39
39
|
this._controller.startServer(port);
|
|
40
40
|
}
|
|
41
41
|
}
|
package/dist/src/lib/request.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
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
|
+
};
|
|
4
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
8
|
exports.RequestWrapper = void 0;
|
|
6
|
-
const
|
|
9
|
+
const ramda_1 = __importDefault(require("ramda"));
|
|
7
10
|
/**
|
|
8
11
|
* The RequestWrapper class provides methods to modify Kubernetes objects in the context
|
|
9
12
|
* of a mutating webhook request.
|
|
@@ -39,7 +42,7 @@ class RequestWrapper {
|
|
|
39
42
|
*/
|
|
40
43
|
constructor(input) {
|
|
41
44
|
// Deep clone the object to prevent mutation of the original object
|
|
42
|
-
this.Raw =
|
|
45
|
+
this.Raw = ramda_1.default.clone(input.object);
|
|
43
46
|
// Store the input
|
|
44
47
|
this._input = input;
|
|
45
48
|
}
|
|
@@ -49,7 +52,7 @@ class RequestWrapper {
|
|
|
49
52
|
* @param obj - The object to merge with the current resource.
|
|
50
53
|
*/
|
|
51
54
|
Merge(obj) {
|
|
52
|
-
this.Raw =
|
|
55
|
+
this.Raw = ramda_1.default.mergeDeepRight(this.Raw, obj);
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Updates a label on the Kubernetes resource.
|
package/package.json
CHANGED
package/.env
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const version: string;
|
package/dist/src/cli/version.js
DELETED