pepr 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -296,7 +296,6 @@ var import_zlib = require("zlib");
296
296
  // src/lib/helpers.ts
297
297
  var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
298
298
  var import_fs2 = require("fs");
299
- var import_commander = __toESM(require("commander"));
300
299
  var createRBACMap = (capabilities) => {
301
300
  return capabilities.reduce((acc, capability) => {
302
301
  capability.bindings.forEach((binding) => {
@@ -420,11 +419,11 @@ var parseTimeout = (value, previous) => {
420
419
  const parsedValue = parseInt(value, 10);
421
420
  const floatValue = parseFloat(value);
422
421
  if (isNaN(parsedValue)) {
423
- throw new import_commander.default.InvalidArgumentError("Not a number.");
422
+ throw new Error("Not a number.");
424
423
  } else if (parsedValue !== floatValue) {
425
- throw new import_commander.default.InvalidArgumentError("Value must be an integer.");
424
+ throw new Error("Value must be an integer.");
426
425
  } else if (parsedValue < 1 || parsedValue > 30) {
427
- throw new import_commander.default.InvalidArgumentError("Number must be between 1 and 30.");
426
+ throw new Error("Number must be between 1 and 30.");
428
427
  }
429
428
  return parsedValue;
430
429
  };
@@ -1825,7 +1824,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
1825
1824
  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';
1826
1825
  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';
1827
1826
  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';
1828
- 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.27.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": "git clone https://github.com/defenseunicorns/pepr-upgrade-test.git", "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.10", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.1", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.0.1", "@commitlint/config-conventional": "19.0.0", "@jest/globals": "29.7.0", "@types/eslint": "8.56.4", "@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" } };
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" } };
1829
1828
 
1830
1829
  // src/templates/pepr.code-snippets.json
1831
1830
  var pepr_code_snippets_default = {
@@ -1928,7 +1927,6 @@ function genPkgJSON(opts, pgkVerOverride) {
1928
1927
  node: ">=18.0.0"
1929
1928
  },
1930
1929
  pepr: {
1931
- name: opts.name.trim(),
1932
1930
  uuid: pgkVerOverride ? "static-test" : uuid,
1933
1931
  onError: opts.errorBehavior,
1934
1932
  webhookTimeout: 10,
@@ -1938,8 +1936,7 @@ function genPkgJSON(opts, pgkVerOverride) {
1938
1936
  }
1939
1937
  },
1940
1938
  alwaysIgnore: {
1941
- namespaces: [],
1942
- labels: []
1939
+ namespaces: []
1943
1940
  },
1944
1941
  includedFiles: [],
1945
1942
  env: pgkVerOverride ? testEnv : {}
@@ -2059,7 +2056,7 @@ async function peprFormat(validateOnly) {
2059
2056
  }
2060
2057
 
2061
2058
  // src/cli/build.ts
2062
- var import_commander2 = require("commander");
2059
+ var import_commander = require("commander");
2063
2060
  var peprTS2 = "pepr.ts";
2064
2061
  var outputDir = "dist";
2065
2062
  function build_default(program2) {
@@ -2067,22 +2064,25 @@ function build_default(program2) {
2067
2064
  "-n, --no-embed",
2068
2065
  "Disables embedding of deployment files into output module. Useful when creating library modules intended solely for reuse/distribution via NPM."
2069
2066
  ).option(
2070
- "-i, --custom-image [custom-image]",
2067
+ "-i, --custom-image <custom-image>",
2071
2068
  "Custom Image: Use custom image for Admission and Watch Deployments."
2072
2069
  ).option(
2073
2070
  "-r, --registry-info [<registry>/<username>]",
2074
2071
  "Registry Info: Image registry and username. Note: You must be signed into the registry"
2075
- ).option("-o, --output-dir [output directory]", "Define where to place build output").option(
2076
- "--timeout [timeout]",
2072
+ ).option("-o, --output-dir <output directory>", "Define where to place build output").option(
2073
+ "--timeout <timeout>",
2077
2074
  "How long the API server should wait for a webhook to respond before treating the call as a failure",
2078
2075
  parseTimeout
2076
+ ).option(
2077
+ "-v, --version <version>. Example: '0.27.3'",
2078
+ "The version of the Pepr image to use in the deployment manifests."
2079
2079
  ).addOption(
2080
- new import_commander2.Option(
2080
+ new import_commander.Option(
2081
2081
  "--registry <GitHub|Iron Bank>",
2082
2082
  "Container registry: Choose container registry for deployment manifests. Can't be used with --custom-image."
2083
2083
  ).choices(["GitHub", "Iron Bank"])
2084
2084
  ).addOption(
2085
- new import_commander2.Option("--rbac-mode [admin|scoped]", "Rbac Mode: admin, scoped (default: admin)").choices(["admin", "scoped"]).default("admin")
2085
+ new import_commander.Option("--rbac-mode [admin|scoped]", "Rbac Mode: admin, scoped (default: admin)").choices(["admin", "scoped"]).default("admin")
2086
2086
  ).action(async (opts) => {
2087
2087
  if (opts.outputDir) {
2088
2088
  outputDir = opts.outputDir;
@@ -2117,6 +2117,9 @@ function build_default(program2) {
2117
2117
  console.info(`\u2705 Module built successfully at ${path}`);
2118
2118
  return;
2119
2119
  }
2120
+ if (opts.version) {
2121
+ cfg.pepr.peprVersion = opts.version;
2122
+ }
2120
2123
  const assets = new Assets(
2121
2124
  {
2122
2125
  ...cfg.pepr,
@@ -2297,8 +2300,9 @@ function deploy_default(program2) {
2297
2300
  if (opts.image) {
2298
2301
  webhook.image = opts.image;
2299
2302
  }
2303
+ const timeout = cfg.pepr.webhookTimeout ? cfg.pepr.webhookTimeout : 10;
2300
2304
  try {
2301
- await webhook.deploy(opts.force);
2305
+ await webhook.deploy(opts.force, timeout);
2302
2306
  await namespaceDeploymentsReady();
2303
2307
  console.info(`\u2705 Module deployed successfully`);
2304
2308
  } catch (e) {
@@ -2619,11 +2623,11 @@ function uuid_default(program2) {
2619
2623
  }
2620
2624
 
2621
2625
  // src/cli/root.ts
2622
- var import_commander3 = require("commander");
2623
- var RootCmd = class extends import_commander3.Command {
2626
+ var import_commander2 = require("commander");
2627
+ var RootCmd = class extends import_commander2.Command {
2624
2628
  // eslint-disable-next-line class-methods-use-this
2625
2629
  createCommand(name2) {
2626
- const cmd = new import_commander3.Command(name2);
2630
+ const cmd = new import_commander2.Command(name2);
2627
2631
  cmd.option("-l, --log-level [level]", "Log level: debug, info, warn, error", "info");
2628
2632
  cmd.hook("preAction", (run) => {
2629
2633
  logger_default.level = run.opts().logLevel;
@@ -2690,6 +2694,39 @@ function update_default(program2) {
2690
2694
  });
2691
2695
  }
2692
2696
 
2697
+ // src/cli/kfc.ts
2698
+ var import_child_process6 = require("child_process");
2699
+ var import_prompts6 = __toESM(require("prompts"));
2700
+ function kfc_default(program2) {
2701
+ program2.command("kfc [args...]").description("Execute Kubernetes Fluent Client commands").action(async (args) => {
2702
+ const { confirm: confirm2 } = await (0, import_prompts6.default)({
2703
+ type: "confirm",
2704
+ name: "confirm",
2705
+ message: "For commands that generate files, this may overwrite any previously generated files.\nAre you sure you want to continue?"
2706
+ });
2707
+ if (!confirm2) {
2708
+ return;
2709
+ }
2710
+ console.log("Preparing to execute the requested KFC command...");
2711
+ try {
2712
+ if (args.length === 0) {
2713
+ console.log(
2714
+ "No kubernetes-fluent-client arguments provided. Showing kubernetes-fluent-client help..."
2715
+ );
2716
+ args.push("--help");
2717
+ }
2718
+ const argsString = args.join(" ");
2719
+ (0, import_child_process6.execSync)(`kubernetes-fluent-client ${argsString}`, {
2720
+ stdio: "inherit"
2721
+ });
2722
+ console.log(`\u2705 KFC command executed successfully`);
2723
+ } catch (e) {
2724
+ console.error(e.message);
2725
+ process.exit(1);
2726
+ }
2727
+ });
2728
+ }
2729
+
2693
2730
  // src/cli.ts
2694
2731
  if (process.env.npm_lifecycle_event !== "npx") {
2695
2732
  console.warn("Pepr should be run via `npx pepr <command>` instead of `pepr <command>`.");
@@ -2714,4 +2751,5 @@ update_default(program);
2714
2751
  format_default(program);
2715
2752
  monitor_default(program);
2716
2753
  uuid_default(program);
2754
+ kfc_default(program);
2717
2755
  program.parse();
@@ -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.27.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": "git clone https://github.com/defenseunicorns/pepr-upgrade-test.git", "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.10", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.1", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.0.1", "@commitlint/config-conventional": "19.0.0", "@jest/globals": "29.7.0", "@types/eslint": "8.56.4", "@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.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" } };
53
53
 
54
54
  // src/lib/k8s.ts
55
55
  var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
@@ -1,10 +1,17 @@
1
+ import { KubernetesObject } from "kubernetes-fluent-client";
1
2
  import { CapabilityExport } from "./types";
3
+ import { Binding } from "./types";
2
4
  type RBACMap = {
3
5
  [key: string]: {
4
6
  verbs: string[];
5
7
  plural: string;
6
8
  };
7
9
  };
10
+ export declare function checkOverlap(record1: Record<string, string>, record2: Record<string, string>): boolean;
11
+ /**
12
+ * Decide to run callback after the event comes back from API Server
13
+ **/
14
+ export declare const filterMatcher: (binding: Partial<Binding>, obj: Partial<KubernetesObject>, capabilityNamespaces: string[]) => string;
8
15
  export declare const addVerbIfNotExists: (verbs: string[], verb: string) => void;
9
16
  export declare const createRBACMap: (capabilities: CapabilityExport[]) => RBACMap;
10
17
  export declare function createDirectoryIfNotExists(path: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI3C,KAAK,OAAO,GAAG;IACb,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,EAAE,QAAQ,MAAM,SAI/D,CAAC;AAEF,eAAO,MAAM,aAAa,iBAAkB,gBAAgB,EAAE,KAAG,OAoBhE,CAAC;AAEF,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,iBAU5D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAMpE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAMlE;AAED,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAE/F;AAED,wBAAgB,8BAA8B,CAAC,iBAAiB,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AAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAK1E"}
package/dist/lib/k8s.d.ts CHANGED
@@ -128,16 +128,5 @@ export type WebhookIgnore = {
128
128
  * Note: `kube-system` and `pepr-system` are always ignored.
129
129
  */
130
130
  namespaces?: string[];
131
- /**
132
- * List of Kubernetes labels to always ignore.
133
- * Any resources with these labels will be ignored by Pepr.
134
- *
135
- * The example below will ignore any resources with the label `my-label=ulta-secret`:
136
- * ```
137
- * alwaysIgnore:
138
- * labels: [{ "my-label": "ultra-secret" }]
139
- * ```
140
- */
141
- labels?: Record<string, string>[];
142
131
  };
143
132
  //# sourceMappingURL=k8s.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"k8s.d.ts","sourceRoot":"","sources":["../../src/lib/k8s.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAEzG,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,WAAW;IAChC,IAAI,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAIF;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,gBAAgB;IACpD,gEAAgE;IAChE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,+GAA+G;IAC/G,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC,s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AE1B;;;;;;OAMG;IAEH,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,kIAAkI;IAClI,GAAG,EAAE,MAAM,CAAC;IAEZ,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IAEjB,6IAA6I;IAC7I,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IAEF,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,6IAA6I;IAC7I,MAAM,CAAC,EAAE;QACP;2FACmF;QACnF,IAAI,EAAE,MAAM,CAAC;QAEb,oEAAoE;QACpE,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC"}
@@ -6,8 +6,6 @@ export interface CustomLabels {
6
6
  }
7
7
  /** Global configuration for the Pepr runtime. */
8
8
  export type ModuleConfig = {
9
- /** The user-defined name for the module */
10
- name: string;
11
9
  /** The Pepr version this module uses */
12
10
  peprVersion?: string;
13
11
  /** The user-defined version of the module */
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAK1F,0CAA0C;AAC1C,MAAM,WAAW,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B,qHAAqH;IACrH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE7C,6GAA6G;IAC7G,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,CAAC;CAC9D,CAAC;AAGF,eAAO,MAAM,WAAW,eAA+C,CAAC;AAGxE,eAAO,MAAM,WAAW,eAA0C,CAAC;AAEnE,eAAO,MAAM,SAAS,eAAwC,CAAC;AAE/D,qBAAa,UAAU;;IAGrB;;;;;;OAMG;gBACS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,GAAE,UAAU,EAAO,EAAE,IAAI,GAAE,iBAAsB;IAoD7G;;;;;OAKG;IACH,KAAK,0BAEH;CACH"}
@@ -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;AAY1C,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAoC5C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,iBAOxE"}
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"}
package/dist/lib.js CHANGED
@@ -31,26 +31,26 @@ 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_client5.K8s,
34
+ K8s: () => import_kubernetes_fluent_client6.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_client5.RegisterKind,
42
- a: () => import_kubernetes_fluent_client5.kind,
41
+ RegisterKind: () => import_kubernetes_fluent_client6.RegisterKind,
42
+ a: () => import_kubernetes_fluent_client6.kind,
43
43
  containers: () => containers,
44
- fetch: () => import_kubernetes_fluent_client5.fetch,
45
- fetchStatus: () => import_kubernetes_fluent_client5.fetchStatus,
46
- kind: () => import_kubernetes_fluent_client5.kind
44
+ fetch: () => import_kubernetes_fluent_client6.fetch,
45
+ fetchStatus: () => import_kubernetes_fluent_client6.fetchStatus,
46
+ kind: () => import_kubernetes_fluent_client6.kind
47
47
  });
48
48
  module.exports = __toCommonJS(lib_exports);
49
- var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
49
+ var import_kubernetes_fluent_client6 = require("kubernetes-fluent-client");
50
50
  var R = __toESM(require("ramda"));
51
51
 
52
52
  // src/lib/capability.ts
53
- var import_kubernetes_fluent_client4 = require("kubernetes-fluent-client");
53
+ var import_kubernetes_fluent_client5 = require("kubernetes-fluent-client");
54
54
  var import_ramda6 = require("ramda");
55
55
 
56
56
  // src/lib/logger.ts
@@ -187,7 +187,7 @@ var peprStoreGVK = {
187
187
 
188
188
  // src/lib/filter.ts
189
189
  function shouldSkipRequest(binding, req, capabilityNamespaces) {
190
- const { group, kind: kind2, version } = binding.kind || {};
190
+ const { group, kind: kind3, version } = binding.kind || {};
191
191
  const { namespaces, labels, annotations, name } = binding.filters || {};
192
192
  const operation = req.operation.toUpperCase();
193
193
  const srcObject = operation === "DELETE" /* DELETE */ ? req.oldObject : req.object;
@@ -199,7 +199,7 @@ function shouldSkipRequest(binding, req, capabilityNamespaces) {
199
199
  if (name && name !== req.name) {
200
200
  return true;
201
201
  }
202
- if (kind2 !== req.kind.kind) {
202
+ if (kind3 !== req.kind.kind) {
203
203
  return true;
204
204
  }
205
205
  if (group && group !== req.kind.group) {
@@ -969,7 +969,7 @@ var Controller = class _Controller {
969
969
 
970
970
  // src/lib/watch-processor.ts
971
971
  var import_crypto = require("crypto");
972
- var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
972
+ var import_kubernetes_fluent_client4 = require("kubernetes-fluent-client");
973
973
  var import_types2 = require("kubernetes-fluent-client/dist/fluent/types");
974
974
 
975
975
  // src/lib/queue.ts
@@ -1023,6 +1023,53 @@ var Queue = class {
1023
1023
  }
1024
1024
  };
1025
1025
 
1026
+ // src/lib/helpers.ts
1027
+ var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
1028
+ function checkOverlap(record1, record2) {
1029
+ if (Object.keys(record1).length === 0) {
1030
+ return true;
1031
+ }
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;
1035
+ }
1036
+ }
1037
+ return false;
1038
+ }
1039
+ var filterMatcher = (binding, obj, capabilityNamespaces) => {
1040
+ if (binding.kind && binding.kind.kind === "Namespace" && binding.filters && binding.filters.namespaces.length !== 0) {
1041
+ return `Ignoring Watch Callback: Cannot use a namespace filter in a namespace object.`;
1042
+ }
1043
+ if (typeof obj === "object" && obj !== null && "metadata" in obj && obj.metadata !== void 0 && binding.filters) {
1044
+ if (obj.metadata.labels && !checkOverlap(binding.filters.labels, obj.metadata.labels)) {
1045
+ return `Ignoring Watch Callback: No overlap between binding and object labels. Binding labels ${JSON.stringify(
1046
+ binding.filters.labels
1047
+ )}, Object Labels ${JSON.stringify(obj.metadata.labels)}.`;
1048
+ }
1049
+ if (obj.metadata.annotations && !checkOverlap(binding.filters.annotations, obj.metadata.annotations)) {
1050
+ return `Ignoring Watch Callback: No overlap between binding and object annotations. Binding annotations ${JSON.stringify(
1051
+ binding.filters.annotations
1052
+ )}, Object annotations ${JSON.stringify(obj.metadata.annotations)}.`;
1053
+ }
1054
+ }
1055
+ if (Array.isArray(capabilityNamespaces) && capabilityNamespaces.length > 0 && obj.metadata && obj.metadata.namespace && !capabilityNamespaces.includes(obj.metadata.namespace)) {
1056
+ return `Ignoring Watch Callback: Object is not in the capability namespace. Capability namespaces: ${capabilityNamespaces.join(
1057
+ ", "
1058
+ )}, Object namespace: ${obj.metadata.namespace}.`;
1059
+ }
1060
+ if (Array.isArray(capabilityNamespaces) && capabilityNamespaces.length > 0 && binding.filters && Array.isArray(binding.filters.namespaces) && binding.filters.namespaces.length > 0 && !binding.filters.namespaces.every((ns) => capabilityNamespaces.includes(ns))) {
1061
+ return `Ignoring Watch Callback: Binding namespace is not part of capability namespaces. Capability namespaces: ${capabilityNamespaces.join(
1062
+ ", "
1063
+ )}, Binding namespaces: ${binding.filters.namespaces.join(", ")}.`;
1064
+ }
1065
+ if (binding.filters && Array.isArray(binding.filters.namespaces) && binding.filters.namespaces.length > 0 && obj.metadata && obj.metadata.namespace && !binding.filters.namespaces.includes(obj.metadata.namespace)) {
1066
+ return `Ignoring Watch Callback: Binding namespace and object namespace are not the same. Binding namespaces: ${binding.filters.namespaces.join(
1067
+ ", "
1068
+ )}, Object namespace: ${obj.metadata.namespace}.`;
1069
+ }
1070
+ return "";
1071
+ };
1072
+
1026
1073
  // src/lib/watch-processor.ts
1027
1074
  var storeUpdates = false;
1028
1075
  var store = {};
@@ -1030,7 +1077,7 @@ async function setupStore(uuid) {
1030
1077
  const name = `pepr-${uuid}-watch`;
1031
1078
  const namespace2 = "pepr-system";
1032
1079
  try {
1033
- const k8sStore = await (0, import_kubernetes_fluent_client3.K8s)(PeprStore).InNamespace(namespace2).Get(name);
1080
+ const k8sStore = await (0, import_kubernetes_fluent_client4.K8s)(PeprStore).InNamespace(namespace2).Get(name);
1034
1081
  Object.entries(k8sStore.data).forEach(([key, value]) => {
1035
1082
  store[key] = value;
1036
1083
  });
@@ -1039,7 +1086,7 @@ async function setupStore(uuid) {
1039
1086
  }
1040
1087
  setInterval(() => {
1041
1088
  if (storeUpdates) {
1042
- (0, import_kubernetes_fluent_client3.K8s)(PeprStore).Apply({
1089
+ (0, import_kubernetes_fluent_client4.K8s)(PeprStore).Apply({
1043
1090
  metadata: {
1044
1091
  name,
1045
1092
  namespace: namespace2
@@ -1053,9 +1100,11 @@ async function setupStore(uuid) {
1053
1100
  }
1054
1101
  async function setupWatch(uuid, capabilities) {
1055
1102
  await setupStore(uuid);
1056
- capabilities.flatMap((c) => c.bindings).filter((binding) => binding.isWatch).forEach(runBinding);
1103
+ capabilities.map(
1104
+ (capability) => capability.bindings.filter((binding) => binding.isWatch).forEach((bindingElement) => runBinding(bindingElement, capability.namespaces))
1105
+ );
1057
1106
  }
1058
- async function runBinding(binding) {
1107
+ async function runBinding(binding, capabilityNamespaces) {
1059
1108
  const eventToPhaseMap = {
1060
1109
  ["CREATE" /* Create */]: [import_types2.WatchPhase.Added],
1061
1110
  ["UPDATE" /* Update */]: [import_types2.WatchPhase.Modified],
@@ -1071,23 +1120,33 @@ async function runBinding(binding) {
1071
1120
  let watcher;
1072
1121
  if (binding.isQueue) {
1073
1122
  const queue = new Queue();
1074
- watcher = (0, import_kubernetes_fluent_client3.K8s)(binding.model, binding.filters).Watch(async (obj, type) => {
1123
+ watcher = (0, import_kubernetes_fluent_client4.K8s)(binding.model, binding.filters).Watch(async (obj, type) => {
1075
1124
  logger_default.debug(obj, `Watch event ${type} received`);
1076
1125
  if (phaseMatch.includes(type)) {
1077
1126
  try {
1078
- queue.setReconcile(async () => await binding.watchCallback?.(obj, type));
1079
- await queue.enqueue(obj);
1127
+ const filterMatch = filterMatcher(binding, obj, capabilityNamespaces);
1128
+ if (filterMatch === "") {
1129
+ queue.setReconcile(async () => await binding.watchCallback?.(obj, type));
1130
+ await queue.enqueue(obj);
1131
+ } else {
1132
+ logger_default.debug(filterMatch);
1133
+ }
1080
1134
  } catch (e) {
1081
1135
  logger_default.error(e, "Error executing watch callback");
1082
1136
  }
1083
1137
  }
1084
1138
  }, watchCfg);
1085
1139
  } else {
1086
- watcher = (0, import_kubernetes_fluent_client3.K8s)(binding.model, binding.filters).Watch(async (obj, type) => {
1140
+ watcher = (0, import_kubernetes_fluent_client4.K8s)(binding.model, binding.filters).Watch(async (obj, type) => {
1087
1141
  logger_default.debug(obj, `Watch event ${type} received`);
1088
1142
  if (phaseMatch.includes(type)) {
1089
1143
  try {
1090
- await binding.watchCallback?.(obj, type);
1144
+ const filterMatch = filterMatcher(binding, obj, capabilityNamespaces);
1145
+ if (filterMatch === "") {
1146
+ await binding.watchCallback?.(obj, type);
1147
+ } else {
1148
+ logger_default.debug(filterMatch);
1149
+ }
1091
1150
  } catch (e) {
1092
1151
  logger_default.error(e, "Error executing watch callback");
1093
1152
  }
@@ -1096,7 +1155,7 @@ async function runBinding(binding) {
1096
1155
  }
1097
1156
  const cacheSuffix = (0, import_crypto.createHash)("sha224").update(binding.watchCallback.toString()).digest("hex").substring(0, 5);
1098
1157
  const cacheID = [watcher.getCacheID(), cacheSuffix].join("-");
1099
- watcher.events.on(import_kubernetes_fluent_client3.WatchEvent.RESOURCE_VERSION, (version) => {
1158
+ watcher.events.on(import_kubernetes_fluent_client4.WatchEvent.RESOURCE_VERSION, (version) => {
1100
1159
  logger_default.debug(`Received watch cache: ${cacheID}:${version}`);
1101
1160
  if (store[cacheID] !== version) {
1102
1161
  logger_default.debug(`Updating watch cache: ${cacheID}: ${store[cacheID]} => ${version}`);
@@ -1104,7 +1163,7 @@ async function runBinding(binding) {
1104
1163
  storeUpdates = true;
1105
1164
  }
1106
1165
  });
1107
- watcher.events.on(import_kubernetes_fluent_client3.WatchEvent.GIVE_UP, (err) => {
1166
+ watcher.events.on(import_kubernetes_fluent_client4.WatchEvent.GIVE_UP, (err) => {
1108
1167
  logger_default.error(err, "Watch failed after 5 attempts, giving up");
1109
1168
  process.exit(1);
1110
1169
  });
@@ -1547,15 +1606,15 @@ var Capability = class {
1547
1606
  * @param kind if using a custom KubernetesObject not available in `a.*`, specify the GroupVersionKind
1548
1607
  * @returns
1549
1608
  */
1550
- When = (model, kind2) => {
1551
- const matchedKind = (0, import_kubernetes_fluent_client4.modelToGroupVersionKind)(model.name);
1552
- if (!matchedKind && !kind2) {
1609
+ When = (model, kind3) => {
1610
+ const matchedKind = (0, import_kubernetes_fluent_client5.modelToGroupVersionKind)(model.name);
1611
+ if (!matchedKind && !kind3) {
1553
1612
  throw new Error(`Kind not specified for ${model.name}`);
1554
1613
  }
1555
1614
  const binding = {
1556
1615
  model,
1557
1616
  // If the kind is not specified, use the matched kind from the model
1558
- kind: kind2 || matchedKind,
1617
+ kind: kind3 || matchedKind,
1559
1618
  event: "*" /* Any */,
1560
1619
  filters: {
1561
1620
  name: "",