pepr 0.15.0 → 0.16.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.
@@ -0,0 +1,37 @@
1
+ # Pepr Best Practices (WIP)
2
+
3
+ ## TOC
4
+
5
+ - [Store](#pepr-store)
6
+ - [OnSchedule](#onschedule)
7
+ - [Watch](#watch)
8
+
9
+
10
+ ## Pepr Store
11
+
12
+ The store is backed by ETCD in a `PeprStore` resource, and updates happen at 5-second intervals when an array of patches is sent to the Kubernetes API Server. The store is intentionally not designed to be `transactional`; instead, it is built to be eventually consistent, meaning that the last operation within the interval will be persisted, potentially overwriting other operations. In simpler terms, changes to the data are made without a guarantee that they will occur simultaneously, so caution is needed in managing errors and ensuring consistency.
13
+
14
+
15
+ ## OnSchedule
16
+
17
+ `OnSchedule` is supported by a `PeprStore` to safeguard against schedule loss following a pod restart. It is utilized at the top level, distinct from being within a `Validate`, `Mutate`, or `Watch`. Recommended intervals are 30 seconds or longer, and jobs are advised to be idempotent, meaning that if the code is applied or executed multiple times, the outcome should be the same as if it had been executed only once. A major use-case for `OnSchedule` is day 2 operations.
18
+
19
+ ## Watch
20
+
21
+ Pepr facilitates efficient change notifications on resources through `Watch`. It is recommended to use `Watch` instead of `Mutate` or `Validate` when longer running operations are needed, as there is no [timeout limitation](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#timeouts). An instance where `Watch` is beneficial is when API calls need to be chained together. `Watch` operations can be sequentially executed after `Mutate` and `Validate`.
22
+
23
+ ```typescript
24
+ When(a.Pod)
25
+ .IsCreated()
26
+ .InNamespace("my-app")
27
+ .WithName("database")
28
+ .Mutate(pod => // .... )
29
+ .Validate(pod => // .... )
30
+ .Watch(async (pod, phase) => {
31
+ Log.info(pod, `Pod was ${phase}.`);
32
+
33
+ // do consecutive api calls
34
+ ```
35
+
36
+
37
+ [TOP](#pepr-best-practices)
package/dist/cli.js CHANGED
@@ -106,7 +106,7 @@ var banner = `\x1B[0m\x1B[38;2;96;96;96m \x1B[0m\x1B[38;2;96;96;96m \x1B[0m\x1B[
106
106
  // src/cli/build.ts
107
107
  var import_child_process2 = require("child_process");
108
108
  var import_esbuild = require("esbuild");
109
- var import_fs6 = require("fs");
109
+ var import_fs7 = require("fs");
110
110
  var import_path = require("path");
111
111
 
112
112
  // src/lib/included-files.ts
@@ -187,7 +187,7 @@ function genCert(key, name2, issuer) {
187
187
 
188
188
  // src/lib/assets/deploy.ts
189
189
  var import_crypto = __toESM(require("crypto"));
190
- var import_fs2 = require("fs");
190
+ var import_fs3 = require("fs");
191
191
  var import_kubernetes_fluent_client2 = require("kubernetes-fluent-client");
192
192
 
193
193
  // src/lib/logger.ts
@@ -530,6 +530,7 @@ function moduleSecret(name2, data, hash) {
530
530
  }
531
531
 
532
532
  // src/lib/helpers.ts
533
+ var import_fs2 = require("fs");
533
534
  var createRBACMap = (capabilities) => {
534
535
  return capabilities.reduce((acc, capability) => {
535
536
  capability.bindings.forEach((binding) => {
@@ -548,6 +549,17 @@ var createRBACMap = (capabilities) => {
548
549
  return acc;
549
550
  }, {});
550
551
  };
552
+ async function createDirectoryIfNotExists(path) {
553
+ try {
554
+ await import_fs2.promises.access(path);
555
+ } catch (error) {
556
+ if (error.code === "ENOENT") {
557
+ await import_fs2.promises.mkdir(path, { recursive: true });
558
+ } else {
559
+ throw error;
560
+ }
561
+ }
562
+ }
551
563
 
552
564
  // src/lib/assets/rbac.ts
553
565
  function clusterRole(name2, capabilities, rbacMode = "") {
@@ -815,7 +827,7 @@ async function deploy(assets, webhookTimeout) {
815
827
  if (host) {
816
828
  return;
817
829
  }
818
- const code = await import_fs2.promises.readFile(path);
830
+ const code = await import_fs3.promises.readFile(path);
819
831
  const hash = import_crypto.default.createHash("sha256").update(code).digest("hex");
820
832
  if (code.length < 1) {
821
833
  throw new Error("No code provided");
@@ -897,7 +909,7 @@ function loadCapabilities(path) {
897
909
  // src/lib/assets/yaml.ts
898
910
  var import_client_node = require("@kubernetes/client-node");
899
911
  var import_crypto2 = __toESM(require("crypto"));
900
- var import_fs3 = require("fs");
912
+ var import_fs4 = require("fs");
901
913
  function zarfYaml({ name: name2, image, config }, path) {
902
914
  const zarfCfg = {
903
915
  kind: "ZarfPackageConfig",
@@ -926,7 +938,7 @@ function zarfYaml({ name: name2, image, config }, path) {
926
938
  }
927
939
  async function allYaml(assets, rbacMode) {
928
940
  const { name: name2, tls, apiToken, path } = assets;
929
- const code = await import_fs3.promises.readFile(path);
941
+ const code = await import_fs4.promises.readFile(path);
930
942
  const hash = import_crypto2.default.createHash("sha256").update(code).digest("hex");
931
943
  const mutateWebhook = await webhookConfig(assets, "mutate");
932
944
  const validateWebhook = await webhookConfig(assets, "validate");
@@ -1192,7 +1204,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
1192
1204
  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';
1193
1205
  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';
1194
1206
  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';
1195
- 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.15.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", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "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", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "1.8.0", pino: "8.16.1", "pino-pretty": "10.2.3", "prom-client": "15.0.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.2.0", "@commitlint/config-conventional": "18.1.0", "@jest/globals": "29.7.0", "@types/eslint": "8.44.6", "@types/express": "4.17.20", "@types/node": "18.x.x", "@types/node-forge": "1.3.8", "@types/prompts": "2.4.7", "@types/ramda": "0.29.7", "@types/uuid": "9.0.6", jest: "29.7.0", nock: "13.3.6", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.7.3", "@typescript-eslint/parser": "6.7.3", commander: "11.0.0", esbuild: "0.19.4", eslint: "8.50.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.1" } };
1207
+ 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.16.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", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "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", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.9", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "1.8.2", pino: "8.16.2", "pino-pretty": "10.2.3", "prom-client": "15.0.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.4.1", "@commitlint/config-conventional": "18.4.0", "@jest/globals": "29.7.0", "@types/eslint": "8.44.7", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.9", "@types/prompts": "2.4.8", "@types/uuid": "9.0.7", jest: "29.7.0", nock: "13.3.8", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.7.3", "@typescript-eslint/parser": "6.7.3", commander: "11.0.0", esbuild: "0.19.4", eslint: "8.50.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.1" } };
1196
1208
 
1197
1209
  // src/templates/pepr.code-snippets.json
1198
1210
  var pepr_code_snippets_default = {
@@ -1250,7 +1262,7 @@ var tsconfig_module_default = {
1250
1262
  };
1251
1263
 
1252
1264
  // src/cli/init/utils.ts
1253
- var import_fs4 = require("fs");
1265
+ var import_fs5 = require("fs");
1254
1266
  function sanitizeName(name2) {
1255
1267
  let sanitized = name2.toLowerCase().replace(/[^a-z0-9-]+/gi, "-");
1256
1268
  sanitized = sanitized.replace(/^-+|-+$/g, "");
@@ -1259,7 +1271,7 @@ function sanitizeName(name2) {
1259
1271
  }
1260
1272
  async function createDir(dir) {
1261
1273
  try {
1262
- await import_fs4.promises.mkdir(dir);
1274
+ await import_fs5.promises.mkdir(dir);
1263
1275
  } catch (err) {
1264
1276
  if (err && err.code === "EEXIST") {
1265
1277
  throw new Error(`Directory ${dir} already exists`);
@@ -1272,7 +1284,7 @@ function write(path, data) {
1272
1284
  if (typeof data !== "string") {
1273
1285
  data = JSON.stringify(data, null, 2);
1274
1286
  }
1275
- return import_fs4.promises.writeFile(path, data);
1287
+ return import_fs5.promises.writeFile(path, data);
1276
1288
  }
1277
1289
 
1278
1290
  // src/cli/init/templates.ts
@@ -1360,7 +1372,7 @@ var eslint = {
1360
1372
 
1361
1373
  // src/cli/format.ts
1362
1374
  var import_eslint = require("eslint");
1363
- var import_fs5 = require("fs");
1375
+ var import_fs6 = require("fs");
1364
1376
  var import_prettier = require("prettier");
1365
1377
  function format_default(program2) {
1366
1378
  program2.command("format").description("Lint and format this Pepr module").option("-v, --validate-only", "Do not modify files, only validate formatting").action(async (opts) => {
@@ -1393,7 +1405,7 @@ async function peprFormat(validateOnly) {
1393
1405
  await import_eslint.ESLint.outputFixes(results);
1394
1406
  }
1395
1407
  for (const { filePath } of results) {
1396
- const content = await import_fs5.promises.readFile(filePath, "utf8");
1408
+ const content = await import_fs6.promises.readFile(filePath, "utf8");
1397
1409
  const cfg = await (0, import_prettier.resolveConfig)(filePath);
1398
1410
  const formatted = await (0, import_prettier.format)(content, { filepath: filePath, ...cfg });
1399
1411
  if (validateOnly) {
@@ -1402,7 +1414,7 @@ async function peprFormat(validateOnly) {
1402
1414
  console.error(`File ${filePath} is not formatted correctly`);
1403
1415
  }
1404
1416
  } else {
1405
- await import_fs5.promises.writeFile(filePath, formatted);
1417
+ await import_fs6.promises.writeFile(filePath, formatted);
1406
1418
  }
1407
1419
  }
1408
1420
  return !hasFailure;
@@ -1416,6 +1428,7 @@ async function peprFormat(validateOnly) {
1416
1428
  // src/cli/build.ts
1417
1429
  var import_commander = require("commander");
1418
1430
  var peprTS2 = "pepr.ts";
1431
+ var outputDir = "dist";
1419
1432
  function build_default(program2) {
1420
1433
  program2.command("build").description("Build a Pepr Module for deployment").option(
1421
1434
  "-e, --entry-point [file]",
@@ -1424,9 +1437,16 @@ function build_default(program2) {
1424
1437
  ).option(
1425
1438
  "-r, --registry-info [<registry>/<username>]",
1426
1439
  "Registry Info: Image registry and username. Note: You must be signed into the registry"
1427
- ).addOption(
1440
+ ).option("-o, --output-dir [output directory]", "Define where to place build output").addOption(
1428
1441
  new import_commander.Option("--rbac-mode [admin|scoped]", "Rbac Mode: admin, scoped (default: admin)").choices(["admin", "scoped"]).default("admin")
1429
1442
  ).action(async (opts) => {
1443
+ if (opts.outputDir) {
1444
+ outputDir = opts.outputDir;
1445
+ createDirectoryIfNotExists(outputDir).catch((error) => {
1446
+ console.error(`Error creating output directory: ${error}`);
1447
+ process.exit(1);
1448
+ });
1449
+ }
1430
1450
  const { cfg, path, uuid } = await buildModule(void 0, opts.entryPoint);
1431
1451
  const { includedFiles } = cfg.pepr;
1432
1452
  let image = "";
@@ -1455,12 +1475,12 @@ function build_default(program2) {
1455
1475
  assets.image = image;
1456
1476
  }
1457
1477
  const yamlFile = `pepr-module-${uuid}.yaml`;
1458
- const yamlPath = (0, import_path.resolve)("dist", yamlFile);
1478
+ const yamlPath = (0, import_path.resolve)(outputDir, yamlFile);
1459
1479
  const yaml = await assets.allYaml(opts.rbacMode);
1460
- const zarfPath = (0, import_path.resolve)("dist", "zarf.yaml");
1480
+ const zarfPath = (0, import_path.resolve)(outputDir, "zarf.yaml");
1461
1481
  const zarf = assets.zarfYaml(yamlFile);
1462
- await import_fs6.promises.writeFile(yamlPath, yaml);
1463
- await import_fs6.promises.writeFile(zarfPath, zarf);
1482
+ await import_fs7.promises.writeFile(yamlPath, yaml);
1483
+ await import_fs7.promises.writeFile(zarfPath, zarf);
1464
1484
  console.info(`\u2705 K8s resource for the module saved to ${yamlPath}`);
1465
1485
  });
1466
1486
  }
@@ -1471,15 +1491,15 @@ async function loadModule(entryPoint = peprTS2) {
1471
1491
  const cfgPath = (0, import_path.resolve)(".", "package.json");
1472
1492
  const input = (0, import_path.resolve)(".", entryPoint);
1473
1493
  try {
1474
- await import_fs6.promises.access(cfgPath);
1475
- await import_fs6.promises.access(input);
1494
+ await import_fs7.promises.access(cfgPath);
1495
+ await import_fs7.promises.access(input);
1476
1496
  } catch (e) {
1477
1497
  console.error(
1478
1498
  `Could not find ${cfgPath} or ${input} in the current directory. Please run this command from the root of your module's directory.`
1479
1499
  );
1480
1500
  process.exit(1);
1481
1501
  }
1482
- const moduleText = await import_fs6.promises.readFile(cfgPath, { encoding: "utf-8" });
1502
+ const moduleText = await import_fs7.promises.readFile(cfgPath, { encoding: "utf-8" });
1483
1503
  const cfg = JSON.parse(moduleText);
1484
1504
  const { uuid } = cfg.pepr;
1485
1505
  const name2 = `pepr-${uuid}.js`;
@@ -1491,7 +1511,7 @@ async function loadModule(entryPoint = peprTS2) {
1491
1511
  cfg,
1492
1512
  input,
1493
1513
  name: name2,
1494
- path: (0, import_path.resolve)("dist", name2),
1514
+ path: (0, import_path.resolve)(outputDir, name2),
1495
1515
  uuid
1496
1516
  };
1497
1517
  }
@@ -1540,7 +1560,7 @@ async function buildModule(reloader, entryPoint = peprTS2) {
1540
1560
  }
1541
1561
  if (entryPoint !== peprTS2) {
1542
1562
  ctxCfg.minify = false;
1543
- ctxCfg.outfile = (0, import_path.resolve)("dist", (0, import_path.basename)(entryPoint, (0, import_path.extname)(entryPoint))) + ".js";
1563
+ ctxCfg.outfile = (0, import_path.resolve)(outputDir, (0, import_path.basename)(entryPoint, (0, import_path.extname)(entryPoint))) + ".js";
1544
1564
  ctxCfg.packages = "external";
1545
1565
  ctxCfg.treeShaking = false;
1546
1566
  }
@@ -1622,7 +1642,7 @@ function deploy_default(program2) {
1622
1642
 
1623
1643
  // src/cli/dev.ts
1624
1644
  var import_child_process3 = require("child_process");
1625
- var import_fs7 = require("fs");
1645
+ var import_fs8 = require("fs");
1626
1646
  var import_prompts2 = __toESM(require("prompts"));
1627
1647
  function dev_default(program2) {
1628
1648
  program2.command("dev").description("Setup a local webhook development environment").option("-h, --host [host]", "Host to listen on", "host.k3d.internal").option("--confirm", "Skip confirmation prompt").action(async (opts) => {
@@ -1645,8 +1665,8 @@ function dev_default(program2) {
1645
1665
  path,
1646
1666
  opts.host
1647
1667
  );
1648
- await import_fs7.promises.writeFile("insecure-tls.crt", webhook.tls.pem.crt);
1649
- await import_fs7.promises.writeFile("insecure-tls.key", webhook.tls.pem.key);
1668
+ await import_fs8.promises.writeFile("insecure-tls.crt", webhook.tls.pem.crt);
1669
+ await import_fs8.promises.writeFile("insecure-tls.key", webhook.tls.pem.key);
1650
1670
  try {
1651
1671
  let program3;
1652
1672
  const runFork = async () => {
@@ -1690,7 +1710,7 @@ var import_path2 = require("path");
1690
1710
  var import_prompts4 = __toESM(require("prompts"));
1691
1711
 
1692
1712
  // src/cli/init/walkthrough.ts
1693
- var import_fs8 = require("fs");
1713
+ var import_fs9 = require("fs");
1694
1714
  var import_prompts3 = __toESM(require("prompts"));
1695
1715
 
1696
1716
  // src/lib/errors.ts
@@ -1710,7 +1730,7 @@ function walkthrough() {
1710
1730
  validate: async (val) => {
1711
1731
  try {
1712
1732
  const name2 = sanitizeName(val);
1713
- await import_fs8.promises.access(name2, import_fs8.promises.constants.F_OK);
1733
+ await import_fs9.promises.access(name2, import_fs9.promises.constants.F_OK);
1714
1734
  return "A directory with this name already exists";
1715
1735
  } catch (e) {
1716
1736
  return val.length > 2 || "The name must be at least 3 characters long";
@@ -1845,7 +1865,7 @@ var RootCmd = class extends import_commander2.Command {
1845
1865
 
1846
1866
  // src/cli/update.ts
1847
1867
  var import_child_process5 = require("child_process");
1848
- var import_fs9 = __toESM(require("fs"));
1868
+ var import_fs10 = __toESM(require("fs"));
1849
1869
  var import_path3 = require("path");
1850
1870
  var import_prompts5 = __toESM(require("prompts"));
1851
1871
  function update_default(program2) {
@@ -1885,12 +1905,12 @@ function update_default(program2) {
1885
1905
  await write((0, import_path3.resolve)(".vscode", snippet.path), snippet.data);
1886
1906
  await write((0, import_path3.resolve)(".vscode", codeSettings.path), codeSettings.data);
1887
1907
  const samplePath = (0, import_path3.resolve)("capabilities", samplesYaml.path);
1888
- if (import_fs9.default.existsSync(samplePath)) {
1889
- import_fs9.default.unlinkSync(samplePath);
1908
+ if (import_fs10.default.existsSync(samplePath)) {
1909
+ import_fs10.default.unlinkSync(samplePath);
1890
1910
  await write(samplePath, samplesYaml.data);
1891
1911
  }
1892
1912
  const tsPath = (0, import_path3.resolve)("capabilities", helloPepr.path);
1893
- if (import_fs9.default.existsSync(tsPath)) {
1913
+ if (import_fs10.default.existsSync(tsPath)) {
1894
1914
  await write(tsPath, helloPepr.data);
1895
1915
  }
1896
1916
  }
@@ -48,7 +48,7 @@ if (process.env.LOG_LEVEL) {
48
48
  var logger_default = Log;
49
49
 
50
50
  // src/templates/data.json
51
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.15.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", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "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", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "1.8.0", pino: "8.16.1", "pino-pretty": "10.2.3", "prom-client": "15.0.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.2.0", "@commitlint/config-conventional": "18.1.0", "@jest/globals": "29.7.0", "@types/eslint": "8.44.6", "@types/express": "4.17.20", "@types/node": "18.x.x", "@types/node-forge": "1.3.8", "@types/prompts": "2.4.7", "@types/ramda": "0.29.7", "@types/uuid": "9.0.6", jest: "29.7.0", nock: "13.3.6", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.7.3", "@typescript-eslint/parser": "6.7.3", commander: "11.0.0", esbuild: "0.19.4", eslint: "8.50.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.1" } };
51
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.16.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", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "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", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.9", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "1.8.2", pino: "8.16.2", "pino-pretty": "10.2.3", "prom-client": "15.0.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.4.1", "@commitlint/config-conventional": "18.4.0", "@jest/globals": "29.7.0", "@types/eslint": "8.44.7", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.9", "@types/prompts": "2.4.8", "@types/uuid": "9.0.7", jest: "29.7.0", nock: "13.3.8", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.7.3", "@typescript-eslint/parser": "6.7.3", commander: "11.0.0", esbuild: "0.19.4", eslint: "8.50.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.1" } };
52
52
 
53
53
  // src/runtime/controller.ts
54
54
  var { version } = packageJSON;
@@ -1,11 +1,20 @@
1
1
  import { GenericClass, GroupVersionKind } from "kubernetes-fluent-client";
2
2
  import { PeprStore, Storage } from "./storage";
3
+ import { Schedule } from "./schedule";
3
4
  import { Binding, CapabilityCfg, CapabilityExport, WhenSelector } from "./types";
4
5
  /**
5
6
  * A capability is a unit of functionality that can be registered with the Pepr runtime.
6
7
  */
7
8
  export declare class Capability implements CapabilityExport {
8
9
  #private;
10
+ hasSchedule: boolean;
11
+ /**
12
+ * Run code on a schedule with the capability.
13
+ *
14
+ * @param schedule The schedule to run the code on
15
+ * @returns
16
+ */
17
+ OnSchedule: (schedule: Schedule) => void;
9
18
  /**
10
19
  * Store is a key-value data store that can be used to persist data that should be shared
11
20
  * between requests. Each capability has its own store, and the data is persisted in Kubernetes
@@ -14,11 +23,27 @@ export declare class Capability implements CapabilityExport {
14
23
  * Note: You should only access the store from within an action.
15
24
  */
16
25
  Store: PeprStore;
26
+ /**
27
+ * ScheduleStore is a key-value data store used to persist schedule data that should be shared
28
+ * between intervals. Each Schedule shares store, and the data is persisted in Kubernetes
29
+ * in the `pepr-system` namespace.
30
+ *
31
+ * Note: There is no direct access to schedule store
32
+ */
33
+ ScheduleStore: PeprStore;
17
34
  get bindings(): Binding[];
18
35
  get name(): string;
19
36
  get description(): string;
20
37
  get namespaces(): string[];
21
38
  constructor(cfg: CapabilityCfg);
39
+ /**
40
+ * Register the store with the capability. This is called automatically by the Pepr controller.
41
+ *
42
+ * @param store
43
+ */
44
+ registerScheduleStore: () => {
45
+ scheduleStore: Storage;
46
+ };
22
47
  /**
23
48
  * Register the store with the capability. This is called automatically by the Pepr controller.
24
49
  *
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/lib/capability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAA2B,MAAM,0BAA0B,CAAC;AAMnG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,OAAO,EAGP,aAAa,EACb,gBAAgB,EAMhB,YAAY,EACb,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,qBAAa,UAAW,YAAW,gBAAgB;;IAQjD;;;;;;OAMG;IACH,KAAK,EAAE,SAAS,CAOd;IAEF,IAAI,QAAQ,cAEX;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;gBAEW,GAAG,EAAE,aAAa;IAS9B;;;;OAIG;IACH,aAAa;;MAaX;IAEF;;;;;;;;OAQG;IACH,IAAI,4CAA6C,gBAAgB,qBAqH/D;CACH"}
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/lib/capability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAA2B,MAAM,0BAA0B,CAAC;AAMnG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAc,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EACL,OAAO,EAGP,aAAa,EACb,gBAAgB,EAMhB,YAAY,EACb,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,qBAAa,UAAW,YAAW,gBAAgB;;IASjD,WAAW,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,UAAU,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAqBtC;IAEF;;;;;;OAMG;IACH,KAAK,EAAE,SAAS,CAQd;IAEF;;;;;;OAMG;IACH,aAAa,EAAE,SAAS,CAQtB;IAEF,IAAI,QAAQ,cAEX;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;gBAEW,GAAG,EAAE,aAAa;IAU9B;;;;OAIG;IACH,qBAAqB;;MAanB;IAEF;;;;OAIG;IACH,aAAa;;MAaX;IAEF;;;;;;;;OAQG;IACH,IAAI,4CAA6C,gBAAgB,qBAqH/D;CACH"}
@@ -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;AAKtD,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;IA6BtB,+BAA+B;IAC/B,WAAW,SAAU,MAAM,UAqDzB;CAoKH"}
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;AAKtD,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;CAoKH"}
@@ -1,7 +1,8 @@
1
1
  import { Capability } from "../capability";
2
2
  import { ModuleConfig } from "../module";
3
+ export declare const debounceBackoff = 5000;
3
4
  export declare class PeprControllerStore {
4
5
  #private;
5
- constructor(config: ModuleConfig, capabilities: Capability[], onReady?: () => void);
6
+ constructor(config: ModuleConfig, capabilities: Capability[], name: string, onReady?: () => void);
6
7
  }
7
8
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMzC,qBAAa,mBAAmB;;gBAMlB,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;CA8KnF"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,qBAAa,mBAAmB;;gBAMlB,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;CAgMjG"}
@@ -7,5 +7,6 @@ type RBACMap = {
7
7
  };
8
8
  export declare const addVerbIfNotExists: (verbs: string[], verb: string) => void;
9
9
  export declare const createRBACMap: (capabilities: CapabilityExport[]) => RBACMap;
10
+ export declare function createDirectoryIfNotExists(path: string): Promise<void>;
10
11
  export {};
11
12
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,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"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI1F,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG;IACzB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW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D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,qHAAqH;IACrH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,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;IAiD7G;;;;;OAKG;IACH,KAAK,0BAEH;CACH"}
@@ -0,0 +1,76 @@
1
+ /// <reference types="node" />
2
+ import { PeprStore } from "./storage";
3
+ type Unit = "seconds" | "second" | "minute" | "minutes" | "hours" | "hour";
4
+ export interface Schedule {
5
+ /**
6
+ * * The name of the store
7
+ */
8
+ name: string;
9
+ /**
10
+ * The value associated with a unit of time
11
+ */
12
+ every: number;
13
+ /**
14
+ * The unit of time
15
+ */
16
+ unit: Unit;
17
+ /**
18
+ * The code to run
19
+ */
20
+ run: () => void;
21
+ /**
22
+ * The start time of the schedule
23
+ */
24
+ startTime?: Date | undefined;
25
+ /**
26
+ * The number of times the schedule has run
27
+ */
28
+ completions?: number | undefined;
29
+ /**
30
+ * Tje intervalID to clear the interval
31
+ */
32
+ intervalID?: NodeJS.Timeout;
33
+ }
34
+ export declare class OnSchedule implements Schedule {
35
+ intervalId: NodeJS.Timeout | null;
36
+ store: PeprStore | undefined;
37
+ name: string;
38
+ completions?: number | undefined;
39
+ every: number;
40
+ unit: Unit;
41
+ run: () => void;
42
+ startTime?: Date | undefined;
43
+ duration: number | undefined;
44
+ lastTimestamp: Date | undefined;
45
+ constructor(schedule: Schedule);
46
+ setStore(store: PeprStore): void;
47
+ startInterval(): void;
48
+ /**
49
+ * Checks the store for this schedule and sets the values if it exists
50
+ * @returns
51
+ */
52
+ checkStore(): void;
53
+ /**
54
+ * Saves the schedule to the store
55
+ * @returns
56
+ */
57
+ saveToStore(): void;
58
+ /**
59
+ * Gets the durations in milliseconds
60
+ */
61
+ getDuration(): void;
62
+ /**
63
+ * Sets up the interval
64
+ */
65
+ setupInterval(): void;
66
+ /**
67
+ * Starts the interval
68
+ */
69
+ start(): void;
70
+ /**
71
+ * Stops the interval
72
+ */
73
+ stop(): void;
74
+ }
75
+ export {};
76
+ //# sourceMappingURL=schedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../src/lib/schedule.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,KAAK,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3E,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC7B;AAED,qBAAa,UAAW,YAAW,QAAQ;IACzC,UAAU,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAQ;IACzC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAG,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAG,MAAM,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,aAAa,EAAE,IAAI,GAAG,SAAS,CAAC;gBAEpB,QAAQ,EAAE,QAAQ;IAQ9B,QAAQ,CAAC,KAAK,EAAE,SAAS;IAIzB,aAAa;IAKb;;;OAGG;IACH,UAAU;IAUV;;;OAGG;IACH,WAAW;IAUX;;OAEG;IACH,WAAW;IAmBX;;OAEG;IACH,aAAa;IAwBb;;OAEG;IACH,KAAK;IAgBL;;OAEG;IACH,IAAI;CAOL"}
@@ -31,6 +31,11 @@ export interface PeprStore {
31
31
  * Register a function to be called when the store is ready.
32
32
  */
33
33
  onReady(callback: DataReceiver): void;
34
+ /**
35
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
36
+ * Resolves when the key/value show up in the store.
37
+ */
38
+ setItemAndWait(key: string, value: string): Promise<void>;
34
39
  }
35
40
  /**
36
41
  * A key-value data store that can be used to persist data that should be shared across Pepr controllers and capabilities.
@@ -45,6 +50,15 @@ export declare class Storage implements PeprStore {
45
50
  clear: () => void;
46
51
  removeItem: (key: string) => void;
47
52
  setItem: (key: string, value: string) => void;
53
+ /**
54
+ * Creates a promise and subscribes to the store, the promise resolves when
55
+ * the key and value are seen in the store.
56
+ *
57
+ * @param key - The key to add into the store
58
+ * @param value - The value of the key
59
+ * @returns
60
+ */
61
+ setItemAndWait: (key: string, value: string) => Promise<void>;
48
62
  subscribe: (subscriber: DataReceiver) => () => void;
49
63
  onReady: (callback: DataReceiver) => void;
50
64
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/lib/storage.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AACtC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1C;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,WAAW,CAAC;IAE/C;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;CACvC;AAED;;;;GAIG;AACH,qBAAa,OAAQ,YAAW,SAAS;;IAOvC,cAAc,SAAU,UAAU,UAEhC;IAEF,OAAO,SAAU,SAAS,UAWxB;IAEF,OAAO,QAAS,MAAM,mBAGpB;IAEF,KAAK,aAEH;IAEF,UAAU,QAAS,MAAM,UAEvB;IAEF,OAAO,QAAS,MAAM,SAAS,MAAM,UAEnC;IAEF,SAAS,eAAgB,YAAY,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AS,MAAM,mBAGpB;IAEF,KAAK,aAEH;IAEF,UAAU,QAAS,MAAM,UAEvB;IAEF,OAAO,QAAS,MAAM,SAAS,MAAM,UAEnC;IAEF;;;;;;;OAOG;IACH,cAAc,QAAS,MAAM,SAAS,MAAM,mBAgB1C;IAEF,SAAS,eAAgB,YAAY,gBAInC;IAEF,OAAO,aAAc,YAAY,UAE/B;IAEF;;;OAGG;IACH,WAAW,QAAS,MAAM,UAExB;CAqBH"}
@@ -35,6 +35,7 @@ export interface CapabilityCfg {
35
35
  }
36
36
  export interface CapabilityExport extends CapabilityCfg {
37
37
  bindings: Binding[];
38
+ hasSchedule: boolean;
38
39
  }
39
40
  export type WhenSelector<T extends GenericClass> = {
40
41
  /** Register an action to be executed when a Kubernetes resource is created or updated. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF;;GAEG;AACH,oBAAY,KAAK;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,GAAG,MAAM;CACV;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAC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