pepr 0.1.33 → 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
|
@@ -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,
|
|
@@ -30,12 +30,12 @@ function processor(config, capabilities, req) {
|
|
|
30
30
|
// Add annotations to the request to indicate that the capability started processing
|
|
31
31
|
// this will allow tracking of failed mutations that were permitted to continue
|
|
32
32
|
const { metadata } = wrapped.Raw;
|
|
33
|
-
const identifier =
|
|
33
|
+
const identifier = `${config.uuid}.pepr.dev/${name}`;
|
|
34
34
|
metadata.annotations = metadata.annotations || {};
|
|
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
|
}
|
package/dist/src/lib/types.d.ts
CHANGED
|
@@ -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>;
|