pepr 1.1.5 → 1.1.6
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/cli/init/templates.d.ts +3 -6
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli.js +36 -26
- package/dist/controller.js +6 -9
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/controller/index.util.d.ts +4 -0
- package/dist/lib/controller/index.util.d.ts.map +1 -1
- package/dist/lib.js +20 -2
- package/dist/lib.js.map +2 -2
- package/package.json +6 -9
- package/src/lib/controller/index.ts +28 -3
- package/src/lib/controller/index.util.ts +10 -0
- package/dist/sdk/heredoc.d.ts +0 -2
- package/dist/sdk/heredoc.d.ts.map +0 -1
- package/src/sdk/heredoc.ts +0 -36
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"!src/fixtures/**",
|
|
17
17
|
"!dist/**/*.test.d.ts*"
|
|
18
18
|
],
|
|
19
|
-
"version": "1.1.
|
|
19
|
+
"version": "1.1.6",
|
|
20
20
|
"main": "dist/lib.js",
|
|
21
21
|
"types": "dist/lib.d.ts",
|
|
22
22
|
"scripts": {
|
|
@@ -50,11 +50,12 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@types/ramda": "0.31.1",
|
|
53
|
-
"
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "8.45.0",
|
|
54
|
+
"@typescript-eslint/parser": "8.45.0",
|
|
54
55
|
"commander": "14.0.3",
|
|
56
|
+
"eslint": "9.36.0",
|
|
55
57
|
"express": "5.2.1",
|
|
56
58
|
"fast-json-patch": "3.1.1",
|
|
57
|
-
"heredoc": "^1.3.1",
|
|
58
59
|
"http-status-codes": "^2.3.0",
|
|
59
60
|
"json-pointer": "^0.6.2",
|
|
60
61
|
"kubernetes-fluent-client": "3.11.6",
|
|
@@ -63,10 +64,7 @@
|
|
|
63
64
|
"prom-client": "15.1.3",
|
|
64
65
|
"quicktype-core": "^23.2.6",
|
|
65
66
|
"ramda": "0.32.0",
|
|
66
|
-
"ts-morph": "^27.0.0"
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "8.45.0",
|
|
68
|
-
"@typescript-eslint/parser": "8.45.0",
|
|
69
|
-
"eslint": "9.36.0"
|
|
67
|
+
"ts-morph": "^27.0.0"
|
|
70
68
|
},
|
|
71
69
|
"devDependencies": {
|
|
72
70
|
"@commitlint/cli": "20.4.3",
|
|
@@ -76,7 +74,6 @@
|
|
|
76
74
|
"@semantic-release/npm": "^13.0.0",
|
|
77
75
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
78
76
|
"@types/command-line-args": "^5.2.3",
|
|
79
|
-
"@types/eslint": "9.6.1",
|
|
80
77
|
"@types/express": "5.0.6",
|
|
81
78
|
"@types/json-pointer": "^1.0.34",
|
|
82
79
|
"@types/json-schema": "^7.0.15",
|
|
@@ -103,7 +100,7 @@
|
|
|
103
100
|
"peerDependencies": {
|
|
104
101
|
"@types/prompts": "2.4.9",
|
|
105
102
|
"esbuild": "0.25.10",
|
|
106
|
-
"node-forge": "1.
|
|
103
|
+
"node-forge": "1.4.0",
|
|
107
104
|
"prettier": "3.6.2",
|
|
108
105
|
"prompts": "2.4.2",
|
|
109
106
|
"typescript": "5.8.3",
|
|
@@ -14,7 +14,12 @@ import { ModuleConfig } from "../types";
|
|
|
14
14
|
import { mutateProcessor } from "../processors/mutate-processor";
|
|
15
15
|
import { validateProcessor } from "../processors/validate-processor";
|
|
16
16
|
import { StoreController } from "./store";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
karForMutate,
|
|
19
|
+
karForValidate,
|
|
20
|
+
KubeAdmissionReview,
|
|
21
|
+
parseWebhookTimeouts,
|
|
22
|
+
} from "./index.util";
|
|
18
23
|
import { AdmissionRequest } from "../common-types";
|
|
19
24
|
import { featureFlagStore } from "../features/store";
|
|
20
25
|
import { GroupVersionKind } from "kubernetes-fluent-client";
|
|
@@ -118,11 +123,16 @@ export class Controller {
|
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
// Create HTTPS server
|
|
121
|
-
const server = https.createServer(options, this.#app)
|
|
126
|
+
const server = https.createServer(options, this.#app);
|
|
127
|
+
|
|
128
|
+
// Tune HTTP timeouts (defaults align with controller-runtime's webhook server)
|
|
129
|
+
const { keepAliveTimeoutMs, headersTimeoutMs } = Controller.#applyTimeouts(server);
|
|
130
|
+
|
|
131
|
+
server.listen(port);
|
|
122
132
|
|
|
123
133
|
// Handle server listening event
|
|
124
134
|
server.on("listening", () => {
|
|
125
|
-
Log.debug(`Server listening on port ${port}`);
|
|
135
|
+
Log.debug({ port, keepAliveTimeoutMs, headersTimeoutMs }, `Server listening on port ${port}`);
|
|
126
136
|
// Track that the server is running
|
|
127
137
|
this.#running = true;
|
|
128
138
|
});
|
|
@@ -274,6 +284,21 @@ export class Controller {
|
|
|
274
284
|
};
|
|
275
285
|
};
|
|
276
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Parse and apply HTTP timeout settings to the server.
|
|
289
|
+
*
|
|
290
|
+
* @param server the HTTPS server to configure
|
|
291
|
+
*/
|
|
292
|
+
static #applyTimeouts(server: https.Server): {
|
|
293
|
+
keepAliveTimeoutMs: number;
|
|
294
|
+
headersTimeoutMs: number;
|
|
295
|
+
} {
|
|
296
|
+
const { keepAliveTimeoutMs, headersTimeoutMs } = parseWebhookTimeouts();
|
|
297
|
+
server.keepAliveTimeout = keepAliveTimeoutMs;
|
|
298
|
+
server.headersTimeout = headersTimeoutMs;
|
|
299
|
+
return { keepAliveTimeoutMs, headersTimeoutMs };
|
|
300
|
+
}
|
|
301
|
+
|
|
277
302
|
/**
|
|
278
303
|
* Middleware for logging requests
|
|
279
304
|
*
|
|
@@ -19,6 +19,16 @@ export function karForMutate(mr: MutateResponse): KubeAdmissionReview {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export function parseWebhookTimeouts(): { keepAliveTimeoutMs: number; headersTimeoutMs: number } {
|
|
23
|
+
const keepAliveTimeoutMs = process.env.PEPR_KEEP_ALIVE_TIMEOUT_MS
|
|
24
|
+
? parseInt(process.env.PEPR_KEEP_ALIVE_TIMEOUT_MS, 10)
|
|
25
|
+
: 90000;
|
|
26
|
+
const headersTimeoutMs = process.env.PEPR_HEADERS_TIMEOUT_MS
|
|
27
|
+
? parseInt(process.env.PEPR_HEADERS_TIMEOUT_MS, 10)
|
|
28
|
+
: 32000;
|
|
29
|
+
return { keepAliveTimeoutMs, headersTimeoutMs };
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
export function karForValidate(ar: AdmissionRequest, vr: ValidateResponse[]): KubeAdmissionReview {
|
|
23
33
|
const isAllowed = vr.filter(r => !r.allowed).length === 0;
|
|
24
34
|
|
package/dist/sdk/heredoc.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"heredoc.d.ts","sourceRoot":"","sources":["../../src/sdk/heredoc.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAgClF"}
|
package/src/sdk/heredoc.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Refs:
|
|
2
|
-
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
|
|
3
|
-
|
|
4
|
-
export function heredoc(strings: TemplateStringsArray, ...values: string[]): string {
|
|
5
|
-
// shuffle strings & expression values back together
|
|
6
|
-
const zipped = strings
|
|
7
|
-
.reduce((acc: string[], cur, idx) => {
|
|
8
|
-
acc.push(cur, values[idx] || "");
|
|
9
|
-
return acc;
|
|
10
|
-
}, [])
|
|
11
|
-
.filter(x => x);
|
|
12
|
-
|
|
13
|
-
// rebuild as line-oriented
|
|
14
|
-
const asLines = zipped.join("").split(/[\r\n]+/);
|
|
15
|
-
|
|
16
|
-
// strip whitespace-only first & last lines
|
|
17
|
-
if (asLines[0].trim().length === 0) asLines.shift();
|
|
18
|
-
if (asLines.slice(-1)[0].trim().length === 0) asLines.pop();
|
|
19
|
-
|
|
20
|
-
// find smallest indent
|
|
21
|
-
const indent = asLines.reduce((acc, cur) => {
|
|
22
|
-
const firstAt = cur.search(/\S/);
|
|
23
|
-
return Math.min(firstAt !== -1 ? firstAt : Number.POSITIVE_INFINITY, acc);
|
|
24
|
-
}, Number.POSITIVE_INFINITY);
|
|
25
|
-
|
|
26
|
-
// de-indent all lines
|
|
27
|
-
const snipped = asLines.map(line => {
|
|
28
|
-
if (line.length < indent) {
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
return line.slice(indent);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// rejoin into multiline string
|
|
35
|
-
return snipped.join("\n");
|
|
36
|
-
}
|