pepr 0.12.2 → 0.13.0
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/CODE_OF_CONDUCT.md +83 -0
- package/CONTRIBUTING.md +70 -0
- package/README.md +28 -30
- package/dist/cli.js +644 -679
- package/dist/controller.js +13 -81
- package/dist/lib/assets/deploy.d.ts +3 -0
- package/dist/lib/assets/deploy.d.ts.map +1 -0
- package/dist/lib/assets/index.d.ts +18 -0
- package/dist/lib/assets/index.d.ts.map +1 -0
- package/dist/lib/assets/loader.d.ts +14 -0
- package/dist/lib/assets/loader.d.ts.map +1 -0
- package/dist/lib/assets/networking.d.ts +6 -0
- package/dist/lib/assets/networking.d.ts.map +1 -0
- package/dist/lib/assets/pods.d.ts +8 -0
- package/dist/lib/assets/pods.d.ts.map +1 -0
- package/dist/lib/assets/rbac.d.ts +11 -0
- package/dist/lib/assets/rbac.d.ts.map +1 -0
- package/dist/lib/assets/webhooks.d.ts +6 -0
- package/dist/lib/assets/webhooks.d.ts.map +1 -0
- package/dist/lib/assets/yaml.d.ts +4 -0
- package/dist/lib/assets/yaml.d.ts.map +1 -0
- package/dist/lib/capability.d.ts +1 -3
- package/dist/lib/capability.d.ts.map +1 -1
- package/dist/lib/controller.d.ts +45 -10
- package/dist/lib/controller.d.ts.map +1 -1
- package/dist/lib/filter.d.ts +1 -1
- package/dist/lib/filter.d.ts.map +1 -1
- package/dist/lib/k8s/index.d.ts +2 -1
- package/dist/lib/k8s/index.d.ts.map +1 -1
- package/dist/lib/k8s/kinds.d.ts.map +1 -1
- package/dist/lib/k8s/types.d.ts +13 -13
- package/dist/lib/k8s/types.d.ts.map +1 -1
- package/dist/lib/k8s/upstream.d.ts +2 -2
- package/dist/lib/k8s/upstream.d.ts.map +1 -1
- package/dist/lib/logger.d.ts +8 -54
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/metrics.d.ts +11 -4
- package/dist/lib/metrics.d.ts.map +1 -1
- package/dist/lib/module.d.ts +2 -2
- package/dist/lib/module.d.ts.map +1 -1
- package/dist/lib/mutate-processor.d.ts +5 -0
- package/dist/lib/mutate-processor.d.ts.map +1 -0
- package/dist/lib/{request.d.ts → mutate-request.d.ts} +5 -5
- package/dist/lib/mutate-request.d.ts.map +1 -0
- package/dist/lib/types.d.ts +45 -46
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/validate-processor.d.ts +4 -0
- package/dist/lib/validate-processor.d.ts.map +1 -0
- package/dist/lib/validate-request.d.ts +54 -0
- package/dist/lib/validate-request.d.ts.map +1 -0
- package/dist/lib.d.ts +3 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +502 -302
- package/dist/lib.js.map +4 -4
- package/package.json +15 -12
- package/src/cli.ts +2 -11
- package/src/lib/assets/deploy.ts +179 -0
- package/src/lib/assets/index.ts +46 -0
- package/src/lib/assets/loader.ts +49 -0
- package/src/lib/assets/networking.ts +58 -0
- package/src/lib/assets/pods.ts +148 -0
- package/src/lib/assets/rbac.ts +57 -0
- package/src/lib/assets/webhooks.ts +139 -0
- package/src/lib/assets/yaml.ts +75 -0
- package/src/lib/capability.ts +54 -44
- package/src/lib/controller.ts +171 -89
- package/src/lib/fetch.ts +1 -1
- package/src/lib/filter.ts +1 -3
- package/src/lib/k8s/index.ts +4 -1
- package/src/lib/k8s/kinds.ts +40 -0
- package/src/lib/k8s/types.ts +16 -14
- package/src/lib/k8s/upstream.ts +5 -1
- package/src/lib/logger.ts +14 -125
- package/src/lib/metrics.ts +67 -23
- package/src/lib/module.ts +13 -11
- package/src/lib/{processor.ts → mutate-processor.ts} +37 -28
- package/src/lib/{request.ts → mutate-request.ts} +4 -4
- package/src/lib/types.ts +51 -51
- package/src/lib/validate-processor.ts +68 -0
- package/src/lib/validate-request.ts +94 -0
- package/src/lib.ts +4 -2
- package/src/runtime/controller.ts +1 -1
- package/dist/lib/k8s/webhook.d.ts +0 -37
- package/dist/lib/k8s/webhook.d.ts.map +0 -1
- package/dist/lib/processor.d.ts +0 -5
- package/dist/lib/processor.d.ts.map +0 -1
- package/dist/lib/request.d.ts.map +0 -1
- package/src/lib/k8s/webhook.ts +0 -643
package/dist/controller.js
CHANGED
|
@@ -30,93 +30,25 @@ var import_fs = __toESM(require("fs"));
|
|
|
30
30
|
var import_zlib = require("zlib");
|
|
31
31
|
|
|
32
32
|
// src/lib/logger.ts
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})(LogLevel || {});
|
|
40
|
-
var Logger = class {
|
|
41
|
-
_logLevel;
|
|
42
|
-
/**
|
|
43
|
-
* Create a new logger instance.
|
|
44
|
-
* @param logLevel - The minimum log level to log messages for.
|
|
45
|
-
*/
|
|
46
|
-
constructor(logLevel) {
|
|
47
|
-
this._logLevel = logLevel;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Change the log level of the logger.
|
|
51
|
-
* @param logLevel - The log level to log the message at.
|
|
52
|
-
*/
|
|
53
|
-
SetLogLevel(logLevel) {
|
|
54
|
-
this._logLevel = LogLevel[logLevel];
|
|
55
|
-
this.debug(`Log level set to ${logLevel}`);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Log a debug message.
|
|
59
|
-
* @param message - The message to log.
|
|
60
|
-
*/
|
|
61
|
-
debug(message, prefix) {
|
|
62
|
-
this.log(0 /* debug */, message, prefix);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Log an info message.
|
|
66
|
-
* @param message - The message to log.
|
|
67
|
-
*/
|
|
68
|
-
info(message, prefix) {
|
|
69
|
-
this.log(1 /* info */, message, prefix);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Log a warning message.
|
|
73
|
-
* @param message - The message to log.
|
|
74
|
-
*/
|
|
75
|
-
warn(message, prefix) {
|
|
76
|
-
this.log(2 /* warn */, message, prefix);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Log an error message.
|
|
80
|
-
* @param message - The message to log.
|
|
81
|
-
*/
|
|
82
|
-
error(message, prefix) {
|
|
83
|
-
this.log(3 /* error */, message, prefix);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Log a message at the specified log level.
|
|
87
|
-
* @param logLevel - The log level of the message.
|
|
88
|
-
* @param message - The message to log.
|
|
89
|
-
*/
|
|
90
|
-
log(logLevel, message, callerPrefix = "") {
|
|
91
|
-
const color = {
|
|
92
|
-
[0 /* debug */]: "\x1B[30m" /* FgBlack */,
|
|
93
|
-
[1 /* info */]: "\x1B[36m" /* FgCyan */,
|
|
94
|
-
[2 /* warn */]: "\x1B[33m" /* FgYellow */,
|
|
95
|
-
[3 /* error */]: "\x1B[31m" /* FgRed */
|
|
96
|
-
};
|
|
97
|
-
if (logLevel >= this._logLevel) {
|
|
98
|
-
let prefix = "[" + LogLevel[logLevel] + "] " + callerPrefix;
|
|
99
|
-
prefix = this.colorize(prefix, color[logLevel]);
|
|
100
|
-
if (typeof message !== "string") {
|
|
101
|
-
console.log(prefix);
|
|
102
|
-
console.debug("%o", message);
|
|
103
|
-
} else {
|
|
104
|
-
console.log(prefix + " " + message);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
colorize(text, color) {
|
|
109
|
-
return color + text + "\x1B[0m" /* Reset */;
|
|
33
|
+
var import_pino = require("pino");
|
|
34
|
+
var isPrettyLog = process.env.PEPR_PRETTY_LOGS === "true";
|
|
35
|
+
var pretty = {
|
|
36
|
+
target: "pino-pretty",
|
|
37
|
+
options: {
|
|
38
|
+
colorize: true
|
|
110
39
|
}
|
|
111
40
|
};
|
|
112
|
-
var
|
|
41
|
+
var transport = isPrettyLog ? pretty : void 0;
|
|
42
|
+
var Log = (0, import_pino.pino)({
|
|
43
|
+
transport
|
|
44
|
+
});
|
|
113
45
|
if (process.env.LOG_LEVEL) {
|
|
114
|
-
Log.
|
|
46
|
+
Log.level = process.env.LOG_LEVEL;
|
|
115
47
|
}
|
|
116
48
|
var logger_default = Log;
|
|
117
49
|
|
|
118
50
|
// src/cli/init/templates/data.json
|
|
119
|
-
var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.
|
|
51
|
+
var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.13.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { prebuild: "rm -fr dist/* && node hack/build-template-data.js", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:e2e", "test:unit": "npm run build && tsc -p tsconfig.tests.json && ava dist/**/*.test.js", "test:e2e": "npm run test:e2e:k3d && npm run test:e2e:build && npm run test:e2e:image && npm run test:e2e:run", "test:e2e:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'", "test:e2e:build": "npm run build && npm pack", "test:e2e:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:e2e:run": "ava hack/e2e.test.mjs --sequential --timeout=2m", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@kubernetes/client-node": "0.18.1", express: "4.18.2", "fast-json-patch": "3.1.1", "http-status-codes": "2.2.0", "node-fetch": "2.7.0", pino: "8.15.0", "pino-pretty": "10.2.0", "prom-client": "14.2.0", ramda: "0.29.0" }, devDependencies: { "@types/eslint": "8.44.2", "@types/express": "4.17.17", "@types/node": "18.x.x", "@types/node-fetch": "2.6.4", "@types/node-forge": "1.3.4", "@types/prettier": "3.0.0", "@types/prompts": "2.4.4", "@types/ramda": "0.29.3", "@types/uuid": "9.0.2", ava: "5.3.1", nock: "13.3.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.4.0", "@typescript-eslint/parser": "6.4.0", commander: "11.0.0", esbuild: "0.19.2", eslint: "8.47.0", "node-forge": "1.3.1", prettier: "3.0.1", prompts: "2.4.2", typescript: "5.1.6", uuid: "9.0.0" }, ava: { failFast: true, verbose: true } };
|
|
120
52
|
|
|
121
53
|
// src/runtime/controller.ts
|
|
122
54
|
var { version } = packageJSON;
|
|
@@ -129,7 +61,7 @@ function validateHash(expectedHash) {
|
|
|
129
61
|
function runModule(expectedHash) {
|
|
130
62
|
const gzPath = `/app/load/module-${expectedHash}.js.gz`;
|
|
131
63
|
const jsPath = `/app/module-${expectedHash}.js`;
|
|
132
|
-
logger_default.
|
|
64
|
+
logger_default.level = "info";
|
|
133
65
|
if (!import_fs.default.existsSync(gzPath)) {
|
|
134
66
|
logger_default.error(`File not found: ${gzPath}`);
|
|
135
67
|
process.exit(1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAO3B,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,iBA6JnE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TLSOut } from "../k8s/tls";
|
|
2
|
+
import { ModuleConfig } from "../types";
|
|
3
|
+
import { ModuleCapabilities } from "./loader";
|
|
4
|
+
export declare class Assets {
|
|
5
|
+
readonly config: ModuleConfig;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly host?: string | undefined;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly tls: TLSOut;
|
|
10
|
+
readonly apiToken: string;
|
|
11
|
+
capabilities: ModuleCapabilities[];
|
|
12
|
+
image: string;
|
|
13
|
+
constructor(config: ModuleConfig, path: string, host?: string | undefined);
|
|
14
|
+
deploy: (webhookTimeout?: number) => Promise<void>;
|
|
15
|
+
zarfYaml: (path: string) => string;
|
|
16
|
+
allYaml: () => Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAU,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAoB,MAAM,UAAU,CAAC;AAGhE,qBAAa,MAAM;IAQf,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,CAAC;IAThB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAG,kBAAkB,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;gBAGH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,oBAAQ;IAaxB,MAAM,oBAA2B,MAAM,mBAGrC;IAEF,QAAQ,SAAU,MAAM,YAA0B;IAElD,OAAO,wBAGL;CACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Binding } from "../types";
|
|
2
|
+
export interface ModuleCapabilities {
|
|
3
|
+
_name: string;
|
|
4
|
+
_description: string;
|
|
5
|
+
_namespaces: string[];
|
|
6
|
+
_bindings: Binding[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Read the capabilities from the module by running it in build mode
|
|
10
|
+
* @param path
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadCapabilities(path: string): Promise<ModuleCapabilities[]>;
|
|
14
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,OAAO,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA4B5E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TLSOut } from "../k8s/tls";
|
|
2
|
+
import { Secret, Service } from "../k8s/upstream";
|
|
3
|
+
export declare function apiTokenSecret(name: string, apiToken: string): Secret;
|
|
4
|
+
export declare function tlsSecret(name: string, tls: TLSOut): Secret;
|
|
5
|
+
export declare function service(name: string): Service;
|
|
6
|
+
//# sourceMappingURL=networking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/networking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAarE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAc3D;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAoB7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Assets } from ".";
|
|
3
|
+
import { Deployment, Namespace, Secret } from "../k8s/upstream";
|
|
4
|
+
/** Generate the pepr-system namespace */
|
|
5
|
+
export declare const namespace: Namespace;
|
|
6
|
+
export declare function deployment(assets: Assets, hash: string): Deployment;
|
|
7
|
+
export declare function moduleSecret(name: string, data: Buffer, hash: string): Secret;
|
|
8
|
+
//# sourceMappingURL=pods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEhE,yCAAyC;AACzC,eAAO,MAAM,SAAS,EAAE,SAIvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAkHnE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB7E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClusterRole, ClusterRoleBinding, ServiceAccount } from "../k8s/upstream";
|
|
2
|
+
/**
|
|
3
|
+
* Grants the controller access to cluster resources beyond the mutating webhook.
|
|
4
|
+
*
|
|
5
|
+
* @todo: should dynamically generate this based on resources used by the module. will also need to explore how this should work for multiple modules.
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function clusterRole(name: string): ClusterRole;
|
|
9
|
+
export declare function clusterRoleBinding(name: string): ClusterRoleBinding;
|
|
10
|
+
export declare function serviceAccount(name: string): ServiceAccount;
|
|
11
|
+
//# sourceMappingURL=rbac.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rbac.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/rbac.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAcrD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAkBnE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAS3D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { V1RuleWithOperations } from "@kubernetes/client-node";
|
|
2
|
+
import { Assets } from ".";
|
|
3
|
+
import { MutatingWebhookConfiguration, ValidatingWebhookConfiguration } from "../k8s/upstream";
|
|
4
|
+
export declare function generateWebhookRules(assets: Assets, isMutateWebhook: boolean): Promise<V1RuleWithOperations[]>;
|
|
5
|
+
export declare function webhookConfig(assets: Assets, mutateOrValidate: "mutate" | "validate", timeoutSeconds?: number): Promise<MutatingWebhookConfiguration | ValidatingWebhookConfiguration | null>;
|
|
6
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAW/F,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,mCA4ClF;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,QAAQ,GAAG,UAAU,EACvC,cAAc,SAAK,GAClB,OAAO,CAAC,4BAA4B,GAAG,8BAA8B,GAAG,IAAI,CAAC,CAkE/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAM3B,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UA0BrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,mBAiC3C"}
|
package/dist/lib/capability.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GroupVersionKind } from "./k8s/types";
|
|
2
|
-
import { Binding, CapabilityCfg, GenericClass,
|
|
2
|
+
import { Binding, CapabilityCfg, GenericClass, WhenSelector } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* A capability is a unit of functionality that can be registered with the Pepr runtime.
|
|
5
5
|
*/
|
|
@@ -7,13 +7,11 @@ export declare class Capability implements CapabilityCfg {
|
|
|
7
7
|
private _name;
|
|
8
8
|
private _description;
|
|
9
9
|
private _namespaces?;
|
|
10
|
-
private _mutateOrValidate;
|
|
11
10
|
private _bindings;
|
|
12
11
|
get bindings(): Binding[];
|
|
13
12
|
get name(): string;
|
|
14
13
|
get description(): string;
|
|
15
14
|
get namespaces(): string[];
|
|
16
|
-
get mutateOrValidate(): HookPhase;
|
|
17
15
|
constructor(cfg: CapabilityCfg);
|
|
18
16
|
/**
|
|
19
17
|
* The When method is used to register a capability action to be executed when a Kubernetes resource is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/lib/capability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/lib/capability.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EACL,OAAO,EAGP,aAAa,EAEb,YAAY,EAIZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,UAAW,YAAW,aAAa;IAC9C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAuB;IAE3C,OAAO,CAAC,SAAS,CAAiB;IAElC,IAAI,QAAQ,IAAI,OAAO,EAAE,CAExB;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;gBAEW,GAAG,EAAE,aAAa;IAS9B;;;;;;;;OAQG;IACH,IAAI,4CAA6C,gBAAgB,qBAuG/D;CACH"}
|
package/dist/lib/controller.d.ts
CHANGED
|
@@ -1,21 +1,56 @@
|
|
|
1
1
|
import { Capability } from "./capability";
|
|
2
|
-
import {
|
|
2
|
+
import { MutateResponse, Request } from "./k8s/types";
|
|
3
3
|
import { ModuleConfig } from "./types";
|
|
4
4
|
export declare class Controller {
|
|
5
|
-
private readonly
|
|
6
|
-
private readonly
|
|
7
|
-
private readonly
|
|
8
|
-
private readonly
|
|
9
|
-
private readonly
|
|
10
|
-
private
|
|
5
|
+
private readonly _config;
|
|
6
|
+
private readonly _capabilities;
|
|
7
|
+
private readonly _beforeHook?;
|
|
8
|
+
private readonly _afterHook?;
|
|
9
|
+
private readonly _app;
|
|
10
|
+
private _running;
|
|
11
11
|
private metricsCollector;
|
|
12
|
-
private
|
|
13
|
-
constructor(
|
|
12
|
+
private _token;
|
|
13
|
+
constructor(_config: ModuleConfig, _capabilities: Capability[], _beforeHook?: ((req: Request) => void) | undefined, _afterHook?: ((res: MutateResponse) => void) | undefined);
|
|
14
|
+
private bindEndpoints;
|
|
14
15
|
/** Start the webhook server */
|
|
15
16
|
startServer: (port: number) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Middleware for logging requests
|
|
19
|
+
*
|
|
20
|
+
* @param req the incoming request
|
|
21
|
+
* @param res the outgoing response
|
|
22
|
+
* @param next the next middleware function
|
|
23
|
+
*/
|
|
16
24
|
private logger;
|
|
25
|
+
/**
|
|
26
|
+
* Validate the token in the request path
|
|
27
|
+
*
|
|
28
|
+
* @param req The incoming request
|
|
29
|
+
* @param res The outgoing response
|
|
30
|
+
* @param next The next middleware function
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
private validateToken;
|
|
34
|
+
/**
|
|
35
|
+
* Health check endpoint handler
|
|
36
|
+
*
|
|
37
|
+
* @param req the incoming request
|
|
38
|
+
* @param res the outgoing response
|
|
39
|
+
*/
|
|
17
40
|
private healthz;
|
|
41
|
+
/**
|
|
42
|
+
* Metrics endpoint handler
|
|
43
|
+
*
|
|
44
|
+
* @param req the incoming request
|
|
45
|
+
* @param res the outgoing response
|
|
46
|
+
*/
|
|
18
47
|
private metrics;
|
|
19
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Admission request handler for both mutate and validate requests
|
|
50
|
+
*
|
|
51
|
+
* @param admissionKind the type of admission request
|
|
52
|
+
* @returns the request handler
|
|
53
|
+
*/
|
|
54
|
+
private admissionReq;
|
|
20
55
|
}
|
|
21
56
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/lib/controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/lib/controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AAIxE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,UAAU;IASnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAX9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAgC;IAGxD,OAAO,CAAC,MAAM,CAAM;gBAGD,OAAO,EAAE,YAAY,EACrB,aAAa,EAAE,UAAU,EAAE,EAC3B,WAAW,CAAC,SAAQ,OAAO,KAAK,IAAI,aAAA,EACpC,UAAU,CAAC,SAAQ,cAAc,KAAK,IAAI,aAAA;IAoB7D,OAAO,CAAC,aAAa,CAmBnB;IAEF,+BAA+B;IACxB,WAAW,SAAU,MAAM,UAqDhC;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAiBZ;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa,CAanB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAOb;IAEF;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAOb;IAEF;;;;;OAKG;IACH,OAAO,CAAC,YAAY,CAwDlB;CACH"}
|
package/dist/lib/filter.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Binding } from "./types";
|
|
|
3
3
|
/**
|
|
4
4
|
* shouldSkipRequest determines if a request should be skipped based on the binding filters.
|
|
5
5
|
*
|
|
6
|
-
* @param binding the
|
|
6
|
+
* @param binding the action binding
|
|
7
7
|
* @param req the incoming request
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
package/dist/lib/filter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,WA2E/D"}
|
package/dist/lib/k8s/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as kind from "./upstream";
|
|
2
|
-
/** a is a collection of K8s types to be used within a
|
|
2
|
+
/** a is a collection of K8s types to be used within a action: `When(a.Configmap)` */
|
|
3
3
|
export { kind as a };
|
|
4
4
|
export { modelToGroupVersionKind, gvkMap, RegisterKind } from "./kinds";
|
|
5
|
+
export declare const isWatchMode: boolean;
|
|
5
6
|
export * from "./types";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,qFAAqF;AACrF,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGxE,eAAO,MAAM,WAAW,SAAyC,CAAC;AAElE,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/kinds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/kinds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAsfnD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAErE;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,YAAY,oBAAoB,gBAAgB,SAUnF,CAAC"}
|
package/dist/lib/k8s/types.d.ts
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KubernetesListObject, KubernetesObject, V1ObjectMeta } from "@kubernetes/client-node";
|
|
2
|
+
export { KubernetesListObject, KubernetesObject };
|
|
2
3
|
export declare enum Operation {
|
|
3
4
|
CREATE = "CREATE",
|
|
4
5
|
UPDATE = "UPDATE",
|
|
5
6
|
DELETE = "DELETE",
|
|
6
7
|
CONNECT = "CONNECT"
|
|
7
8
|
}
|
|
8
|
-
export interface KubernetesObject {
|
|
9
|
-
apiVersion?: string;
|
|
10
|
-
kind?: string;
|
|
11
|
-
metadata?: V1ObjectMeta;
|
|
12
|
-
}
|
|
13
|
-
export interface KubernetesListObject<T extends KubernetesObject> {
|
|
14
|
-
apiVersion?: string;
|
|
15
|
-
kind?: string;
|
|
16
|
-
metadata?: V1ListMeta;
|
|
17
|
-
items: T[];
|
|
18
|
-
}
|
|
19
9
|
/**
|
|
20
10
|
* GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
|
|
21
11
|
* that is not explicitly supported by Pepr. This can be used on its own or as a base class for
|
|
@@ -109,7 +99,7 @@ export interface Request<T = KubernetesObject> {
|
|
|
109
99
|
*/
|
|
110
100
|
readonly options?: any;
|
|
111
101
|
}
|
|
112
|
-
export interface
|
|
102
|
+
export interface MutateResponse {
|
|
113
103
|
/** UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest. */
|
|
114
104
|
uid: string;
|
|
115
105
|
/** Allowed indicates whether or not the admission request was permitted. */
|
|
@@ -127,6 +117,16 @@ export interface Response {
|
|
|
127
117
|
/** warnings is a list of warning messages to return to the requesting API client. */
|
|
128
118
|
warnings?: string[];
|
|
129
119
|
}
|
|
120
|
+
export interface ValidateResponse extends MutateResponse {
|
|
121
|
+
/** Status contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
|
|
122
|
+
status?: {
|
|
123
|
+
/** A machine-readable description of why this operation is in the
|
|
124
|
+
"Failure" status. If this value is empty there is no information available. */
|
|
125
|
+
code: number;
|
|
126
|
+
/** A human-readable description of the status of this operation. */
|
|
127
|
+
message: string;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
130
|
export type WebhookIgnore = {
|
|
131
131
|
/**
|
|
132
132
|
* List of Kubernetes namespaces to always ignore.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** a is a collection of K8s types to be used within
|
|
2
|
-
export { V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CSIStorageCapacity as CSIStorageCapacity, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node";
|
|
1
|
+
/** a is a collection of K8s types to be used within an action: `When(a.Configmap)` */
|
|
2
|
+
export { V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ClusterRole as ClusterRole, V1ClusterRoleBinding as ClusterRoleBinding, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CSIStorageCapacity as CSIStorageCapacity, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1Role as Role, V1RoleBinding as RoleBinding, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node";
|
|
3
3
|
export { GenericKind } from "./types";
|
|
4
4
|
//# sourceMappingURL=upstream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/upstream.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/upstream.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,OAAO,EACL,YAAY,IAAI,UAAU,EAC1B,2BAA2B,IAAI,yBAAyB,EACxD,aAAa,IAAI,WAAW,EAC5B,oBAAoB,IAAI,kBAAkB,EAC1C,WAAW,IAAI,SAAS,EACxB,oBAAoB,IAAI,kBAAkB,EAC1C,SAAS,IAAI,OAAO,EACpB,WAAW,IAAI,SAAS,EACxB,oBAAoB,IAAI,kBAAkB,EAC1C,0BAA0B,IAAI,wBAAwB,EACtD,WAAW,IAAI,SAAS,EACxB,YAAY,IAAI,UAAU,EAC1B,eAAe,IAAI,aAAa,EAChC,yBAAyB,IAAI,uBAAuB,EACpD,SAAS,IAAI,OAAO,EACpB,cAAc,IAAI,YAAY,EAC9B,KAAK,IAAI,GAAG,EACZ,YAAY,IAAI,UAAU,EAC1B,0BAA0B,IAAI,wBAAwB,EACtD,8BAA8B,IAAI,4BAA4B,EAC9D,WAAW,IAAI,SAAS,EACxB,eAAe,IAAI,aAAa,EAChC,MAAM,IAAI,IAAI,EACd,kBAAkB,IAAI,gBAAgB,EACtC,uBAAuB,IAAI,qBAAqB,EAChD,KAAK,IAAI,GAAG,EACZ,qBAAqB,IAAI,mBAAmB,EAC5C,aAAa,IAAI,WAAW,EAC5B,YAAY,IAAI,UAAU,EAC1B,uBAAuB,IAAI,qBAAqB,EAChD,eAAe,IAAI,aAAa,EAChC,MAAM,IAAI,IAAI,EACd,aAAa,IAAI,WAAW,EAC5B,cAAc,IAAI,YAAY,EAC9B,QAAQ,IAAI,MAAM,EAClB,yBAAyB,IAAI,uBAAuB,EACpD,wBAAwB,IAAI,sBAAsB,EAClD,SAAS,IAAI,OAAO,EACpB,gBAAgB,IAAI,cAAc,EAClC,aAAa,IAAI,WAAW,EAC5B,cAAc,IAAI,YAAY,EAC9B,qBAAqB,IAAI,mBAAmB,EAC5C,aAAa,IAAI,WAAW,EAC5B,gCAAgC,IAAI,8BAA8B,EAClE,kBAAkB,IAAI,gBAAgB,GACvC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/lib/logger.d.ts
CHANGED
|
@@ -1,56 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Simple logger class that logs messages at different log levels.
|
|
12
|
-
*/
|
|
13
|
-
export declare class Logger {
|
|
14
|
-
private _logLevel;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new logger instance.
|
|
17
|
-
* @param logLevel - The minimum log level to log messages for.
|
|
18
|
-
*/
|
|
19
|
-
constructor(logLevel: LogLevel);
|
|
20
|
-
/**
|
|
21
|
-
* Change the log level of the logger.
|
|
22
|
-
* @param logLevel - The log level to log the message at.
|
|
23
|
-
*/
|
|
24
|
-
SetLogLevel(logLevel: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* Log a debug message.
|
|
27
|
-
* @param message - The message to log.
|
|
28
|
-
*/
|
|
29
|
-
debug<T>(message: T, prefix?: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Log an info message.
|
|
32
|
-
* @param message - The message to log.
|
|
33
|
-
*/
|
|
34
|
-
info<T>(message: T, prefix?: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Log a warning message.
|
|
37
|
-
* @param message - The message to log.
|
|
38
|
-
*/
|
|
39
|
-
warn<T>(message: T, prefix?: string): void;
|
|
40
|
-
/**
|
|
41
|
-
* Log an error message.
|
|
42
|
-
* @param message - The message to log.
|
|
43
|
-
*/
|
|
44
|
-
error<T>(message: T, prefix?: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* Log a message at the specified log level.
|
|
47
|
-
* @param logLevel - The log level of the message.
|
|
48
|
-
* @param message - The message to log.
|
|
49
|
-
*/
|
|
50
|
-
private log;
|
|
51
|
-
private colorize;
|
|
52
|
-
}
|
|
53
|
-
/** Log is an instance of Logger used to generate log entries. */
|
|
54
|
-
declare const Log: Logger;
|
|
1
|
+
declare const Log: import("pino").Logger<{
|
|
2
|
+
transport: {
|
|
3
|
+
target: string;
|
|
4
|
+
options: {
|
|
5
|
+
colorize: boolean;
|
|
6
|
+
};
|
|
7
|
+
} | undefined;
|
|
8
|
+
}>;
|
|
55
9
|
export default Log;
|
|
56
10
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,GAAG;;;;;;;EAEP,CAAC;AAMH,eAAe,GAAG,CAAC"}
|
package/dist/lib/metrics.d.ts
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare class MetricsCollector {
|
|
5
5
|
private _registry;
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
6
|
+
private _counters;
|
|
7
|
+
private _summaries;
|
|
8
|
+
private _prefix;
|
|
9
|
+
private _metricNames;
|
|
9
10
|
/**
|
|
10
11
|
* Creates a MetricsCollector instance with prefixed metrics.
|
|
11
12
|
* @param {string} [prefix='pepr'] - The prefix for the metric names.
|
|
12
13
|
*/
|
|
13
14
|
constructor(prefix?: string);
|
|
15
|
+
private getMetricName;
|
|
16
|
+
private addMetric;
|
|
17
|
+
addCounter(name: string, help: string): void;
|
|
18
|
+
addSummary(name: string, help: string): void;
|
|
19
|
+
incCounter(name: string): void;
|
|
14
20
|
/**
|
|
15
21
|
* Increments the error counter.
|
|
16
22
|
*/
|
|
@@ -27,8 +33,9 @@ export declare class MetricsCollector {
|
|
|
27
33
|
/**
|
|
28
34
|
* Observes the duration since the provided start time and updates the summary.
|
|
29
35
|
* @param {number} startTime - The start time.
|
|
36
|
+
* @param {string} name - The metrics summary to increment.
|
|
30
37
|
*/
|
|
31
|
-
observeEnd(startTime: number): void;
|
|
38
|
+
observeEnd(startTime: number, name?: string): void;
|
|
32
39
|
/**
|
|
33
40
|
* Fetches the current metrics from the registry.
|
|
34
41
|
* @returns {Promise<string>} The metrics.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/lib/metrics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/lib/metrics.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,UAAU,CAA2C;IAC7D,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,YAAY,CAKlB;IAEF;;;OAGG;gBACS,MAAM,SAAS;IAQ3B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,SAAS;IAkBjB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIrC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIrC,UAAU,CAAC,IAAI,EAAE,MAAM;IAIvB;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,KAAK;IAIL;;;OAGG;IACH,YAAY;IAIZ;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,MAAiC;IAIrE;;;OAGG;IACG,UAAU;CAGjB"}
|
package/dist/lib/module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Capability } from "./capability";
|
|
2
|
-
import { Request,
|
|
2
|
+
import { MutateResponse, Request, ValidateResponse } from "./k8s/types";
|
|
3
3
|
import { ModuleConfig } from "./types";
|
|
4
4
|
export type PackageJSON = {
|
|
5
5
|
description: string;
|
|
@@ -10,7 +10,7 @@ export type PeprModuleOptions = {
|
|
|
10
10
|
/** A user-defined callback to pre-process or intercept a Pepr request from K8s immediately before it is processed */
|
|
11
11
|
beforeHook?: (req: Request) => void;
|
|
12
12
|
/** A user-defined callback to post-process or intercept a Pepr response just before it is returned to K8s */
|
|
13
|
-
afterHook?: (res:
|
|
13
|
+
afterHook?: (res: MutateResponse | ValidateResponse) => void;
|
|
14
14
|
};
|
|
15
15
|
export declare class PeprModule {
|
|
16
16
|
private _controller;
|
package/dist/lib/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,qHAAqH;IACrH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAEpC,6GAA6G;IAC7G,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,CAAC;CAC9D,CAAC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,WAAW,CAAc;IAEjC;;;;;;OAMG;gBACS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,GAAE,UAAU,EAAO,EAAE,IAAI,GAAE,iBAAsB;IA2B7G;;;;;OAKG;IACH,KAAK,CAAC,IAAI,SAAO;CAGlB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Capability } from "./capability";
|
|
2
|
+
import { MutateResponse, Request } from "./k8s/types";
|
|
3
|
+
import { ModuleConfig } from "./types";
|
|
4
|
+
export declare function mutateProcessor(config: ModuleConfig, capabilities: Capability[], req: Request, reqMetadata: Record<string, string>): Promise<MutateResponse>;
|
|
5
|
+
//# sourceMappingURL=mutate-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate-processor.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,OAAO,CAAC,cAAc,CAAC,CA+HzB"}
|