pepr 0.1.34 → 0.1.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pepr",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Kubernetes application engine",
5
5
  "author": "Defense Unicorns",
6
6
  "homepage": "https://github.com/defenseunicorns/pepr",
@@ -68,7 +68,7 @@ class Capability {
68
68
  };
69
69
  const ThenSet = (merge) => {
70
70
  // Add the new action to the binding
71
- Then(req => req.Merge(merge));
71
+ Then(async (req) => req.Merge(merge));
72
72
  return { Then };
73
73
  };
74
74
  function InNamespace(...namespaces) {
@@ -46,14 +46,14 @@ class Controller {
46
46
  res.status(500).send("Internal Server Error");
47
47
  }
48
48
  };
49
- this.mutate = (req, res) => {
49
+ this.mutate = async (req, res) => {
50
50
  try {
51
51
  const name = req.body?.request?.name || "";
52
52
  const namespace = req.body?.request?.namespace || "";
53
53
  const gvk = req.body?.request?.kind || { group: "", version: "", kind: "" };
54
54
  console.log(`Mutate request: ${gvk.group}/${gvk.version}/${gvk.kind}`);
55
55
  name && console.log(` ${namespace}/${name}\n`);
56
- const response = (0, processor_1.processor)(this.config, this.capabilities, req.body.request);
56
+ const response = await (0, processor_1.processor)(this.config, this.capabilities, req.body.request);
57
57
  console.debug(response);
58
58
  // Send a no prob bob response
59
59
  res.send({
@@ -1,4 +1,4 @@
1
1
  import { Capability } from "./capability";
2
2
  import { Request, Response } from "./k8s/types";
3
3
  import { ModuleConfig } from "./types";
4
- export declare function processor(config: ModuleConfig, capabilities: Capability[], req: Request): Response;
4
+ export declare function processor(config: ModuleConfig, capabilities: Capability[], req: Request): Promise<Response>;
@@ -10,7 +10,7 @@ const fast_json_patch_1 = require("fast-json-patch");
10
10
  const filter_1 = require("./filter");
11
11
  const logger_1 = __importDefault(require("./logger"));
12
12
  const request_1 = require("./request");
13
- function processor(config, capabilities, req) {
13
+ async function processor(config, capabilities, req) {
14
14
  const wrapped = new request_1.RequestWrapper(req);
15
15
  const response = {
16
16
  uid: req.uid,
@@ -35,7 +35,7 @@ function processor(config, capabilities, req) {
35
35
  metadata.annotations[identifier] = "started";
36
36
  try {
37
37
  // Run the action
38
- action.callback(wrapped);
38
+ await action.callback(wrapped);
39
39
  // Add annotations to the request to indicate that the capability succeeded
40
40
  metadata.annotations[identifier] = "succeeded";
41
41
  }
@@ -184,4 +184,4 @@ export type BindToActionOrSet<T extends GenericClass> = BindToAction<T> & {
184
184
  */
185
185
  ThenSet: (val: DeepPartial<InstanceType<T>>) => BindToAction<T>;
186
186
  };
187
- export type CapabilityAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (req: RequestWrapper<K>) => void;
187
+ export type CapabilityAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (req: RequestWrapper<K>) => Promise<void> | void | Promise<RequestWrapper<K>> | RequestWrapper<K>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pepr",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Kubernetes application engine",
5
5
  "author": "Defense Unicorns",
6
6
  "homepage": "https://github.com/defenseunicorns/pepr",