pepr 0.47.0-nightly.0 → 0.47.0-nightly.10

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
@@ -1500,7 +1500,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
1500
1500
  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';
1501
1501
  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';
1502
1502
  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';
1503
- 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*"], version: "0.47.0-nightly.0", 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: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": "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 build && 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'", "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.4.6", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0" }, 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.1", 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" } };
1503
+ 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*"], version: "0.47.0-nightly.10", 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: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'", "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.4.10", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0" }, 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.1", 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" } };
1504
1504
 
1505
1505
  // src/cli/init/utils.ts
1506
1506
  var import_fs4 = require("fs");
@@ -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*"], version: "0.47.0-nightly.0", 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: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": "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 build && 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'", "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.4.6", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0" }, 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.1", 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" } };
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*"], version: "0.47.0-nightly.10", 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: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'", "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.4.10", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.1.0" }, 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.1", 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");
@@ -0,0 +1,11 @@
1
+ import { Storage } from "../core/storage";
2
+ import { Store } from "../k8s";
3
+ export interface StoreMigration {
4
+ name: string;
5
+ namespace: string;
6
+ store: Store;
7
+ stores: Record<string, Storage>;
8
+ setupWatch: () => void;
9
+ }
10
+ export declare function migrateAndSetupWatch(storeData: StoreMigration): Promise<void>;
11
+ //# sourceMappingURL=migrateStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateStore.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/migrateStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAI/B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAUhD,qBAAa,eAAe;;gBAMd,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;CA0K3E"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWhD,qBAAa,eAAe;;gBAMd,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;CA4I3E"}
@@ -1,3 +1,4 @@
1
+ import { Binding } from "../types";
1
2
  import { Capability } from "../core/capability";
2
3
  import { KubernetesObject, WatchEvent, GenericClass } from "kubernetes-fluent-client";
3
4
  import { Queue } from "../core/queue";
@@ -18,6 +19,13 @@ export declare function getOrCreateQueue(obj: KubernetesObject): Queue<Kubernete
18
19
  * @param capabilities The capabilities to load watches for
19
20
  */
20
21
  export declare function setupWatch(capabilities: Capability[], ignoredNamespaces?: string[]): void;
22
+ /**
23
+ * Setup a watch for a binding
24
+ *
25
+ * @param binding the binding to watch
26
+ * @param capabilityNamespaces list of namespaces to filter on
27
+ */
28
+ export declare function runBinding(binding: Binding, capabilityNamespaces: string[], ignoredNamespaces?: string[]): Promise<void>;
21
29
  export declare function logEvent(event: WatchEvent, message?: string, obj?: KubernetesObject): void;
