pepr 0.13.0 → 0.13.2
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.js +54 -28
- package/dist/controller.js +1 -1
- package/dist/lib/assets/index.d.ts +5 -6
- package/dist/lib/assets/index.d.ts.map +1 -1
- package/dist/lib/assets/loader.d.ts +2 -8
- package/dist/lib/assets/loader.d.ts.map +1 -1
- package/dist/lib/capability.d.ts +4 -7
- package/dist/lib/capability.d.ts.map +1 -1
- package/dist/lib/controller.d.ts +3 -49
- package/dist/lib/controller.d.ts.map +1 -1
- package/dist/lib/errors.d.ts +12 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/k8s/types.d.ts +5 -1
- package/dist/lib/k8s/types.d.ts.map +1 -1
- package/dist/lib/metrics.d.ts +6 -12
- 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.map +1 -1
- package/dist/lib/mutate-request.d.ts +2 -2
- package/dist/lib/mutate-request.d.ts.map +1 -1
- package/dist/lib/types.d.ts +3 -9
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/validate-processor.d.ts.map +1 -1
- package/dist/lib/validate-request.d.ts +2 -2
- package/dist/lib/validate-request.d.ts.map +1 -1
- package/dist/lib.js +247 -191
- package/dist/lib.js.map +3 -3
- package/jest.config.json +4 -0
- package/journey/before.ts +21 -0
- package/journey/k8s.ts +81 -0
- package/journey/pepr-build.ts +69 -0
- package/journey/pepr-deploy.ts +133 -0
- package/journey/pepr-dev.ts +155 -0
- package/journey/pepr-format.ts +13 -0
- package/journey/pepr-init.ts +12 -0
- package/package.json +20 -21
- package/src/lib/assets/index.ts +15 -8
- package/src/lib/assets/loader.ts +4 -12
- package/src/lib/assets/webhooks.ts +2 -2
- package/src/lib/capability.ts +34 -32
- package/src/lib/controller.ts +111 -93
- package/src/lib/errors.ts +20 -0
- package/src/lib/k8s/types.ts +5 -1
- package/src/lib/metrics.ts +45 -32
- package/src/lib/module.ts +24 -10
- package/src/lib/mutate-processor.ts +5 -3
- package/src/lib/mutate-request.ts +22 -9
- package/src/lib/types.ts +4 -10
- package/src/lib/validate-processor.ts +8 -0
- package/src/lib/validate-request.ts +19 -7
package/dist/cli.js
CHANGED
|
@@ -176,7 +176,7 @@ var import_fs = require("fs");
|
|
|
176
176
|
|
|
177
177
|
// src/lib/logger.ts
|
|
178
178
|
var import_pino = require("pino");
|
|
179
|
-
var isPrettyLog =
|
|
179
|
+
var isPrettyLog = true;
|
|
180
180
|
var pretty = {
|
|
181
181
|
target: "pino-pretty",
|
|
182
182
|
options: {
|
|
@@ -440,8 +440,8 @@ async function generateWebhookRules(assets, isMutateWebhook) {
|
|
|
440
440
|
const { config, capabilities } = assets;
|
|
441
441
|
const rules = [];
|
|
442
442
|
for (const capability of capabilities) {
|
|
443
|
-
console.info(`Module ${config.uuid} has capability: ${capability.
|
|
444
|
-
for (const binding of capability.
|
|
443
|
+
console.info(`Module ${config.uuid} has capability: ${capability.name}`);
|
|
444
|
+
for (const binding of capability.bindings) {
|
|
445
445
|
const { event, kind, isMutate, isValidate } = binding;
|
|
446
446
|
if (isMutateWebhook && !isMutate) {
|
|
447
447
|
continue;
|
|
@@ -672,7 +672,7 @@ function loadCapabilities(path) {
|
|
|
672
672
|
program2.on("message", (message) => {
|
|
673
673
|
const capabilities = message.valueOf();
|
|
674
674
|
for (const capability of capabilities) {
|
|
675
|
-
console.info(`Registered Pepr Capability "${capability.
|
|
675
|
+
console.info(`Registered Pepr Capability "${capability.name}"`);
|
|
676
676
|
}
|
|
677
677
|
resolve4(capabilities);
|
|
678
678
|
});
|
|
@@ -744,6 +744,9 @@ var Assets = class {
|
|
|
744
744
|
this.config = config;
|
|
745
745
|
this.path = path;
|
|
746
746
|
this.host = host;
|
|
747
|
+
this.deploy = this.deploy.bind(this);
|
|
748
|
+
this.zarfYaml = this.zarfYaml.bind(this);
|
|
749
|
+
this.allYaml = this.allYaml.bind(this);
|
|
747
750
|
this.name = `pepr-${config.uuid}`;
|
|
748
751
|
this.image = `ghcr.io/defenseunicorns/pepr/controller:v${config.peprVersion}`;
|
|
749
752
|
this.tls = genTLS(this.host || `${this.name}.pepr-system.svc`);
|
|
@@ -754,15 +757,17 @@ var Assets = class {
|
|
|
754
757
|
apiToken;
|
|
755
758
|
capabilities;
|
|
756
759
|
image;
|
|
757
|
-
|
|
760
|
+
async deploy(webhookTimeout) {
|
|
758
761
|
this.capabilities = await loadCapabilities(this.path);
|
|
759
762
|
await deploy(this, webhookTimeout);
|
|
760
|
-
}
|
|
761
|
-
zarfYaml
|
|
762
|
-
|
|
763
|
+
}
|
|
764
|
+
zarfYaml(path) {
|
|
765
|
+
return zarfYaml(this, path);
|
|
766
|
+
}
|
|
767
|
+
async allYaml() {
|
|
763
768
|
this.capabilities = await loadCapabilities(this.path);
|
|
764
769
|
return allYaml(this);
|
|
765
|
-
}
|
|
770
|
+
}
|
|
766
771
|
};
|
|
767
772
|
|
|
768
773
|
// src/cli/init/templates.ts
|
|
@@ -968,7 +973,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
968
973
|
var readmeMd = '# Pepr Module\n\nThis is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a Kubernetes transformation system\nwritten in Typescript.\n\nThe `capabilities` directory contains all the capabilities for this module. By default,\na capability is a single typescript file in the format of `capability-name.ts` that is\nimported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`.\nBecause this is typescript, you can organize this however you choose, e.g. creating a sub-folder\nper-capability or common logic in shared files or folders.\n\nExample Structure:\n\n```\nModule Root\n\u251C\u2500\u2500 package.json\n\u251C\u2500\u2500 pepr.ts\n\u2514\u2500\u2500 capabilities\n \u251C\u2500\u2500 example-one.ts\n \u251C\u2500\u2500 example-three.ts\n \u2514\u2500\u2500 example-two.ts\n```\n';
|
|
969
974
|
var peprTS = 'import { PeprModule } from "pepr";\n// cfg loads your pepr configuration from package.json\nimport cfg from "./package.json";\n\n// HelloPepr is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\nimport { HelloPepr } from "./capabilities/hello-pepr";\n\n/**\n * This is the main entrypoint for this Pepr module. It is run when the module is started.\n * This is where you register your Pepr configurations and capabilities.\n */\nnew PeprModule(cfg, [\n // "HelloPepr" is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\n HelloPepr,\n\n // Your additional capabilities go here\n]);\n';
|
|
970
975
|
var helloPeprTS = 'import {\n Capability,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n} from "pepr";\n\n/**\n * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.\n * To test this capability you run `pepr dev`and then run the following command:\n * `kubectl apply -f capabilities/hello-pepr.samples.yaml`\n */\nexport const HelloPepr = new Capability({\n name: "hello-pepr",\n description: "A simple example capability to show how things work.",\n namespaces: ["pepr-demo", "pepr-demo-2"],\n});\n\n// Use the \'When\' function to create a new Action\nconst { When } = HelloPepr;\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action removes the label `remove-me` when a Namespace is created.\n * Note we don\'t need to specify the namespace here, because we\'ve already specified\n * it in the Capability definition above.\n */\nWhen(a.Namespace)\n .IsCreated()\n .Mutate(ns => ns.RemoveLabel("remove-me"));\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 1) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is a single action. They can be in the same file or put imported from other files.\n * In this example, when a ConfigMap is created with the name `example-1`, then add a label and annotation.\n *\n * Equivalent to manually running:\n * `kubectl label configmap example-1 pepr=was-here`\n * `kubectl annotate configmap example-1 pepr.dev=annotations-work-too`\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request\n .SetLabel("pepr", "was-here")\n .SetAnnotation("pepr.dev", "annotations-work-too");\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate & Validate Actions (CM Example 2) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This combines 2 different types of actions: \'Mutate\', and \'Validate\'. The order\n * of the actions is required, but each action is optional. In this example, when a ConfigMap is created\n * with the name `example-2`, then add a label and annotation and finally validate that the ConfigMap has the label\n * `pepr`.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n // This Mutate Action will mutate the request before it is persisted to the cluster\n\n // Use `request.Merge()` to merge the new data with the existing data\n request.Merge({\n metadata: {\n labels: {\n pepr: "was-here",\n },\n annotations: {\n "pepr.dev": "annotations-work-too",\n },\n },\n });\n })\n .Validate(request => {\n // This Validate Action will validate the request before it is persisted to the cluster\n\n // Approve the request if the ConfigMap has the label \'pepr\'\n if (request.HasLabel("pepr")) {\n return request.Approve();\n }\n\n // Otherwise, deny the request with an error message (optional)\n return request.Deny("ConfigMap must have label \'pepr\'");\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 2a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action shows a simple validation that will deny any ConfigMap that has the\n * annotation `evil`. Note that the `Deny()` function takes an optional second parameter that is a\n * user-defined status code to return.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .Validate(request => {\n if (request.HasAnnotation("evil")) {\n return request.Deny("No evil CM annotations allowed.", 400);\n }\n\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 3) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action combines different styles. Unlike the previous actions, this one will look\n * for any ConfigMap in the `pepr-demo` namespace that has the label `change=by-label` during either\n * CREATE or UPDATE. Note that all conditions added such as `WithName()`, `WithLabel()`, `InNamespace()`,\n * are ANDs so all conditions must be true for the request to be processed.\n */\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("change", "by-label")\n .Mutate(request => {\n // The K8s object e are going to mutate\n const cm = request.Raw;\n\n // Get the username and uid of the K8s request\n const { username, uid } = request.Request.userInfo;\n\n // Store some data about the request in the configmap\n cm.data["username"] = username;\n cm.data["uid"] = uid;\n\n // You can still mix other ways of making changes too\n request.SetAnnotation("pepr.dev", "making-waves");\n });\n\n// This action validates the label `change=by-label` is deleted\nWhen(a.ConfigMap)\n .IsDeleted()\n .WithLabel("change", "by-label")\n .Validate(request => {\n // Log and then always approve the request\n Log.info("CM with label \'change=by-label\' was deleted.");\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action show how you can use the `Mutate()` function without an inline function.\n * This is useful if you want to keep your actions small and focused on a single task,\n * or if you want to reuse the same function in multiple actions.\n */\nWhen(a.ConfigMap).IsCreated().WithName("example-4").Mutate(example4Cb);\n\n// This function uses the complete type definition, but is not required.\nfunction example4Cb(cm: PeprMutateRequest<a.ConfigMap>) {\n cm.SetLabel("pepr.dev/first", "true");\n cm.SetLabel("pepr.dev/second", "true");\n cm.SetLabel("pepr.dev/third", "true");\n}\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is the same as Example 4, except this only operates on a CM in the `pepr-demo-2` namespace.\n * Note because the Capability defines namespaces, the namespace specified here must be one of those.\n * Alternatively, you can remove the namespace from the Capability definition and specify it here.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .InNamespace("pepr-demo-2")\n .WithName("example-4a")\n .Mutate(example4Cb);\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 5) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`\n * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a\n * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how\n * you can use Pepr to make changes to your K8s objects based on external data.\n *\n * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.\n *\n * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you\n * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to\n * cast the data returned from the API.\n *\n * These are equivalent:\n * ```ts\n * const joke = await fetch<TheChuckNorrisJoke>("https://api.chucknorris.io/jokes/random?category=dev");\n * const joke = await fetch("https://api.chucknorris.io/jokes/random?category=dev") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://api.chucknorris.io/jokes/random?category=dev")\n * ```\n */\ninterface TheChuckNorrisJoke {\n icon_url: string;\n id: string;\n url: string;\n value: string;\n}\n\nWhen(a.ConfigMap)\n .IsCreated()\n .WithLabel("chuck-norris")\n .Mutate(async change => {\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(\n "https://api.chucknorris.io/jokes/random?category=dev",\n );\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n // Add the Chuck Norris joke to the configmap\n change.Raw.data["chuck-says"] = response.data.value;\n return;\n }\n\n // You can also assert on different HTTP response codes\n if (response.status === fetchStatus.NOT_FOUND) {\n // Do something else\n return;\n }\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Secret Base64 Handling) *\n * ---------------------------------------------------------------------------------------------------\n *\n * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,\n * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding\n * secret data before and after the action is executed.\n */\nWhen(a.Secret)\n .IsCreated()\n .WithName("secret-1")\n .Mutate(request => {\n const secret = request.Raw;\n\n // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="\n secret.data.magic = "change-without-encoding";\n\n // You can modify the data directly, and it will be encoded at the end of all processing\n secret.data.example += " - modified by Pepr";\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Untyped Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create\n * your own types. This is useful if you are working with an Operator that creates custom resources.\n * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,\n * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.\n *\n * This example shows how to use the `When()` function with a `GenericKind`. Note that you\n * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows\n * if the action should be triggered or not. Since we are using a `GenericKind`,\n * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the\n * Kubernetes API documentation for the object you are working with.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-1\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```\n */\nWhen(a.GenericKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n})\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr without type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Typed Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This example shows how to use the `RegisterKind()` function to create a new type. This is useful\n * if you are working with an Operator that creates custom resources and you want to have intellisense\n * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)\n * as this is how Pepr knows if the action should be triggered or not.\n *\n * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,\n * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available\n * to all actions, but we are putting it here for demonstration purposes.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-2\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```*\n */\nclass UnicornKind extends a.GenericKind {\n spec: {\n /**\n * JSDoc comments can be added to explain more details about the field.\n *\n * @example\n * ```ts\n * request.Raw.spec.message = "Hello Pepr!";\n * ```\n * */\n message: string;\n counter: number;\n };\n}\n\nRegisterKind(UnicornKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n});\n\nWhen(UnicornKind)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr with type data!",\n counter: Math.random(),\n },\n });\n });\n';
|
|
971
|
-
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.
|
|
976
|
+
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.2", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest journey/entrypoint.test.ts", "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: { "@jest/globals": "29.6.4", "@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.3", jest: "29.6.4", nock: "13.3.3", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.5.0", "@typescript-eslint/parser": "6.5.0", commander: "11.0.0", esbuild: "0.19.2", eslint: "8.48.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.0" } };
|
|
972
977
|
|
|
973
978
|
// src/cli/init/templates/pepr.code-snippets.json
|
|
974
979
|
var pepr_code_snippets_default = {
|
|
@@ -993,6 +998,17 @@ var pepr_code_snippets_default = {
|
|
|
993
998
|
}
|
|
994
999
|
};
|
|
995
1000
|
|
|
1001
|
+
// src/cli/init/templates/settings.json
|
|
1002
|
+
var settings_default = {
|
|
1003
|
+
"debug.javascript.terminalOptions": {
|
|
1004
|
+
enableTurboSourcemaps: true,
|
|
1005
|
+
resolveSourceMapLocations: [
|
|
1006
|
+
"${workspaceFolder}/**",
|
|
1007
|
+
"node_modules/pepr/**"
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
|
|
996
1012
|
// src/cli/init/templates/tsconfig.module.json
|
|
997
1013
|
var tsconfig_module_default = {
|
|
998
1014
|
compilerOptions: {
|
|
@@ -1064,7 +1080,7 @@ function genPkgJSON(opts, pgkVerOverride) {
|
|
|
1064
1080
|
}
|
|
1065
1081
|
},
|
|
1066
1082
|
scripts: {
|
|
1067
|
-
"k3d-setup": scripts["test:
|
|
1083
|
+
"k3d-setup": scripts["test:journey:k3d"]
|
|
1068
1084
|
},
|
|
1069
1085
|
dependencies: {
|
|
1070
1086
|
pepr: pgkVerOverride || version
|
|
@@ -1105,6 +1121,10 @@ var snippet = {
|
|
|
1105
1121
|
path: "pepr.code-snippets",
|
|
1106
1122
|
data: pepr_code_snippets_default
|
|
1107
1123
|
};
|
|
1124
|
+
var codeSettings = {
|
|
1125
|
+
path: "settings.json",
|
|
1126
|
+
data: settings_default
|
|
1127
|
+
};
|
|
1108
1128
|
var tsConfig = {
|
|
1109
1129
|
path: "tsconfig.json",
|
|
1110
1130
|
data: tsconfig_module_default
|
|
@@ -1146,7 +1166,6 @@ function build_default(program2) {
|
|
|
1146
1166
|
const zarf = assets.zarfYaml(yamlFile);
|
|
1147
1167
|
await import_fs4.promises.writeFile(yamlPath, yaml);
|
|
1148
1168
|
await import_fs4.promises.writeFile(zarfPath, zarf);
|
|
1149
|
-
logger_default.debug(`Module compiled successfully at ${path}`);
|
|
1150
1169
|
console.info(`\u2705 K8s resource for the module saved to ${yamlPath}`);
|
|
1151
1170
|
});
|
|
1152
1171
|
}
|
|
@@ -1231,12 +1250,12 @@ async function buildModule(reloader, entryPoint = peprTS2) {
|
|
|
1231
1250
|
}
|
|
1232
1251
|
return { ctx, path, cfg, uuid };
|
|
1233
1252
|
} catch (e) {
|
|
1234
|
-
|
|
1253
|
+
console.error(e.message);
|
|
1235
1254
|
if (e.stdout) {
|
|
1236
1255
|
const out = e.stdout.toString();
|
|
1237
1256
|
const err = e.stderr.toString();
|
|
1238
|
-
|
|
1239
|
-
|
|
1257
|
+
console.log(out);
|
|
1258
|
+
console.error(err);
|
|
1240
1259
|
if (out.includes("Types have separate declarations of a private property '_name'.")) {
|
|
1241
1260
|
const pgkErrMatch = /error TS2322: .*? 'import\("\/.*?\/node_modules\/(.*?)\/node_modules/g;
|
|
1242
1261
|
out.matchAll(pgkErrMatch);
|
|
@@ -1338,7 +1357,8 @@ function dev_default(program2) {
|
|
|
1338
1357
|
PEPR_PRETTY_LOGS: "true",
|
|
1339
1358
|
SSL_KEY_PATH: "insecure-tls.key",
|
|
1340
1359
|
SSL_CERT_PATH: "insecure-tls.crt"
|
|
1341
|
-
}
|
|
1360
|
+
},
|
|
1361
|
+
stdio: "inherit"
|
|
1342
1362
|
});
|
|
1343
1363
|
};
|
|
1344
1364
|
await buildModule(async (r) => {
|
|
@@ -1402,7 +1422,6 @@ function format_default(program2) {
|
|
|
1402
1422
|
}
|
|
1403
1423
|
console.info("\u2705 Module formatted");
|
|
1404
1424
|
} catch (e) {
|
|
1405
|
-
logger_default.debug(e);
|
|
1406
1425
|
console.error(e.message);
|
|
1407
1426
|
process.exit(1);
|
|
1408
1427
|
}
|
|
@@ -1417,6 +1436,16 @@ var import_prompts4 = __toESM(require("prompts"));
|
|
|
1417
1436
|
// src/cli/init/walkthrough.ts
|
|
1418
1437
|
var import_fs7 = require("fs");
|
|
1419
1438
|
var import_prompts3 = __toESM(require("prompts"));
|
|
1439
|
+
|
|
1440
|
+
// src/lib/errors.ts
|
|
1441
|
+
var Errors = {
|
|
1442
|
+
audit: "audit",
|
|
1443
|
+
ignore: "ignore",
|
|
1444
|
+
reject: "reject"
|
|
1445
|
+
};
|
|
1446
|
+
var ErrorList = Object.values(Errors);
|
|
1447
|
+
|
|
1448
|
+
// src/cli/init/walkthrough.ts
|
|
1420
1449
|
function walkthrough() {
|
|
1421
1450
|
const askName = {
|
|
1422
1451
|
type: "text",
|
|
@@ -1444,18 +1473,18 @@ function walkthrough() {
|
|
|
1444
1473
|
choices: [
|
|
1445
1474
|
{
|
|
1446
1475
|
title: "Ignore",
|
|
1447
|
-
value:
|
|
1476
|
+
value: Errors.ignore,
|
|
1448
1477
|
description: "Pepr will continue processing and generate an entry in the Pepr Controller log.",
|
|
1449
1478
|
selected: true
|
|
1450
1479
|
},
|
|
1451
1480
|
{
|
|
1452
1481
|
title: "Log an audit event",
|
|
1453
|
-
value:
|
|
1482
|
+
value: Errors.audit,
|
|
1454
1483
|
description: "Pepr will continue processing and generate an entry in the Pepr Controller log as well as an audit event in the cluster."
|
|
1455
1484
|
},
|
|
1456
1485
|
{
|
|
1457
1486
|
title: "Reject the operation",
|
|
1458
|
-
value:
|
|
1487
|
+
value: Errors.reject,
|
|
1459
1488
|
description: "Pepr will reject the operation and return an error to the client."
|
|
1460
1489
|
}
|
|
1461
1490
|
]
|
|
@@ -1514,6 +1543,7 @@ function init_default(program2) {
|
|
|
1514
1543
|
await write((0, import_path2.resolve)(dirName, tsConfig.path), tsConfig.data);
|
|
1515
1544
|
await write((0, import_path2.resolve)(dirName, peprTS3.path), peprTS3.data);
|
|
1516
1545
|
await write((0, import_path2.resolve)(dirName, ".vscode", snippet.path), snippet.data);
|
|
1546
|
+
await write((0, import_path2.resolve)(dirName, ".vscode", codeSettings.path), codeSettings.data);
|
|
1517
1547
|
await write((0, import_path2.resolve)(dirName, "capabilities", samplesYaml.path), samplesYaml.data);
|
|
1518
1548
|
await write((0, import_path2.resolve)(dirName, "capabilities", helloPepr.path), helloPepr.data);
|
|
1519
1549
|
if (!opts.skipPostInit) {
|
|
@@ -1546,6 +1576,7 @@ function init_default(program2) {
|
|
|
1546
1576
|
// src/cli/root.ts
|
|
1547
1577
|
var import_commander = require("commander");
|
|
1548
1578
|
var RootCmd = class extends import_commander.Command {
|
|
1579
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1549
1580
|
createCommand(name) {
|
|
1550
1581
|
const cmd = new import_commander.Command(name);
|
|
1551
1582
|
cmd.option("-l, --log-level [level]", "Log level: debug, info, warn, error", "info");
|
|
@@ -1585,10 +1616,7 @@ function update_default(program2) {
|
|
|
1585
1616
|
}
|
|
1586
1617
|
console.log(`\u2705 Module updated successfully`);
|
|
1587
1618
|
} catch (e) {
|
|
1588
|
-
|
|
1589
|
-
if (e instanceof Error) {
|
|
1590
|
-
console.error(e.message);
|
|
1591
|
-
}
|
|
1619
|
+
console.error(e.message);
|
|
1592
1620
|
process.exit(1);
|
|
1593
1621
|
}
|
|
1594
1622
|
});
|
|
@@ -1599,6 +1627,7 @@ function update_default(program2) {
|
|
|
1599
1627
|
await write((0, import_path3.resolve)(prettier.path), prettier.data);
|
|
1600
1628
|
await write((0, import_path3.resolve)(tsConfig.path), tsConfig.data);
|
|
1601
1629
|
await write((0, import_path3.resolve)(".vscode", snippet.path), snippet.data);
|
|
1630
|
+
await write((0, import_path3.resolve)(".vscode", codeSettings.path), codeSettings.data);
|
|
1602
1631
|
const samplePath = (0, import_path3.resolve)("capabilities", samplesYaml.path);
|
|
1603
1632
|
if (import_fs8.default.existsSync(samplePath)) {
|
|
1604
1633
|
import_fs8.default.unlinkSync(samplePath);
|
|
@@ -1610,10 +1639,7 @@ function update_default(program2) {
|
|
|
1610
1639
|
}
|
|
1611
1640
|
}
|
|
1612
1641
|
} catch (e) {
|
|
1613
|
-
|
|
1614
|
-
if (e instanceof Error) {
|
|
1615
|
-
console.error(e.message);
|
|
1616
|
-
}
|
|
1642
|
+
console.error(e.message);
|
|
1617
1643
|
process.exit(1);
|
|
1618
1644
|
}
|
|
1619
1645
|
});
|
package/dist/controller.js
CHANGED
|
@@ -48,7 +48,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
48
48
|
var logger_default = Log;
|
|
49
49
|
|
|
50
50
|
// src/cli/init/templates/data.json
|
|
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.
|
|
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.2", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest journey/entrypoint.test.ts", "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: { "@jest/globals": "29.6.4", "@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.3", jest: "29.6.4", nock: "13.3.3", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.5.0", "@typescript-eslint/parser": "6.5.0", commander: "11.0.0", esbuild: "0.19.2", eslint: "8.48.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.0" } };
|
|
52
52
|
|
|
53
53
|
// src/runtime/controller.ts
|
|
54
54
|
var { version } = packageJSON;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TLSOut } from "../k8s/tls";
|
|
2
|
-
import { ModuleConfig } from "../types";
|
|
3
|
-
import { ModuleCapabilities } from "./loader";
|
|
2
|
+
import { CapabilityExport, ModuleConfig } from "../types";
|
|
4
3
|
export declare class Assets {
|
|
5
4
|
readonly config: ModuleConfig;
|
|
6
5
|
readonly path: string;
|
|
@@ -8,11 +7,11 @@ export declare class Assets {
|
|
|
8
7
|
readonly name: string;
|
|
9
8
|
readonly tls: TLSOut;
|
|
10
9
|
readonly apiToken: string;
|
|
11
|
-
capabilities:
|
|
10
|
+
capabilities: CapabilityExport[];
|
|
12
11
|
image: string;
|
|
13
12
|
constructor(config: ModuleConfig, path: string, host?: string | undefined);
|
|
14
|
-
deploy
|
|
15
|
-
zarfYaml
|
|
16
|
-
allYaml
|
|
13
|
+
deploy(webhookTimeout?: number): Promise<void>;
|
|
14
|
+
zarfYaml(path: string): string;
|
|
15
|
+
allYaml(): Promise<string>;
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK1D,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,gBAAgB,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;gBAGH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,oBAAQ;IAkBlB,MAAM,CAAC,cAAc,CAAC,EAAE,MAAM;IAKpC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIf,OAAO;CAId"}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ModuleCapabilities {
|
|
3
|
-
_name: string;
|
|
4
|
-
_description: string;
|
|
5
|
-
_namespaces: string[];
|
|
6
|
-
_bindings: Binding[];
|
|
7
|
-
}
|
|
1
|
+
import { CapabilityExport } from "../types";
|
|
8
2
|
/**
|
|
9
3
|
* Read the capabilities from the module by running it in build mode
|
|
10
4
|
* @param path
|
|
11
5
|
* @returns
|
|
12
6
|
*/
|
|
13
|
-
export declare function loadCapabilities(path: string): Promise<
|
|
7
|
+
export declare function loadCapabilities(path: string): Promise<CapabilityExport[]>;
|
|
14
8
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA4B1E"}
|
package/dist/lib/capability.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { GroupVersionKind } from "./k8s/types";
|
|
2
|
-
import { Binding, CapabilityCfg, GenericClass, WhenSelector } from "./types";
|
|
2
|
+
import { Binding, CapabilityCfg, CapabilityExport, 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
|
*/
|
|
6
|
-
export declare class Capability implements
|
|
7
|
-
private
|
|
8
|
-
private _description;
|
|
9
|
-
private _namespaces?;
|
|
10
|
-
private _bindings;
|
|
6
|
+
export declare class Capability implements CapabilityExport {
|
|
7
|
+
#private;
|
|
11
8
|
get bindings(): Binding[];
|
|
12
9
|
get name(): string;
|
|
13
10
|
get description(): string;
|
|
@@ -22,6 +19,6 @@ export declare class Capability implements CapabilityCfg {
|
|
|
22
19
|
* @param kind if using a custom KubernetesObject not available in `a.*`, specify the GroupVersionKind
|
|
23
20
|
* @returns
|
|
24
21
|
*/
|
|
25
|
-
When
|
|
22
|
+
When<T extends GenericClass>(model: T, kind?: GroupVersionKind): WhenSelector<T>;
|
|
26
23
|
}
|
|
27
24
|
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EACb,gBAAgB,EAEhB,YAAY,EAIZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,UAAW,YAAW,gBAAgB;;IAMjD,IAAI,QAAQ,cAEX;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;gBAEW,GAAG,EAAE,aAAa;IAY9B;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,YAAY,CAAC,CAAC,CAAC;CAuGjF"}
|
package/dist/lib/controller.d.ts
CHANGED
|
@@ -2,55 +2,9 @@ import { Capability } from "./capability";
|
|
|
2
2
|
import { MutateResponse, Request } from "./k8s/types";
|
|
3
3
|
import { ModuleConfig } from "./types";
|
|
4
4
|
export declare class Controller {
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
private readonly _beforeHook?;
|
|
8
|
-
private readonly _afterHook?;
|
|
9
|
-
private readonly _app;
|
|
10
|
-
private _running;
|
|
11
|
-
private metricsCollector;
|
|
12
|
-
private _token;
|
|
13
|
-
constructor(_config: ModuleConfig, _capabilities: Capability[], _beforeHook?: ((req: Request) => void) | undefined, _afterHook?: ((res: MutateResponse) => void) | undefined);
|
|
14
|
-
private bindEndpoints;
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: Request) => void, afterHook?: (res: MutateResponse) => void);
|
|
15
7
|
/** Start the webhook server */
|
|
16
|
-
startServer
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
40
|
-
private healthz;
|
|
41
|
-
/**
|
|
42
|
-
* Metrics endpoint handler
|
|
43
|
-
*
|
|
44
|
-
* @param req the incoming request
|
|
45
|
-
* @param res the outgoing response
|
|
46
|
-
*/
|
|
47
|
-
private metrics;
|
|
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;
|
|
8
|
+
startServer(port: number): void;
|
|
55
9
|
}
|
|
56
10
|
//# 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;AAE1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AAIxE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,UAAU
|
|
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;;gBAoBnB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,EACnC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI;IA4B3C,+BAA+B;IAC/B,WAAW,CAAC,IAAI,EAAE,MAAM;CAyNzB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const Errors: {
|
|
2
|
+
audit: string;
|
|
3
|
+
ignore: string;
|
|
4
|
+
reject: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const ErrorList: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Validate the error or throw an error
|
|
9
|
+
* @param error
|
|
10
|
+
*/
|
|
11
|
+
export declare function ValidateError(error?: string): void;
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;;CAIlB,CAAC;AAEF,eAAO,MAAM,SAAS,UAAwB,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAK,QAIvC"}
|
package/dist/lib/k8s/types.d.ts
CHANGED
|
@@ -110,7 +110,11 @@ export interface MutateResponse {
|
|
|
110
110
|
patch?: string;
|
|
111
111
|
/** The type of Patch. Currently we only allow "JSONPatch". */
|
|
112
112
|
patchType?: "JSONPatch";
|
|
113
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted).
|
|
115
|
+
*
|
|
116
|
+
* See https://kubernetes.io/docs/reference/labels-annotations-taints/audit-annotations/ for more information
|
|
117
|
+
*/
|
|
114
118
|
auditAnnotations?: {
|
|
115
119
|
[key: string]: string;
|
|
116
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;AAElD,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,qBAAa,WAAW;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;IAGI;AACJ,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAA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etricsCollector class handles metrics collection using prom-client and performance hooks.
|
|
3
3
|
*/
|
|
4
4
|
export declare class MetricsCollector {
|
|
5
|
-
private
|
|
6
|
-
private _counters;
|
|
7
|
-
private _summaries;
|
|
8
|
-
private _prefix;
|
|
9
|
-
private _metricNames;
|
|
5
|
+
#private;
|
|
10
6
|
/**
|
|
11
7
|
* Creates a MetricsCollector instance with prefixed metrics.
|
|
12
|
-
* @param
|
|
8
|
+
* @param [prefix='pepr'] - The prefix for the metric names.
|
|
13
9
|
*/
|
|
14
10
|
constructor(prefix?: string);
|
|
15
|
-
private getMetricName;
|
|
16
|
-
private addMetric;
|
|
17
11
|
addCounter(name: string, help: string): void;
|
|
18
12
|
addSummary(name: string, help: string): void;
|
|
19
13
|
incCounter(name: string): void;
|
|
@@ -27,18 +21,18 @@ export declare class MetricsCollector {
|
|
|
27
21
|
alert(): void;
|
|
28
22
|
/**
|
|
29
23
|
* Returns the current timestamp from performance.now() method. Useful for start timing an operation.
|
|
30
|
-
* @returns
|
|
24
|
+
* @returns The timestamp.
|
|
31
25
|
*/
|
|
32
26
|
observeStart(): number;
|
|
33
27
|
/**
|
|
34
28
|
* Observes the duration since the provided start time and updates the summary.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
29
|
+
* @param startTime - The start time.
|
|
30
|
+
* @param name - The metrics summary to increment.
|
|
37
31
|
*/
|
|
38
32
|
observeEnd(startTime: number, name?: string): void;
|
|
39
33
|
/**
|
|
40
34
|
* Fetches the current metrics from the registry.
|
|
41
|
-
* @returns
|
|
35
|
+
* @returns The metrics.
|
|
42
36
|
*/
|
|
43
37
|
getMetrics(): Promise<string>;
|
|
44
38
|
}
|
|
@@ -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":"AAwBA;;GAEG;AACH,qBAAa,gBAAgB;;IAa3B;;;OAGG;gBACS,MAAM,SAAS;IAyC3B,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
|
@@ -13,13 +13,13 @@ export type PeprModuleOptions = {
|
|
|
13
13
|
afterHook?: (res: MutateResponse | ValidateResponse) => void;
|
|
14
14
|
};
|
|
15
15
|
export declare class PeprModule {
|
|
16
|
-
private
|
|
16
|
+
#private;
|
|
17
17
|
/**
|
|
18
18
|
* Create a new Pepr runtime
|
|
19
19
|
*
|
|
20
20
|
* @param config The configuration for the Pepr runtime
|
|
21
21
|
* @param capabilities The capabilities to be loaded into the Pepr runtime
|
|
22
|
-
* @param
|
|
22
|
+
* @param opts Options for the Pepr runtime
|
|
23
23
|
*/
|
|
24
24
|
constructor({ description, pepr }: PackageJSON, capabilities?: Capability[], opts?: PeprModuleOptions);
|
|
25
25
|
/**
|
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;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,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;;IAGrB;;;;;;OAMG;gBACS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,GAAE,UAAU,EAAO,EAAE,IAAI,GAAE,iBAAsB;IAwC7G;;;;;OAKG;IACH,KAAK,CAAC,IAAI,SAAO;CAGlB"}
|
|
@@ -1 +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;
|
|
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;AAG1C,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,CAgIzB"}
|
|
@@ -5,7 +5,7 @@ import { DeepPartial } from "./types";
|
|
|
5
5
|
* of a mutating webhook request.
|
|
6
6
|
*/
|
|
7
7
|
export declare class PeprMutateRequest<T extends KubernetesObject> {
|
|
8
|
-
private
|
|
8
|
+
#private;
|
|
9
9
|
Raw: T;
|
|
10
10
|
get PermitSideEffects(): boolean;
|
|
11
11
|
/**
|
|
@@ -27,7 +27,7 @@ export declare class PeprMutateRequest<T extends KubernetesObject> {
|
|
|
27
27
|
* Creates a new instance of the action class.
|
|
28
28
|
* @param input - The request object containing the Kubernetes resource to modify.
|
|
29
29
|
*/
|
|
30
|
-
constructor(
|
|
30
|
+
constructor(input: Request<T>);
|
|
31
31
|
/**
|
|
32
32
|
* Deep merges the provided object with the current resource.
|
|
33
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutate-request.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAa,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,gBAAgB
|
|
1
|
+
{"version":3,"file":"mutate-request.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAa,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,gBAAgB;;IACvD,GAAG,EAAE,CAAC,CAAC;IAIP,IAAI,iBAAiB,YAEpB;IAED;;;OAGG;IACH,IAAI,QAAQ,wBAEX;IAED;;;OAGG;IACH,IAAI,WAAW,kBAEd;IAED;;;OAGG;IACH,IAAI,OAAO,eAEV;IAED;;;OAGG;gBACS,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAyB7B;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;IAIzB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAUnC;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAUxC;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM;IAQvB;;;;OAIG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAQ5B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM;IAIpB;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM;CAG1B"}
|