pepr 0.28.0 → 0.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -356,7 +356,7 @@ function generateWatchNamespaceError(ignoredNamespaces, bindingNamespaces, capab
356
356
  if (bindingAndCapabilityNSConflict(bindingNamespaces, capabilityNamespaces)) {
357
357
  err += `Binding uses namespace not governed by capability: bindingNamespaces: [${bindingNamespaces.join(
358
358
  ", "
359
- )}] capabilityNamespaces:$[${capabilityNamespaces.join(", ")}].`;
359
+ )}] capabilityNamespaces: [${capabilityNamespaces.join(", ")}].`;
360
360
  }
361
361
  return err.replace(/\.([^ ])/g, ". $1");
362
362
  }
@@ -520,6 +520,7 @@ function watcher(assets, hash, buildTimestamp) {
520
520
  }
521
521
  },
522
522
  spec: {
523
+ terminationGracePeriodSeconds: 5,
523
524
  serviceAccountName: name2,
524
525
  securityContext: {
525
526
  runAsUser: 65532,
@@ -642,6 +643,7 @@ function deployment(assets, hash, buildTimestamp) {
642
643
  }
643
644
  },
644
645
  spec: {
646
+ terminationGracePeriodSeconds: 5,
645
647
  priorityClassName: "system-node-critical",
646
648
  serviceAccountName: name2,
647
649
  securityContext: {
@@ -1143,14 +1145,13 @@ async function overridesFile({ hash, name: name2, image, config, apiToken }, pat
1143
1145
  },
1144
1146
  uuid: name2,
1145
1147
  admission: {
1148
+ terminationGracePeriodSeconds: 5,
1146
1149
  failurePolicy: config.onError === "reject" ? "Fail" : "Ignore",
1147
1150
  webhookTimeout: config.webhookTimeout,
1148
1151
  env: [
1149
1152
  { name: "PEPR_WATCH_MODE", value: "false" },
1150
1153
  { name: "PEPR_PRETTY_LOG", value: "false" },
1151
- { name: "LOG_LEVEL", value: "debug" },
1152
- process.env.PEPR_MODE === "dev" && { name: "MY_CUSTOM_VAR", value: "example-value" },
1153
- process.env.PEPR_MODE === "dev" && { name: "ZARF_VAR", value: "###ZARF_VAR_THING###" }
1154
+ { name: "LOG_LEVEL", value: "debug" }
1154
1155
  ],
1155
1156
  image,
1156
1157
  annotations: {
@@ -1191,12 +1192,11 @@ async function overridesFile({ hash, name: name2, image, config, apiToken }, pat
1191
1192
  affinity: {}
1192
1193
  },
1193
1194
  watcher: {
1195
+ terminationGracePeriodSeconds: 5,
1194
1196
  env: [
1195
1197
  { name: "PEPR_WATCH_MODE", value: "true" },
1196
1198
  { name: "PEPR_PRETTY_LOG", value: "false" },
1197
- { name: "LOG_LEVEL", value: "debug" },
1198
- process.env.PEPR_MODE === "dev" && { name: "MY_CUSTOM_VAR", value: "example-value" },
1199
- process.env.PEPR_MODE === "dev" && { name: "ZARF_VAR", value: "###ZARF_VAR_THING###" }
1199
+ { name: "LOG_LEVEL", value: "debug" }
1200
1200
  ],
1201
1201
  image,
1202
1202
  annotations: {
@@ -1237,6 +1237,12 @@ async function overridesFile({ hash, name: name2, image, config, apiToken }, pat
1237
1237
  affinity: {}
1238
1238
  }
1239
1239
  };
1240
+ if (process.env.PEPR_MODE === "dev") {
1241
+ overrides.admission.env.push({ name: "ZARF_VAR", value: "###ZARF_VAR_THING###" });
1242
+ overrides.watcher.env.push({ name: "ZARF_VAR", value: "###ZARF_VAR_THING###" });
1243
+ overrides.admission.env.push({ name: "MY_CUSTOM_VAR", value: "example-value" });
1244
+ overrides.watcher.env.push({ name: "MY_CUSTOM_VAR", value: "example-value" });
1245
+ }
1240
1246
  await import_fs4.promises.writeFile(path, (0, import_client_node.dumpYaml)(overrides, { noRefs: true, forceQuotes: true }));
1241
1247
  }
1242
1248
  function zarfYaml({ name: name2, image, config }, path) {
@@ -1373,6 +1379,7 @@ function watcherDeployTemplate(buildTimestamp) {
1373
1379
  app: {{ .Values.uuid }}-watcher
1374
1380
  pepr.dev/controller: watcher
1375
1381
  spec:
1382
+ terminationGracePeriodSeconds: {{ .Values.watcher.terminationGracePeriodSeconds }}
1376
1383
  serviceAccountName: {{ .Values.uuid }}
1377
1384
  securityContext:
1378
1385
  {{- toYaml .Values.admission.securityContext | nindent 8 }}
@@ -1443,6 +1450,7 @@ function admissionDeployTemplate(buildTimestamp) {
1443
1450
  app: {{ .Values.uuid }}
1444
1451
  pepr.dev/controller: admission
1445
1452
  spec:
1453
+ terminationGracePeriodSeconds: {{ .Values.admission.terminationGracePeriodSeconds }}
1446
1454
  priorityClassName: system-node-critical
1447
1455
  serviceAccountName: {{ .Values.uuid }}
1448
1456
  securityContext:
@@ -1824,7 +1832,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
1824
1832
  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';
1825
1833
  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';
1826
1834
  var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\n\n/**\n * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.\n * To test this capability you run `pepr dev`and then run the following command:\n * `kubectl apply -f capabilities/hello-pepr.samples.yaml`\n */\nexport const HelloPepr = new Capability({\n name: "hello-pepr",\n description: "A simple example capability to show how things work.",\n namespaces: ["pepr-demo", "pepr-demo-2"],\n});\n\n// Use the \'When\' function to create a new action, 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\n .SetLabel("pepr", "was-here")\n .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)\n .IsCreated()\n .InNamespace("pepr-demo-2")\n .WithName("example-4a")\n .Mutate(example4Cb);\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 5) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`\n * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a\n * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how\n * you can use Pepr to make changes to your K8s objects based on external data.\n *\n * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.\n *\n * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you\n * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to\n * cast the data returned from the API.\n *\n * These are equivalent:\n * ```ts\n * const joke = await fetch<TheChuckNorrisJoke>("https://api.chucknorris.io/jokes/random?category=dev");\n * const joke = await fetch("https://api.chucknorris.io/jokes/random?category=dev") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://api.chucknorris.io/jokes/random?category=dev")\n * ```\n */\ninterface TheChuckNorrisJoke {\n icon_url: string;\n id: string;\n url: string;\n value: string;\n}\n\nWhen(a.ConfigMap)\n .IsCreated()\n .WithLabel("chuck-norris")\n .Mutate(async change => {\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(\n "https://api.chucknorris.io/jokes/random?category=dev",\n );\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n // Add the Chuck Norris joke to the configmap\n change.Raw.data["chuck-says"] = response.data.value;\n return;\n }\n\n // You can also assert on different HTTP response codes\n if (response.status === fetchStatus.NOT_FOUND) {\n // Do something else\n return;\n }\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Secret Base64 Handling) *\n * ---------------------------------------------------------------------------------------------------\n *\n * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,\n * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding\n * secret data before and after the action is executed.\n */\nWhen(a.Secret)\n .IsCreated()\n .WithName("secret-1")\n .Mutate(request => {\n const secret = request.Raw;\n\n // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="\n secret.data.magic = "change-without-encoding";\n\n // You can modify the data directly, and it will be encoded at the end of all processing\n secret.data.example += " - modified by Pepr";\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Untyped Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create\n * your own types. This is useful if you are working with an Operator that creates custom resources.\n * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,\n * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.\n *\n * This example shows how to use the `When()` function with a `GenericKind`. Note that you\n * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows\n * if the action should be triggered or not. Since we are using a `GenericKind`,\n * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the\n * Kubernetes API documentation for the object you are working with.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-1\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```\n */\nWhen(a.GenericKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n})\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr without type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Typed Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This example shows how to use the `RegisterKind()` function to create a new type. This is useful\n * if you are working with an Operator that creates custom resources and you want to have intellisense\n * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)\n * as this is how Pepr knows if the action should be triggered or not.\n *\n * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,\n * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available\n * to all actions, but we are putting it here for demonstration purposes.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-2\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```*\n */\nclass UnicornKind extends a.GenericKind {\n spec: {\n /**\n * JSDoc comments can be added to explain more details about the field.\n *\n * @example\n * ```ts\n * request.Raw.spec.message = "Hello Pepr!";\n * ```\n * */\n message: string;\n counter: number;\n };\n}\n\nRegisterKind(UnicornKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n});\n\nWhen(UnicornKind)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr with type data!",\n counter: Math.random(),\n },\n });\n });\n\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';
1827
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.28.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "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:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.11", express: "4.18.3", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.2", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.0.3", "@commitlint/config-conventional": "19.0.3", "@jest/globals": "29.7.0", "@types/eslint": "8.56.5", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.8", jest: "29.7.0", nock: "13.5.4", "ts-jest": "29.1.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
1835
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.28.2", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "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:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.11", express: "4.18.3", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.3", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.1.0", "@commitlint/config-conventional": "19.1.0", "@jest/globals": "29.7.0", "@types/eslint": "8.56.5", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.8", jest: "29.7.0", nock: "13.5.4", "ts-jest": "29.1.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
1828
1836
 
1829
1837
  // src/templates/pepr.code-snippets.json
1830
1838
  var pepr_code_snippets_default = {
@@ -49,7 +49,7 @@ if (process.env.LOG_LEVEL) {
49
49
  var logger_default = Log;
50
50
 
51
51
  // src/templates/data.json
52
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.28.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "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:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.11", express: "4.18.3", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.2", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.0.3", "@commitlint/config-conventional": "19.0.3", "@jest/globals": "29.7.0", "@types/eslint": "8.56.5", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.8", jest: "29.7.0", nock: "13.5.4", "ts-jest": "29.1.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
52
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.28.2", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "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:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.11", express: "4.18.3", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.3", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.1.0", "@commitlint/config-conventional": "19.1.0", "@jest/globals": "29.7.0", "@types/eslint": "8.56.5", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.8", jest: "29.7.0", nock: "13.5.4", "ts-jest": "29.1.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
53
53
 
54
54
  // src/lib/k8s.ts
55
55
  var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
@@ -1 +1 @@
1
- {"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,WAezB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,UA2B3D;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,UAuE3D;AAED,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,UA4E7D"}
1
+ {"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,WAezB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,UA2B3D;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,UAwE3D;AAED,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,UA6E7D"}
@@ -55,6 +55,7 @@ export declare function watcher(assets: Assets, hash: string, buildTimestamp: st
55
55
  };
56
56
  };
57
57
  spec: {
58
+ terminationGracePeriodSeconds: number;
58
59
  serviceAccountName: string;
59
60
  securityContext: {
60
61
  runAsUser: number;
@@ -1 +1 @@
1
- {"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;EAmBjE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgJ3E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAsIhG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAuBlF"}
1
+ {"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;EAmBjE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAiJ3E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAuIhG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAuBlF"}
@@ -1 +1 @@
1
- {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAO3B,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBA8GhG;AACD,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UA0BrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAyC7D"}
1
+ {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAO3B,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAkHhG;AACD,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UA0BrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAyC7D"}
@@ -1,9 +1,9 @@
1
1
  import { Capability } from "../capability";
2
- import { MutateResponse, AdmissionRequest } from "../k8s";
2
+ import { MutateResponse, AdmissionRequest, ValidateResponse } from "../k8s";
3
3
  import { ModuleConfig } from "../module";
4
4
  export declare class Controller {
5
5
  #private;
6
- constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: AdmissionRequest) => void, afterHook?: (res: MutateResponse) => void, onReady?: () => void);
6
+ constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: AdmissionRequest) => void, afterHook?: (res: MutateResponse | ValidateResponse) => void, onReady?: () => void);
7
7
  /** Start the webhook server */
8
8
  startServer: (port: number) => void;
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAoB,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAMtD,qBAAa,UAAU;;gBAoBnB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,EAC5C,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,EACzC,OAAO,CAAC,EAAE,MAAM,IAAI;IAiCtB,+BAA+B;IAC/B,WAAW,SAAU,MAAM,UAqDzB;CAqMH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAMtD,qBAAa,UAAU;;gBAoBnB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,EAC5C,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,EAC5D,OAAO,CAAC,EAAE,MAAM,IAAI;IAiCtB,+BAA+B;IAC/B,WAAW,SAAU,MAAM,UAqDzB;CAqMH"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAa,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,WA+ExG"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAa,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,WA8FxG"}
@@ -7,7 +7,7 @@ type RBACMap = {
7
7
  plural: string;
8
8
  };
9
9
  };
10
- export declare function checkOverlap(record1: Record<string, string>, record2: Record<string, string>): boolean;
10
+ export declare function checkOverlap(bindingFilters: Record<string, string>, objectFilters: Record<string, string>): boolean;
11
11
  /**
12
12
  * Decide to run callback after the event comes back from API Server
13
13
  **/
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,gBAAgB,EAAQ,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,KAAK,OAAO,GAAG;IACb,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAc5F;AAED;;IAEI;AACJ,eAAO,MAAM,aAAa,YACf,QAAQ,OAAO,CAAC,OACpB,QAAQ,gBAAgB,CAAC,wBACR,MAAM,EAAE,KAC7B,MAiEF,CAAC;AACF,eAAO,MAAM,kBAAkB,UAAW,MAAM,EAAE,QAAQ,M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sB;IAsD7G;;;;;OAKG;IACH,KAAK,0BAEH;CACH"}
@@ -1,4 +1,3 @@
1
1
  import { Capability } from "./capability";
2
- export declare function setupStore(uuid: string): Promise<void>;
3
- export declare function setupWatch(uuid: string, capabilities: Capability[]): Promise<void>;
2
+ export declare function setupWatch(capabilities: Capability[]): void;
4
3
  //# sourceMappingURL=watch-processor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAoC5C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,iBAQxE"}
1
+ {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS1C,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,QAMpD"}
package/dist/lib.js CHANGED
@@ -209,7 +209,19 @@ function shouldSkipRequest(binding, req, capabilityNamespaces) {
209
209
  return true;
210
210
  }
211
211
  if (combinedNamespaces.length && !combinedNamespaces.includes(req.namespace || "") || !namespaces.includes(req.namespace || "") && capabilityNamespaces.length !== 0 && namespaces.length !== 0) {
212
- logger_default.debug("Namespace does not match");
212
+ let type = "";
213
+ let label = "";
214
+ if (binding.isMutate) {
215
+ type = "Mutate";
216
+ label = binding.mutateCallback.name;
217
+ } else if (binding.isValidate) {
218
+ type = "Validate";
219
+ label = binding.validateCallback.name;
220
+ } else if (binding.isWatch) {
221
+ type = "Watch";
222
+ label = binding.watchCallback.name;
223
+ }
224
+ logger_default.debug(`${type} binding (${label}) does not match request namespace "${req.namespace}"`);
213
225
  return true;
214
226
  }
215
227
  for (const [key, value] of Object.entries(labels)) {
@@ -424,7 +436,7 @@ async function mutateProcessor(config, capabilities, req, reqMetadata) {
424
436
  continue;
425
437
  }
426
438
  const label = action.mutateCallback.name;
427
- logger_default.info(actionMetadata, `Processing matched action ${label}`);
439
+ logger_default.info(actionMetadata, `Processing mutation action (${label})`);
428
440
  matchedAction = true;
429
441
  const updateStatus = (status) => {
430
442
  if (req.operation == "DELETE") {
@@ -438,7 +450,7 @@ async function mutateProcessor(config, capabilities, req, reqMetadata) {
438
450
  updateStatus("started");
439
451
  try {
440
452
  await action.mutateCallback(wrapped);
441
- logger_default.info(actionMetadata, `Action succeeded`);
453
+ logger_default.info(actionMetadata, `Mutation action succeeded (${label})`);
442
454
  updateStatus("succeeded");
443
455
  } catch (e) {
444
456
  logger_default.warn(actionMetadata, `Action failed: ${e}`);
@@ -584,7 +596,7 @@ async function validateProcessor(capabilities, req, reqMetadata) {
584
596
  continue;
585
597
  }
586
598
  const label = action.validateCallback.name;
587
- logger_default.info(actionMetadata, `Processing matched action ${label}`);
599
+ logger_default.info(actionMetadata, `Processing validation action (${label})`);
588
600
  try {
589
601
  const resp = await action.validateCallback(wrapped);
590
602
  localResponse.allowed = resp.allowed;
@@ -594,7 +606,7 @@ async function validateProcessor(capabilities, req, reqMetadata) {
594
606
  message: resp.statusMessage || `Validation failed for ${name}`
595
607
  };
596
608
  }
597
- logger_default.info(actionMetadata, `Validation Action completed: ${resp.allowed ? "allowed" : "denied"}`);
609
+ logger_default.info(actionMetadata, `Validation action complete (${label}): ${resp.allowed ? "allowed" : "denied"}`);
598
610
  } catch (e) {
599
611
  logger_default.error(actionMetadata, `Action failed: ${JSON.stringify(e)}`);
600
612
  localResponse.allowed = false;
@@ -668,7 +680,7 @@ var PeprControllerStore = class {
668
680
  }
669
681
  };
670
682
  clearTimeout(this.#sendDebounce);
671
- this.#sendDebounce = setTimeout(debounced, debounceBackoff);
683
+ this.#sendDebounce = setTimeout(debounced, this.#onReady ? 0 : debounceBackoff);
672
684
  };
673
685
  #send = (capabilityName) => {
674
686
  const sendCache = {};
@@ -1025,16 +1037,23 @@ var Queue = class {
1025
1037
 
1026
1038
  // src/lib/helpers.ts
1027
1039
  var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
1028
- function checkOverlap(record1, record2) {
1029
- if (Object.keys(record1).length === 0) {
1040
+ function checkOverlap(bindingFilters, objectFilters) {
1041
+ if (Object.keys(bindingFilters).length === 0) {
1030
1042
  return true;
1031
1043
  }
1032
- for (const key in record1) {
1033
- if (Object.prototype.hasOwnProperty.call(record1, key) && Object.prototype.hasOwnProperty.call(record2, key) && record1[key] === record2[key]) {
1034
- return true;
1044
+ let matchCount = 0;
1045
+ for (const key in bindingFilters) {
1046
+ if (Object.prototype.hasOwnProperty.call(objectFilters, key)) {
1047
+ const val1 = bindingFilters[key];
1048
+ const val2 = objectFilters[key];
1049
+ if (val1 === "" && key in objectFilters) {
1050
+ matchCount++;
1051
+ } else if (val1 !== "" && val1 === val2) {
1052
+ matchCount++;
1053
+ }
1035
1054
  }
1036
1055
  }
1037
- return false;
1056
+ return matchCount === Object.keys(bindingFilters).length;
1038
1057
  }
1039
1058
  var filterMatcher = (binding, obj, capabilityNamespaces) => {
1040
1059
  if (binding.kind && binding.kind.kind === "Namespace" && binding.filters && binding.filters.namespaces.length !== 0) {
@@ -1071,35 +1090,8 @@ var filterMatcher = (binding, obj, capabilityNamespaces) => {
1071
1090
  };
1072
1091
 
1073
1092
  // src/lib/watch-processor.ts
1074
- var storeUpdates = false;
1075
1093
  var store = {};
1076
- async function setupStore(uuid) {
1077
- const name = `pepr-${uuid}-watch`;
1078
- const namespace2 = "pepr-system";
1079
- try {
1080
- const k8sStore = await (0, import_kubernetes_fluent_client4.K8s)(PeprStore).InNamespace(namespace2).Get(name);
1081
- Object.entries(k8sStore.data).forEach(([key, value]) => {
1082
- store[key] = value;
1083
- });
1084
- } catch (e) {
1085
- logger_default.debug(e, "Watch store does not exist yet");
1086
- }
1087
- setInterval(() => {
1088
- if (storeUpdates) {
1089
- (0, import_kubernetes_fluent_client4.K8s)(PeprStore).Apply({
1090
- metadata: {
1091
- name,
1092
- namespace: namespace2
1093
- },
1094
- data: store
1095
- }).then(() => storeUpdates = false).catch((e) => {
1096
- logger_default.error(e, "Error updating watch store");
1097
- });
1098
- }
1099
- }, 10 * 1e3);
1100
- }
1101
- async function setupWatch(uuid, capabilities) {
1102
- await setupStore(uuid);
1094
+ function setupWatch(capabilities) {
1103
1095
  capabilities.map(
1104
1096
  (capability) => capability.bindings.filter((binding) => binding.isWatch).forEach((bindingElement) => runBinding(bindingElement, capability.namespaces))
1105
1097
  );
@@ -1155,14 +1147,6 @@ async function runBinding(binding, capabilityNamespaces) {
1155
1147
  }
1156
1148
  const cacheSuffix = (0, import_crypto.createHash)("sha224").update(binding.watchCallback.toString()).digest("hex").substring(0, 5);
1157
1149
  const cacheID = [watcher.getCacheID(), cacheSuffix].join("-");
1158
- watcher.events.on(import_kubernetes_fluent_client4.WatchEvent.RESOURCE_VERSION, (version) => {
1159
- logger_default.debug(`Received watch cache: ${cacheID}:${version}`);
1160
- if (store[cacheID] !== version) {
1161
- logger_default.debug(`Updating watch cache: ${cacheID}: ${store[cacheID]} => ${version}`);
1162
- store[cacheID] = version;
1163
- storeUpdates = true;
1164
- }
1165
- });
1166
1150
  watcher.events.on(import_kubernetes_fluent_client4.WatchEvent.GIVE_UP, (err) => {
1167
1151
  logger_default.error(err, "Watch failed after 5 attempts, giving up");
1168
1152
  process.exit(1);
@@ -1216,10 +1200,12 @@ var PeprModule = class {
1216
1200
  }
1217
1201
  this.#controller = new Controller(config, capabilities, opts.beforeHook, opts.afterHook, () => {
1218
1202
  if (isWatchMode() || isDevMode()) {
1219
- setupWatch(config.uuid, capabilities).catch((e) => {
1203
+ try {
1204
+ setupWatch(capabilities);
1205
+ } catch (e) {
1220
1206
  logger_default.error(e, "Error setting up watch");
1221
1207
  process.exit(1);
1222
- });
1208
+ }
1223
1209
  }
1224
1210
  });
1225
1211
  if (opts.deferStart) {