22
30
  export type WatchEventArgs<K extends WatchEvent, T extends GenericClass> = {
23
31
  [WatchEvent.LIST]: KubernetesListObject<InstanceType<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../../src/lib/processors/watch-processor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAEL,gBAAgB,EAEhB,UAAU,EACV,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAc,WAAW,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EAAoB,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMlF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAkBtD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAM/E;AA2BD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAQzF;AAuGD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,GAAE,MAAW,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAO9F;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,YAAY,IAAI;IACzE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC/B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAChC,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IACrC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;IAC5B,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAC1B,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC1C,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;IAClC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC/B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC/B,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC7B,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC1C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC7B,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAC/C,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAC7E,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,gBAAgB,EAAE,wBAAwB,GACzC,IAAI,CAgCN"}
1
+ {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../../src/lib/processors/watch-processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAEL,gBAAgB,EAEhB,UAAU,EACV,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAc,WAAW,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EAAoB,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMlF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAkBtD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAM/E;AA2BD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAMzF;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,MAAM,EAAE,EAC9B,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CA+Ff;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,GAAE,MAAW,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAO9F;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,YAAY,IAAI;IACzE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC/B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAChC,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IACrC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;IAC5B,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAC1B,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC1C,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;IAClC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC/B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC/B,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC7B,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC1C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC7B,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAC/C,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAC7E,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,gBAAgB,EAAE,wBAAwB,GACzC,IAAI,CAmCN"}
package/dist/lib.js CHANGED
@@ -31,22 +31,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var lib_exports = {};
32
32
  __export(lib_exports, {
33
33
  Capability: () => Capability,
34
- K8s: () => import_kubernetes_fluent_client8.K8s,
34
+ K8s: () => import_kubernetes_fluent_client9.K8s,
35
35
  Log: () => logger_default,
36
36
  PeprModule: () => PeprModule,
37
37
  PeprMutateRequest: () => PeprMutateRequest,
38
38
  PeprUtils: () => utils_exports,
39
39
  PeprValidateRequest: () => PeprValidateRequest,
40
40
  R: () => R,
41
- RegisterKind: () => import_kubernetes_fluent_client8.RegisterKind,
42
- a: () => import_kubernetes_fluent_client8.kind,
43
- fetch: () => import_kubernetes_fluent_client8.fetch,
44
- fetchStatus: () => import_kubernetes_fluent_client8.fetchStatus,
45
- kind: () => import_kubernetes_fluent_client8.kind,
41
+ RegisterKind: () => import_kubernetes_fluent_client9.RegisterKind,
42
+ a: () => import_kubernetes_fluent_client9.kind,
43
+ fetch: () => import_kubernetes_fluent_client9.fetch,
44
+ fetchStatus: () => import_kubernetes_fluent_client9.fetchStatus,
45
+ kind: () => import_kubernetes_fluent_client9.kind,
46
46
  sdk: () => sdk_exports
47
47
  });
48
48
  module.exports = __toCommonJS(lib_exports);
49
- var import_kubernetes_fluent_client8 = require("kubernetes-fluent-client");
49
+ var import_kubernetes_fluent_client9 = require("kubernetes-fluent-client");
50
50
  var R = __toESM(require("ramda"));
51
51
 
52
52
  // src/lib/core/capability.ts
@@ -735,7 +735,7 @@ var Capability = class {
735
735
  };
736
736
 
737
737
  // src/lib/core/module.ts
738
- var import_ramda13 = require("ramda");
738
+ var import_ramda14 = require("ramda");
739
739
 
740
740
  // src/lib/controller/index.ts
741
741
  var import_express = __toESM(require("express"));
@@ -1714,8 +1714,8 @@ async function validateProcessor(config, capabilities, req, reqMetadata) {
1714
1714
  }
1715
1715
 
1716
1716
  // src/lib/controller/store.ts
1717
- var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
1718
- var import_ramda12 = require("ramda");
1717
+ var import_kubernetes_fluent_client6 = require("kubernetes-fluent-client");
1718
+ var import_ramda13 = require("ramda");
1719
1719
 
1720
1720
  // src/lib/k8s.ts
1721
1721
  var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
@@ -1777,6 +1777,41 @@ function updateCacheID(payload) {
1777
1777
  return payload;
1778
1778
  }
1779
1779
 
1780
+ // src/lib/controller/migrateStore.ts
1781
+ var import_ramda12 = require("ramda");
1782
+ var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
1783
+ async function migrateAndSetupWatch(storeData) {
1784
+ const { store, namespace: namespace2, name: name2, stores, setupWatch: setupWatch2 } = storeData;
1785
+ logger_default.debug(redactedStore(store), "Pepr Store migration");
1786
+ await (0, import_kubernetes_fluent_client5.K8s)(Store, { namespace: namespace2, name: name2 }).Patch([
1787
+ {
1788
+ op: "add",
1789
+ path: "/metadata/labels/pepr.dev-cacheID",
1790
+ value: `${Date.now()}`
1791
+ }
1792
+ ]);
1793
+ const data = store.data;
1794
+ let storeCache = {};
1795
+ for (const name3 of Object.keys(stores)) {
1796
+ const offset = `${name3}-`.length;
1797
+ for (const key of Object.keys(data)) {
1798
+ if ((0, import_ramda12.startsWith)(name3, key) && !(0, import_ramda12.startsWith)(`${name3}-v2`, key)) {
1799
+ storeCache = fillStoreCache(storeCache, name3, "remove", {
1800
+ key: [key.slice(offset)],
1801
+ value: data[key]
1802
+ });
1803
+ storeCache = fillStoreCache(storeCache, name3, "add", {
1804
+ key: [key.slice(offset)],
1805
+ value: data[key],
1806
+ version: "v2"
1807
+ });
1808
+ }
1809
+ }
1810
+ }
1811
+ storeCache = await sendUpdatesAndFlushCache(storeCache, namespace2, name2);
1812
+ setupWatch2();
1813
+ }
1814
+
1780
1815
  // src/lib/controller/store.ts
1781
1816
  var namespace = "pepr-system";
1782
1817
  var debounceBackoffReceive = 1e3;
@@ -1806,45 +1841,23 @@ var StoreController = class {
1806
1841
  }
1807
1842
  }
1808
1843
  setTimeout(
1809
- () => (0, import_kubernetes_fluent_client5.K8s)(Store).InNamespace(namespace).Get(this.#name).then(async (store) => await this.#migrateAndSetupWatch(store)).catch(this.#createStoreResource),
1844
+ () => (0, import_kubernetes_fluent_client6.K8s)(Store).InNamespace(namespace).Get(this.#name).then(
1845
+ async (store) => await migrateAndSetupWatch({
1846
+ name: name2,
1847
+ namespace,
1848
+ store,
1849
+ stores: this.#stores,
1850
+ setupWatch: this.#setupWatch
1851
+ })
1852
+ ).catch(this.#createStoreResource),
1810
1853
  Math.random() * 3e3
1811
1854
  // Add a jitter to the Store creation to avoid collisions
1812
1855
  );
1813
1856
  }
1814
1857
  #setupWatch = () => {
1815
- const watcher = (0, import_kubernetes_fluent_client5.K8s)(Store, { name: this.#name, namespace }).Watch(this.#receive);
1858
+ const watcher = (0, import_kubernetes_fluent_client6.K8s)(Store, { name: this.#name, namespace }).Watch(this.#receive);
1816
1859
  watcher.start().catch((e) => logger_default.error(e, "Error starting Pepr store watch"));
1817
1860
  };
1818
- #migrateAndSetupWatch = async (store) => {
1819
- logger_default.debug(redactedStore(store), "Pepr Store migration");
1820
- await (0, import_kubernetes_fluent_client5.K8s)(Store, { namespace, name: this.#name }).Patch([
1821
- {
1822
- op: "add",
1823
- path: "/metadata/labels/pepr.dev-cacheID",
1824
- value: `${Date.now()}`
1825
- }
1826
- ]);
1827
- const data = store.data || {};
1828
- let storeCache = {};
1829
- for (const name2 of Object.keys(this.#stores)) {
1830
- const offset = `${name2}-`.length;
1831
- for (const key of Object.keys(data)) {
1832
- if ((0, import_ramda12.startsWith)(name2, key) && !(0, import_ramda12.startsWith)(`${name2}-v2`, key)) {
1833
- storeCache = fillStoreCache(storeCache, name2, "remove", {
1834
- key: [key.slice(offset)],
1835
- value: data[key]
1836
- });
1837
- storeCache = fillStoreCache(storeCache, name2, "add", {
1838
- key: [key.slice(offset)],
1839
- value: data[key],
1840
- version: "v2"
1841
- });
1842
- }
1843
- }
1844
- }
1845
- storeCache = await sendUpdatesAndFlushCache(storeCache, namespace, this.#name);
1846
- this.#setupWatch();
1847
- };
1848
1861
  #receive = (store) => {
1849
1862
  logger_default.debug(redactedStore(store), "Pepr Store update");
1850
1863
  const debounced = () => {
@@ -1853,7 +1866,7 @@ var StoreController = class {
1853
1866
  const offset = `${name2}-`.length;
1854
1867
  const filtered = {};
1855
1868
  for (const key of Object.keys(data)) {
1856
- if ((0, import_ramda12.startsWith)(name2, key)) {
1869
+ if ((0, import_ramda13.startsWith)(name2, key)) {
1857
1870
  filtered[key.slice(offset)] = data[key];
1858
1871
  }
1859
1872
  }
@@ -1884,7 +1897,7 @@ var StoreController = class {
1884
1897
  logger_default.info(`Pepr store not found, creating...`);
1885
1898
  logger_default.debug(e);
1886
1899
  try {
1887
- await (0, import_kubernetes_fluent_client5.K8s)(Store).Apply({
1900
+ await (0, import_kubernetes_fluent_client6.K8s)(Store).Apply({
1888
1901
  metadata: {
1889
1902
  name: this.#name,
1890
1903
  namespace,
@@ -2164,7 +2177,7 @@ function ValidateError(error = "") {
2164
2177
  }
2165
2178
 
2166
2179
  // src/lib/processors/watch-processor.ts
2167
- var import_kubernetes_fluent_client6 = require("kubernetes-fluent-client");
2180
+ var import_kubernetes_fluent_client7 = require("kubernetes-fluent-client");
2168
2181
 
2169
2182
  // src/lib/core/queue.ts
2170
2183
  var import_node_crypto = require("node:crypto");
@@ -2294,11 +2307,11 @@ var eventToPhaseMap = {
2294
2307
  ["*" /* ANY */]: [import_types.WatchPhase.Added, import_types.WatchPhase.Modified, import_types.WatchPhase.Deleted]
2295
2308
  };
2296
2309
  function setupWatch(capabilities, ignoredNamespaces) {
2297
- capabilities.map(
2298
- (capability) => capability.bindings.filter((binding) => binding.isWatch).forEach(
2299
- (bindingElement) => runBinding(bindingElement, capability.namespaces, ignoredNamespaces)
2300
- )
2301
- );
2310
+ for (const capability of capabilities) {
2311
+ for (const binding of capability.bindings.filter((b) => b.isWatch)) {
2312
+ runBinding(binding, capability.namespaces, ignoredNamespaces);
2313
+ }
2314
+ }
2302
2315
  }
2303
2316
  async function runBinding(binding, capabilityNamespaces, ignoredNamespaces) {
2304
2317
  const phaseMatch = eventToPhaseMap[binding.event] || eventToPhaseMap["*" /* ANY */];
@@ -2347,7 +2360,7 @@ async function runBinding(binding, capabilityNamespaces, ignoredNamespaces) {
2347
2360
  }
2348
2361
  }
2349
2362
  };
2350
- const watcher = (0, import_kubernetes_fluent_client6.K8s)(binding.model, { ...binding.filters, kindOverride: binding.kind }).Watch(
2363
+ const watcher = (0, import_kubernetes_fluent_client7.K8s)(binding.model, { ...binding.filters, kindOverride: binding.kind }).Watch(
2351
2364
  async (obj, phase) => {
2352
2365
  logger_default.debug(obj, `Watch event ${phase} received`);
2353
2366
  if (binding.isQueue) {
@@ -2359,12 +2372,18 @@ async function runBinding(binding, capabilityNamespaces, ignoredNamespaces) {
2359
2372
  },
2360
2373
  watchCfg
2361
2374
  );
2362
- registerWatchEventHandlers(watcher, logEvent, metricsCollector);
2375
+ try {
2376
+ registerWatchEventHandlers(watcher, logEvent, metricsCollector);
2377
+ } catch (err) {
2378
+ throw new Error(
2379
+ "WatchEventHandler Registration Error: Unable to register event watch handler.",
2380
+ { cause: err }
2381
+ );
2382
+ }
2363
2383
  try {
2364
2384
  await watcher.start();
2365
2385
  } catch (err) {
2366
- logger_default.error(err, "Error starting watch");
2367
- process.exit(1);
2386
+ throw new Error("WatchStart Error: Unable to start watch.", { cause: err });
2368
2387
  }
2369
2388
  }
2370
2389
  function logEvent(event, message = "", obj) {
@@ -2377,26 +2396,29 @@ function logEvent(event, message = "", obj) {
2377
2396
  }
2378
2397
  function registerWatchEventHandlers(watcher, logEvent2, metricsCollector2) {
2379
2398
  const eventHandlers = {
2380
- [import_kubernetes_fluent_client6.WatchEvent.DATA]: () => null,
2381
- [import_kubernetes_fluent_client6.WatchEvent.GIVE_UP]: (err) => {
2382
- logEvent2(import_kubernetes_fluent_client6.WatchEvent.GIVE_UP, err.message);
2383
- process.exit(1);
2399
+ [import_kubernetes_fluent_client7.WatchEvent.DATA]: () => null,
2400
+ [import_kubernetes_fluent_client7.WatchEvent.GIVE_UP]: (err) => {
2401
+ logEvent2(import_kubernetes_fluent_client7.WatchEvent.GIVE_UP, err.message);
2402
+ throw new Error(
2403
+ "WatchEvent GiveUp Error: The watch has failed to start after several attempts.",
2404
+ { cause: err }
2405
+ );
2384
2406
  },
2385
- [import_kubernetes_fluent_client6.WatchEvent.CONNECT]: (url) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.CONNECT, url),
2386
- [import_kubernetes_fluent_client6.WatchEvent.DATA_ERROR]: (err) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.DATA_ERROR, err.message),
2387
- [import_kubernetes_fluent_client6.WatchEvent.RECONNECT]: (retryCount) => logEvent2(
2388
- import_kubernetes_fluent_client6.WatchEvent.RECONNECT,
2407
+ [import_kubernetes_fluent_client7.WatchEvent.CONNECT]: (url) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.CONNECT, url),
2408
+ [import_kubernetes_fluent_client7.WatchEvent.DATA_ERROR]: (err) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.DATA_ERROR, err.message),
2409
+ [import_kubernetes_fluent_client7.WatchEvent.RECONNECT]: (retryCount) => logEvent2(
2410
+ import_kubernetes_fluent_client7.WatchEvent.RECONNECT,
2389
2411
  `Reconnecting after ${retryCount} attempt${retryCount === 1 ? "" : "s"}`
2390
2412
  ),
2391
- [import_kubernetes_fluent_client6.WatchEvent.RECONNECT_PENDING]: () => logEvent2(import_kubernetes_fluent_client6.WatchEvent.RECONNECT_PENDING),
2392
- [import_kubernetes_fluent_client6.WatchEvent.ABORT]: (err) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.ABORT, err.message),
2393
- [import_kubernetes_fluent_client6.WatchEvent.OLD_RESOURCE_VERSION]: (errMessage) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.OLD_RESOURCE_VERSION, errMessage),
2394
- [import_kubernetes_fluent_client6.WatchEvent.NETWORK_ERROR]: (err) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.NETWORK_ERROR, err.message),
2395
- [import_kubernetes_fluent_client6.WatchEvent.LIST_ERROR]: (err) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.LIST_ERROR, err.message),
2396
- [import_kubernetes_fluent_client6.WatchEvent.LIST]: (list) => logEvent2(import_kubernetes_fluent_client6.WatchEvent.LIST, JSON.stringify(list, void 0, 2)),
2397
- [import_kubernetes_fluent_client6.WatchEvent.CACHE_MISS]: (windowName) => metricsCollector2.incCacheMiss(windowName),
2398
- [import_kubernetes_fluent_client6.WatchEvent.INIT_CACHE_MISS]: (windowName) => metricsCollector2.initCacheMissWindow(windowName),
2399
- [import_kubernetes_fluent_client6.WatchEvent.INC_RESYNC_FAILURE_COUNT]: (retryCount) => metricsCollector2.incRetryCount(retryCount)
2413
+ [import_kubernetes_fluent_client7.WatchEvent.RECONNECT_PENDING]: () => logEvent2(import_kubernetes_fluent_client7.WatchEvent.RECONNECT_PENDING),
2414
+ [import_kubernetes_fluent_client7.WatchEvent.ABORT]: (err) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.ABORT, err.message),
2415
+ [import_kubernetes_fluent_client7.WatchEvent.OLD_RESOURCE_VERSION]: (errMessage) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.OLD_RESOURCE_VERSION, errMessage),
2416
+ [import_kubernetes_fluent_client7.WatchEvent.NETWORK_ERROR]: (err) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.NETWORK_ERROR, err.message),
2417
+ [import_kubernetes_fluent_client7.WatchEvent.LIST_ERROR]: (err) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.LIST_ERROR, err.message),
2418
+ [import_kubernetes_fluent_client7.WatchEvent.LIST]: (list) => logEvent2(import_kubernetes_fluent_client7.WatchEvent.LIST, JSON.stringify(list, void 0, 2)),
2419
+ [import_kubernetes_fluent_client7.WatchEvent.CACHE_MISS]: (windowName) => metricsCollector2.incCacheMiss(windowName),
2420
+ [import_kubernetes_fluent_client7.WatchEvent.INIT_CACHE_MISS]: (windowName) => metricsCollector2.initCacheMissWindow(windowName),
2421
+ [import_kubernetes_fluent_client7.WatchEvent.INC_RESYNC_FAILURE_COUNT]: (retryCount) => metricsCollector2.incRetryCount(retryCount)
2400
2422
  };
2401
2423
  Object.entries(eventHandlers).forEach(([event, handler]) => {
2402
2424
  watcher.events.on(event, handler);
@@ -2414,7 +2436,7 @@ var PeprModule = class {
2414
2436
  * @param opts Options for the Pepr runtime
2415
2437
  */
2416
2438
  constructor({ description, pepr }, capabilities = [], opts = {}) {
2417
- const config = (0, import_ramda13.clone)(pepr);
2439
+ const config = (0, import_ramda14.clone)(pepr);
2418
2440
  config.description = description;
2419
2441
  ValidateError(config.onError);
2420
2442
  if (isBuildMode()) {
@@ -2437,7 +2459,7 @@ var PeprModule = class {
2437
2459
  const controllerHooks = {
2438
2460
  beforeHook: opts.beforeHook,
2439
2461
  afterHook: opts.afterHook,
2440
- onReady: () => {
2462
+ onReady: async () => {
2441
2463
  if (isWatchMode() || isDevMode()) {
2442
2464
  try {
2443
2465
  setupWatch(capabilities, resolveIgnoreNamespaces(pepr?.alwaysIgnore?.namespaces));
@@ -2473,7 +2495,7 @@ __export(sdk_exports, {
2473
2495
  sanitizeResourceName: () => sanitizeResourceName,
2474
2496
  writeEvent: () => writeEvent
2475
2497
  });
2476
- var import_kubernetes_fluent_client7 = require("kubernetes-fluent-client");
2498
+ var import_kubernetes_fluent_client8 = require("kubernetes-fluent-client");
2477
2499
  function containers(request, containerType) {
2478
2500
  const containers2 = request.Raw.spec?.containers || [];
2479
2501
  const initContainers = request.Raw.spec?.initContainers || [];
@@ -2491,7 +2513,7 @@ function containers(request, containerType) {
2491
2513
  }
2492
2514
  async function writeEvent(cr, event, options) {
2493
2515
  const { eventType, eventReason, reportingComponent, reportingInstance } = options;
2494
- await (0, import_kubernetes_fluent_client7.K8s)(import_kubernetes_fluent_client7.kind.CoreEvent).Create({
2516
+ await (0, import_kubernetes_fluent_client8.K8s)(import_kubernetes_fluent_client8.kind.CoreEvent).Create({
2495
2517
  type: eventType,
2496
2518
  reason: eventReason,
2497
2519
  ...event,