pepr 0.49.0-nightly.7 → 0.49.0-nightly.9
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
CHANGED
|
@@ -8854,7 +8854,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
8854
8854
|
var readmeMd = '# Pepr Module\n\nThis is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system.\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';
|
|
8855
8855
|
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';
|
|
8856
8856
|
var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\nimport { MockAgent, setGlobalDispatcher } from "undici";\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, use \'Store\' to persist data\nconst { When, Store } = 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 * Watch Action with K8s SSA (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action watches for the `pepr-demo-2` namespace to be created, then creates a ConfigMap with\n * the name `pepr-ssa-demo` and adds the namespace UID to the ConfigMap data. Because Pepr uses\n * server-side apply for this operation, the ConfigMap will be created or updated if it already exists.\n */\nWhen(a.Namespace)\n .IsCreated()\n .WithName("pepr-demo-2")\n .Watch(async ns => {\n Log.info("Namespace pepr-demo-2 was created.");\n\n try {\n // Apply the ConfigMap using K8s server-side apply\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: "pepr-ssa-demo",\n namespace: "pepr-demo-2",\n },\n data: {\n "ns-uid": ns.metadata.uid,\n },\n });\n } catch (error) {\n // You can use the Log object to log messages to the Pepr controller pod\n Log.error(error, "Failed to apply ConfigMap using server-side apply.");\n }\n\n // You can share data between actions using the Store, including between different types of actions\n Store.setItem("watch-data", "This data was stored by a Watch Action.");\n });\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.SetLabel("pepr", "was-here").SetAnnotation("pepr.dev", "annotations-work-too");\n\n // Use the Store to persist data between requests and Pepr controller pods\n Store.setItem("example-1", "was-here");\n\n // This data is written asynchronously and can be read back via `Store.getItem()` or `Store.subscribe()`\n Store.setItem("example-1-data", JSON.stringify(request.Raw.data));\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate & Validate Actions (CM Example 2) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This combines 3 different types of actions: \'Mutate\', \'Validate\', and \'Watch\'. 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, validate that the ConfigMap has the label\n * `pepr`, and log the request.\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 .Watch((cm, phase) => {\n // This Watch Action will watch the ConfigMap after it has been persisted to the cluster\n Log.info(cm, `ConfigMap was ${phase} with the name example-2`);\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).IsCreated().InNamespace("pepr-demo-2").WithName("example-4a").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://icanhazdadjoke.com/");\n * const joke = await fetch("https://icanhazdadjoke.com/") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://icanhazdadjoke.com")\n * ```\n */\ninterface TheChuckNorrisJoke {\n id: string;\n joke: string;\n status: number;\n}\n\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("chuck-norris")\n .Mutate(cm => cm.SetLabel("got-jokes", "true"))\n .Watch(async cm => {\n const jokeURL = "https://icanhazdadjoke.com";\n\n const mockAgent: MockAgent = new MockAgent();\n setGlobalDispatcher(mockAgent);\n const mockClient = mockAgent.get(jokeURL);\n mockClient.intercept({ path: "/", method: "GET" }).reply(\n 200,\n {\n id: "R7UfaahVfFd",\n joke: "Funny joke goes here.",\n status: 200,\n },\n {\n headers: {\n "Content-Type": "application/json; charset=utf-8",\n },\n },\n );\n\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(jokeURL, {\n headers: {\n Accept: "application/json",\n },\n });\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n const { joke } = response.data;\n // Add Joke to the Store\n await Store.setItemAndWait(jokeURL, joke);\n // Add the Chuck Norris joke to the configmap\n try {\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: cm.metadata.name,\n namespace: cm.metadata.namespace,\n },\n data: {\n "chuck-says": Store.getItem(jokeURL),\n },\n });\n } catch (error) {\n Log.error(error, "Failed to apply ConfigMap using server-side apply.", {\n cm,\n });\n }\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\n/**\n * A callback function that is called once the Pepr Store is fully loaded.\n */\nStore.onReady(data => {\n Log.info(data, "Pepr Store Ready");\n});\n';
|
|
8857
|
-
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*", "!src/cli/docs/**"], version: "0.49.0-nightly.
|
|
8857
|
+
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*", "!src/cli/docs/**"], version: "0.49.0-nightly.9", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { ci: "npm ci", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) .", "set:version": "node scripts/set-version.js", test: "npm run test:unit && npm run test:journey && npm run test:journey-wasm", "test:artifacts": "npm run build && jest src/build-artifact.test.ts", "test:docs": "jest --verbose src/cli/docs/*.test.ts", "test:integration": "npm run test:integration:prep && npm run test:integration:run", "test:integration:prep": "./integration/prep.sh", "test:integration:run": "jest --maxWorkers=4 integration", "test:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey-wasm:unicorn": "npm run test:journey:k3d && npm run build && npm run test:journey:image:unicorn && npm run test:journey:run-wasm", "test:journey:image": "docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr:dev -c pepr-dev", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "test:unit": 'npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns="build-artifact.test.ts|src/cli/docs/.*\\.test\\.ts"', "format:check": "eslint src && prettier --config .prettierrc src --check", "format:fix": "eslint src --fix && prettier --config .prettierrc src --write", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", express: "5.1.0", "fast-json-patch": "3.1.1", heredoc: "^1.3.1", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.5.3", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0", "ts-morph": "^25.0.1" }, devDependencies: { "@commitlint/cli": "19.8.0", "@commitlint/config-conventional": "19.8.0", "@fast-check/jest": "^2.0.1", "@jest/globals": "29.7.0", "@types/eslint": "9.6.1", "@types/express": "5.0.1", "@types/json-pointer": "^1.0.34", "@types/node": "22.x.x", "@types/node-forge": "1.3.11", "@types/uuid": "10.0.0", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", jest: "29.7.0", "js-yaml": "^4.1.0", shellcheck: "^3.0.0", "ts-jest": "29.3.2", undici: "^7.0.1" }, overrides: { glob: "^9.0.0" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.23.0", "@typescript-eslint/parser": "8.23.0", commander: "13.1.0", esbuild: "0.25.0", eslint: "8.57.0", "node-forge": "1.3.1", prettier: "3.4.2", prompts: "2.4.2", typescript: "5.7.3", uuid: "11.0.5" } };
|
|
8858
8858
|
|
|
8859
8859
|
// src/cli/init/utils.ts
|
|
8860
8860
|
var import_fs4 = require("fs");
|
package/dist/controller.js
CHANGED
|
@@ -51,7 +51,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
51
51
|
var logger_default = Log;
|
|
52
52
|
|
|
53
53
|
// src/templates/data.json
|
|
54
|
-
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*", "!src/cli/docs/**"], version: "0.49.0-nightly.
|
|
54
|
+
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*", "!src/cli/docs/**"], version: "0.49.0-nightly.9", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { ci: "npm ci", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) .", "set:version": "node scripts/set-version.js", test: "npm run test:unit && npm run test:journey && npm run test:journey-wasm", "test:artifacts": "npm run build && jest src/build-artifact.test.ts", "test:docs": "jest --verbose src/cli/docs/*.test.ts", "test:integration": "npm run test:integration:prep && npm run test:integration:run", "test:integration:prep": "./integration/prep.sh", "test:integration:run": "jest --maxWorkers=4 integration", "test:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey-wasm:unicorn": "npm run test:journey:k3d && npm run build && npm run test:journey:image:unicorn && npm run test:journey:run-wasm", "test:journey:image": "docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr:dev -c pepr-dev", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "test:unit": 'npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns="build-artifact.test.ts|src/cli/docs/.*\\.test\\.ts"', "format:check": "eslint src && prettier --config .prettierrc src --check", "format:fix": "eslint src --fix && prettier --config .prettierrc src --write", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", express: "5.1.0", "fast-json-patch": "3.1.1", heredoc: "^1.3.1", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.5.3", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0", "ts-morph": "^25.0.1" }, devDependencies: { "@commitlint/cli": "19.8.0", "@commitlint/config-conventional": "19.8.0", "@fast-check/jest": "^2.0.1", "@jest/globals": "29.7.0", "@types/eslint": "9.6.1", "@types/express": "5.0.1", "@types/json-pointer": "^1.0.34", "@types/node": "22.x.x", "@types/node-forge": "1.3.11", "@types/uuid": "10.0.0", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", jest: "29.7.0", "js-yaml": "^4.1.0", shellcheck: "^3.0.0", "ts-jest": "29.3.2", undici: "^7.0.1" }, overrides: { glob: "^9.0.0" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.23.0", "@typescript-eslint/parser": "8.23.0", commander: "13.1.0", esbuild: "0.25.0", eslint: "8.57.0", "node-forge": "1.3.1", prettier: "3.4.2", prompts: "2.4.2", typescript: "5.7.3", uuid: "11.0.5" } };
|
|
55
55
|
|
|
56
56
|
// src/lib/k8s.ts
|
|
57
57
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-processor.d.ts","sourceRoot":"","sources":["../../../src/lib/processors/validate-processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,mBAAmB,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,GACzD,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"validate-processor.d.ts","sourceRoot":"","sources":["../../../src/lib/processors/validate-processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,mBAAmB,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,GACzD,OAAO,CAAC,gBAAgB,CAAC,CA4C3B;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,GAAG,EAAE,gBAAgB,EACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA4C7B"}
|
package/dist/lib.js
CHANGED
|
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
for (var
|
|
10
|
-
__defProp(target,
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -428,11 +428,11 @@ var Capability = class {
|
|
|
428
428
|
* @returns
|
|
429
429
|
*/
|
|
430
430
|
OnSchedule = (schedule) => {
|
|
431
|
-
const { name
|
|
431
|
+
const { name, every, unit, run, startTime, completions } = schedule;
|
|
432
432
|
this.hasSchedule = true;
|
|
433
433
|
if (process.env.PEPR_WATCH_MODE === "true" || process.env.PEPR_MODE === "dev") {
|
|
434
434
|
const newSchedule = {
|
|
435
|
-
name
|
|
435
|
+
name,
|
|
436
436
|
every,
|
|
437
437
|
unit,
|
|
438
438
|
run,
|
|
@@ -693,9 +693,9 @@ var Capability = class {
|
|
|
693
693
|
binding.filters.regexName = regexName.source;
|
|
694
694
|
return commonChain;
|
|
695
695
|
}
|
|
696
|
-
function WithName(
|
|
697
|
-
logger_default.debug(`Add name filter ${
|
|
698
|
-
binding.filters.name =
|
|
696
|
+
function WithName(name) {
|
|
697
|
+
logger_default.debug(`Add name filter ${name}`, prefix);
|
|
698
|
+
binding.filters.name = name;
|
|
699
699
|
return commonChain;
|
|
700
700
|
}
|
|
701
701
|
function WithLabel(key, value = "") {
|
|
@@ -777,34 +777,34 @@ var MetricsCollector = class {
|
|
|
777
777
|
"count"
|
|
778
778
|
]);
|
|
779
779
|
}
|
|
780
|
-
#getMetricName = (
|
|
781
|
-
#addMetric = (collection, MetricType, { name
|
|
782
|
-
if (collection.has(this.#getMetricName(
|
|
783
|
-
logger_default.debug(`Metric for ${
|
|
780
|
+
#getMetricName = (name) => `${this.#prefix}_${name}`;
|
|
781
|
+
#addMetric = (collection, MetricType, { name, help, labelNames }) => {
|
|
782
|
+
if (collection.has(this.#getMetricName(name))) {
|
|
783
|
+
logger_default.debug(`Metric for ${name} already exists`, loggingPrefix);
|
|
784
784
|
return;
|
|
785
785
|
}
|
|
786
786
|
const metric = new MetricType({
|
|
787
|
-
name: this.#getMetricName(
|
|
787
|
+
name: this.#getMetricName(name),
|
|
788
788
|
help,
|
|
789
789
|
registers: [this.#registry],
|
|
790
790
|
labelNames
|
|
791
791
|
});
|
|
792
|
-
collection.set(this.#getMetricName(
|
|
792
|
+
collection.set(this.#getMetricName(name), metric);
|
|
793
793
|
};
|
|
794
|
-
addCounter = (
|
|
795
|
-
this.#addMetric(this.#counters, import_prom_client.default.Counter, { name
|
|
794
|
+
addCounter = (name, help) => {
|
|
795
|
+
this.#addMetric(this.#counters, import_prom_client.default.Counter, { name, help, labelNames: [] });
|
|
796
796
|
};
|
|
797
|
-
addSummary = (
|
|
798
|
-
this.#addMetric(this.#summaries, import_prom_client.default.Summary, { name
|
|
797
|
+
addSummary = (name, help) => {
|
|
798
|
+
this.#addMetric(this.#summaries, import_prom_client.default.Summary, { name, help, labelNames: [] });
|
|
799
799
|
};
|
|
800
|
-
addGauge = (
|
|
801
|
-
this.#addMetric(this.#gauges, import_prom_client.default.Gauge, { name
|
|
800
|
+
addGauge = (name, help, labelNames) => {
|
|
801
|
+
this.#addMetric(this.#gauges, import_prom_client.default.Gauge, { name, help, labelNames });
|
|
802
802
|
};
|
|
803
|
-
incCounter = (
|
|
804
|
-
this.#counters.get(this.#getMetricName(
|
|
803
|
+
incCounter = (name) => {
|
|
804
|
+
this.#counters.get(this.#getMetricName(name))?.inc();
|
|
805
805
|
};
|
|
806
|
-
incGauge = (
|
|
807
|
-
this.#gauges.get(this.#getMetricName(
|
|
806
|
+
incGauge = (name, labels, value = 1) => {
|
|
807
|
+
this.#gauges.get(this.#getMetricName(name))?.inc(labels || {}, value);
|
|
808
808
|
};
|
|
809
809
|
/**
|
|
810
810
|
* Increments the error counter.
|
|
@@ -819,8 +819,8 @@ var MetricsCollector = class {
|
|
|
819
819
|
* @param startTime - The start time.
|
|
820
820
|
* @param name - The metrics summary to increment.
|
|
821
821
|
*/
|
|
822
|
-
observeEnd = (startTime,
|
|
823
|
-
this.#summaries.get(this.#getMetricName(
|
|
822
|
+
observeEnd = (startTime, name = this.#metricNames.mutate) => {
|
|
823
|
+
this.#summaries.get(this.#getMetricName(name))?.observe(import_perf_hooks.performance.now() - startTime);
|
|
824
824
|
};
|
|
825
825
|
/**
|
|
826
826
|
* Fetches the current metrics from the registry.
|
|
@@ -1449,11 +1449,11 @@ function reencodeData(wrapped, skipped) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
|
|
1451
1451
|
// src/lib/processors/mutate-processor.ts
|
|
1452
|
-
function updateStatus(config,
|
|
1452
|
+
function updateStatus(config, name, wrapped, status) {
|
|
1453
1453
|
if (wrapped.Request.operation === "DELETE") {
|
|
1454
1454
|
return wrapped;
|
|
1455
1455
|
}
|
|
1456
|
-
wrapped.SetAnnotation(`${config.uuid}.pepr.dev/${
|
|
1456
|
+
wrapped.SetAnnotation(`${config.uuid}.pepr.dev/${name}`, status);
|
|
1457
1457
|
return wrapped;
|
|
1458
1458
|
}
|
|
1459
1459
|
function logMutateErrorMessage(e) {
|
|
@@ -1468,16 +1468,16 @@ function logMutateErrorMessage(e) {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
1470
|
async function processRequest(bindable, wrapped, response) {
|
|
1471
|
-
const { binding, actMeta, name
|
|
1471
|
+
const { binding, actMeta, name, config } = bindable;
|
|
1472
1472
|
const label = binding.mutateCallback.name;
|
|
1473
1473
|
logger_default.info(actMeta, `Processing mutation action (${label})`);
|
|
1474
|
-
wrapped = updateStatus(config,
|
|
1474
|
+
wrapped = updateStatus(config, name, wrapped, "started");
|
|
1475
1475
|
try {
|
|
1476
1476
|
await binding.mutateCallback(wrapped);
|
|
1477
1477
|
logger_default.info(actMeta, `Mutation action succeeded (${label})`);
|
|
1478
|
-
wrapped = updateStatus(config,
|
|
1478
|
+
wrapped = updateStatus(config, name, wrapped, "succeeded");
|
|
1479
1479
|
} catch (e) {
|
|
1480
|
-
wrapped = updateStatus(config,
|
|
1480
|
+
wrapped = updateStatus(config, name, wrapped, "warning");
|
|
1481
1481
|
response.warnings = response.warnings || [];
|
|
1482
1482
|
const errorMessage = logMutateErrorMessage(e);
|
|
1483
1483
|
logger_default.error(actMeta, `Action failed: ${errorMessage}`);
|
|
@@ -1660,7 +1660,7 @@ async function processRequest2(binding, actionMetadata, peprValidateRequest) {
|
|
|
1660
1660
|
if (callbackResp.statusCode || callbackResp.statusMessage) {
|
|
1661
1661
|
valResp.status = {
|
|
1662
1662
|
code: callbackResp.statusCode || 400,
|
|
1663
|
-
message: callbackResp.statusMessage || `Validation failed for ${name}`
|
|
1663
|
+
message: callbackResp.statusMessage || `Validation failed for ${peprValidateRequest.Request.kind.kind.toLowerCase()}/${peprValidateRequest.Request.name}${peprValidateRequest.Request.namespace ? ` in ${peprValidateRequest.Request.namespace} namespace.` : ""}`
|
|
1664
1664
|
};
|
|
1665
1665
|
}
|
|
1666
1666
|
if (callbackResp.warnings && callbackResp.warnings.length > 0) {
|
|
@@ -1690,8 +1690,8 @@ async function validateProcessor(config, capabilities, req, reqMetadata) {
|
|
|
1690
1690
|
convertFromBase64Map(wrapped.Raw);
|
|
1691
1691
|
}
|
|
1692
1692
|
logger_default.info(reqMetadata, `Processing validation request`);
|
|
1693
|
-
for (const { name
|
|
1694
|
-
const actionMetadata = { ...reqMetadata, name
|
|
1693
|
+
for (const { name, bindings, namespaces } of capabilities) {
|
|
1694
|
+
const actionMetadata = { ...reqMetadata, name };
|
|
1695
1695
|
for (const binding of bindings) {
|
|
1696
1696
|
if (!binding.validateCallback) {
|
|
1697
1697
|
continue;
|
|
@@ -1734,12 +1734,12 @@ var peprStoreGVK = {
|
|
|
1734
1734
|
// src/lib/controller/storeCache.ts
|
|
1735
1735
|
var import_kubernetes_fluent_client4 = require("kubernetes-fluent-client");
|
|
1736
1736
|
var import_http_status_codes = require("http-status-codes");
|
|
1737
|
-
var sendUpdatesAndFlushCache = async (cache, namespace2,
|
|
1737
|
+
var sendUpdatesAndFlushCache = async (cache, namespace2, name) => {
|
|
1738
1738
|
const indexes = Object.keys(cache);
|
|
1739
1739
|
const payload = Object.values(cache);
|
|
1740
1740
|
try {
|
|
1741
1741
|
if (payload.length > 0) {
|
|
1742
|
-
await (0, import_kubernetes_fluent_client4.K8s)(Store, { namespace: namespace2, name
|
|
1742
|
+
await (0, import_kubernetes_fluent_client4.K8s)(Store, { namespace: namespace2, name }).Patch(updateCacheID(payload));
|
|
1743
1743
|
Object.keys(cache).forEach((key) => delete cache[key]);
|
|
1744
1744
|
}
|
|
1745
1745
|
} catch (err) {
|
|
@@ -1784,9 +1784,9 @@ function updateCacheID(payload) {
|
|
|
1784
1784
|
var import_ramda11 = require("ramda");
|
|
1785
1785
|
var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
|
|
1786
1786
|
async function migrateAndSetupWatch(storeData) {
|
|
1787
|
-
const { store, namespace: namespace2, name
|
|
1787
|
+
const { store, namespace: namespace2, name, stores, setupWatch: setupWatch2 } = storeData;
|
|
1788
1788
|
logger_default.debug(redactedStore(store), "Pepr Store migration");
|
|
1789
|
-
await (0, import_kubernetes_fluent_client5.K8s)(Store, { namespace: namespace2, name
|
|
1789
|
+
await (0, import_kubernetes_fluent_client5.K8s)(Store, { namespace: namespace2, name }).Patch([
|
|
1790
1790
|
{
|
|
1791
1791
|
op: "add",
|
|
1792
1792
|
path: "/metadata/labels/pepr.dev-cacheID",
|
|
@@ -1795,15 +1795,15 @@ async function migrateAndSetupWatch(storeData) {
|
|
|
1795
1795
|
]);
|
|
1796
1796
|
const data = store.data;
|
|
1797
1797
|
let storeCache = {};
|
|
1798
|
-
for (const
|
|
1799
|
-
const offset = `${
|
|
1798
|
+
for (const name2 of Object.keys(stores)) {
|
|
1799
|
+
const offset = `${name2}-`.length;
|
|
1800
1800
|
for (const key of Object.keys(data)) {
|
|
1801
|
-
if ((0, import_ramda11.startsWith)(
|
|
1802
|
-
storeCache = fillStoreCache(storeCache,
|
|
1801
|
+
if ((0, import_ramda11.startsWith)(name2, key) && !(0, import_ramda11.startsWith)(`${name2}-v2`, key)) {
|
|
1802
|
+
storeCache = fillStoreCache(storeCache, name2, "remove", {
|
|
1803
1803
|
key: [key.slice(offset)],
|
|
1804
1804
|
value: data[key]
|
|
1805
1805
|
});
|
|
1806
|
-
storeCache = fillStoreCache(storeCache,
|
|
1806
|
+
storeCache = fillStoreCache(storeCache, name2, "add", {
|
|
1807
1807
|
key: [key.slice(offset)],
|
|
1808
1808
|
value: data[key],
|
|
1809
1809
|
version: "v2"
|
|
@@ -1811,7 +1811,7 @@ async function migrateAndSetupWatch(storeData) {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
|
-
storeCache = await sendUpdatesAndFlushCache(storeCache, namespace2,
|
|
1814
|
+
storeCache = await sendUpdatesAndFlushCache(storeCache, namespace2, name);
|
|
1815
1815
|
setupWatch2();
|
|
1816
1816
|
}
|
|
1817
1817
|
|
|
@@ -1824,29 +1824,29 @@ var StoreController = class {
|
|
|
1824
1824
|
#stores = {};
|
|
1825
1825
|
#sendDebounce;
|
|
1826
1826
|
#onReady;
|
|
1827
|
-
constructor(capabilities,
|
|
1827
|
+
constructor(capabilities, name, onReady) {
|
|
1828
1828
|
this.#onReady = onReady;
|
|
1829
|
-
this.#name =
|
|
1830
|
-
const setStorageInstance = (registrationFunction,
|
|
1829
|
+
this.#name = name;
|
|
1830
|
+
const setStorageInstance = (registrationFunction, name2) => {
|
|
1831
1831
|
const scheduleStore = registrationFunction();
|
|
1832
|
-
scheduleStore.registerSender(this.#send(
|
|
1833
|
-
this.#stores[
|
|
1832
|
+
scheduleStore.registerSender(this.#send(name2));
|
|
1833
|
+
this.#stores[name2] = scheduleStore;
|
|
1834
1834
|
};
|
|
1835
|
-
if (
|
|
1836
|
-
for (const { name:
|
|
1835
|
+
if (name.includes("schedule")) {
|
|
1836
|
+
for (const { name: name2, registerScheduleStore, hasSchedule } of capabilities) {
|
|
1837
1837
|
if (hasSchedule === true) {
|
|
1838
|
-
setStorageInstance(registerScheduleStore,
|
|
1838
|
+
setStorageInstance(registerScheduleStore, name2);
|
|
1839
1839
|
}
|
|
1840
1840
|
}
|
|
1841
1841
|
} else {
|
|
1842
|
-
for (const { name:
|
|
1843
|
-
setStorageInstance(registerStore,
|
|
1842
|
+
for (const { name: name2, registerStore } of capabilities) {
|
|
1843
|
+
setStorageInstance(registerStore, name2);
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
1846
1846
|
setTimeout(
|
|
1847
1847
|
() => (0, import_kubernetes_fluent_client6.K8s)(Store).InNamespace(namespace).Get(this.#name).then(
|
|
1848
1848
|
async (store) => await migrateAndSetupWatch({
|
|
1849
|
-
name
|
|
1849
|
+
name,
|
|
1850
1850
|
namespace,
|
|
1851
1851
|
store,
|
|
1852
1852
|
stores: this.#stores,
|
|
@@ -1865,15 +1865,15 @@ var StoreController = class {
|
|
|
1865
1865
|
logger_default.debug(redactedStore(store), "Pepr Store update");
|
|
1866
1866
|
const debounced = () => {
|
|
1867
1867
|
const data = store.data || {};
|
|
1868
|
-
for (const
|
|
1869
|
-
const offset = `${
|
|
1868
|
+
for (const name of Object.keys(this.#stores)) {
|
|
1869
|
+
const offset = `${name}-`.length;
|
|
1870
1870
|
const filtered = {};
|
|
1871
1871
|
for (const key of Object.keys(data)) {
|
|
1872
|
-
if ((0, import_ramda12.startsWith)(
|
|
1872
|
+
if ((0, import_ramda12.startsWith)(name, key)) {
|
|
1873
1873
|
filtered[key.slice(offset)] = data[key];
|
|
1874
1874
|
}
|
|
1875
1875
|
}
|
|
1876
|
-
this.#stores[
|
|
1876
|
+
this.#stores[name].receive(filtered);
|
|
1877
1877
|
}
|
|
1878
1878
|
if (this.#onReady) {
|
|
1879
1879
|
this.#onReady();
|
|
@@ -2097,12 +2097,12 @@ var Controller = class _Controller {
|
|
|
2097
2097
|
const startTime = MetricsCollector.observeStart();
|
|
2098
2098
|
try {
|
|
2099
2099
|
const request = req.body?.request || {};
|
|
2100
|
-
const { name
|
|
2100
|
+
const { name, namespace: namespace2, gvk } = {
|
|
2101
2101
|
name: request?.name ? `/${request.name}` : "",
|
|
2102
2102
|
namespace: request?.namespace || "",
|
|
2103
2103
|
gvk: request?.kind || { group: "", version: "", kind: "" }
|
|
2104
2104
|
};
|
|
2105
|
-
const reqMetadata = { uid: request.uid, namespace: namespace2, name
|
|
2105
|
+
const reqMetadata = { uid: request.uid, namespace: namespace2, name };
|
|
2106
2106
|
logger_default.info(
|
|
2107
2107
|
{ ...reqMetadata, gvk, operation: request.operation, admissionKind },
|
|
2108
2108
|
"Incoming request"
|
|
@@ -2189,8 +2189,8 @@ var Queue = class {
|
|
|
2189
2189
|
#uid;
|
|
2190
2190
|
#queue = [];
|
|
2191
2191
|
#pendingPromise = false;
|
|
2192
|
-
constructor(
|
|
2193
|
-
this.#name =
|
|
2192
|
+
constructor(name) {
|
|
2193
|
+
this.#name = name;
|
|
2194
2194
|
this.#uid = `${Date.now()}-${(0, import_node_crypto.randomBytes)(2).toString("hex")}`;
|
|
2195
2195
|
}
|
|
2196
2196
|
label() {
|
|
@@ -2280,11 +2280,11 @@ function queueKey(obj) {
|
|
|
2280
2280
|
strat = options.includes(strat) ? strat : d3fault;
|
|
2281
2281
|
const ns = obj.metadata?.namespace ?? "cluster-scoped";
|
|
2282
2282
|
const kind3 = obj.kind ?? "UnknownKind";
|
|
2283
|
-
const
|
|
2283
|
+
const name = obj.metadata?.name ?? "Unnamed";
|
|
2284
2284
|
const lookup = {
|
|
2285
2285
|
kind: `${kind3}`,
|
|
2286
2286
|
kindNs: `${kind3}/${ns}`,
|
|
2287
|
-
kindNsName: `${kind3}/${ns}/${
|
|
2287
|
+
kindNsName: `${kind3}/${ns}/${name}`,
|
|
2288
2288
|
global: "global"
|
|
2289
2289
|
};
|
|
2290
2290
|
return lookup[strat];
|
|
@@ -2547,20 +2547,20 @@ async function writeEvent(cr, event, options) {
|
|
|
2547
2547
|
}
|
|
2548
2548
|
function getOwnerRefFrom(customResource, blockOwnerDeletion, controller) {
|
|
2549
2549
|
const { apiVersion, kind: kind3, metadata } = customResource;
|
|
2550
|
-
const { name
|
|
2550
|
+
const { name, uid } = metadata;
|
|
2551
2551
|
return [
|
|
2552
2552
|
{
|
|
2553
2553
|
apiVersion,
|
|
2554
2554
|
kind: kind3,
|
|
2555
2555
|
uid,
|
|
2556
|
-
name
|
|
2556
|
+
name,
|
|
2557
2557
|
...blockOwnerDeletion !== void 0 && { blockOwnerDeletion },
|
|
2558
2558
|
...controller !== void 0 && { controller }
|
|
2559
2559
|
}
|
|
2560
2560
|
];
|
|
2561
2561
|
}
|
|
2562
|
-
function sanitizeResourceName(
|
|
2563
|
-
return
|
|
2562
|
+
function sanitizeResourceName(name) {
|
|
2563
|
+
return name.toLowerCase().replace(/[^a-z0-9-]+/g, "-").slice(0, 63).replace(/^[^a-z0-9]+/, "").replace(/[^a-z0-9]+$/, "");
|
|
2564
2564
|
}
|
|
2565
2565
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2566
2566
|
0 && (module.exports = {
|