pepr 0.9.0 → 0.10.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 +85 -67
- package/dist/controller.js +1 -1
- package/dist/lib/controller.d.ts +2 -0
- package/dist/lib/controller.d.ts.map +1 -1
- package/dist/lib/k8s/webhook.d.ts.map +1 -1
- package/dist/lib/metrics.d.ts +38 -0
- package/dist/lib/metrics.d.ts.map +1 -0
- package/dist/lib/processor.d.ts.map +1 -1
- package/dist/lib/request.d.ts.map +1 -1
- package/dist/lib.js +92 -3
- package/dist/lib.js.map +4 -4
- package/package.json +4 -3
- package/src/lib/controller.ts +19 -0
- package/src/lib/k8s/webhook.ts +1 -0
- package/src/lib/metrics.ts +79 -0
- package/src/lib/processor.ts +5 -0
- package/src/lib/request.ts +16 -5
package/src/lib/request.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { clone, mergeDeepRight } from "ramda";
|
|
5
5
|
|
|
6
|
-
import { KubernetesObject, Request } from "./k8s/types";
|
|
6
|
+
import { KubernetesObject, Operation, Request } from "./k8s/types";
|
|
7
7
|
import { DeepPartial } from "./types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -46,8 +46,17 @@ export class PeprRequest<T extends KubernetesObject> {
|
|
|
46
46
|
* @param input - The request object containing the Kubernetes resource to modify.
|
|
47
47
|
*/
|
|
48
48
|
constructor(private _input: Request<T>) {
|
|
49
|
-
//
|
|
50
|
-
|
|
49
|
+
// If this is a DELETE operation, use the oldObject instead
|
|
50
|
+
if (_input.operation === Operation.DELETE) {
|
|
51
|
+
this.Raw = clone(_input.oldObject as T);
|
|
52
|
+
} else {
|
|
53
|
+
// Otherwise, use the incoming object
|
|
54
|
+
this.Raw = clone(_input.object);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!this.Raw) {
|
|
58
|
+
throw new Error("unable to load the request object into PeprRequest.RawP");
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
/**
|
|
@@ -100,6 +109,7 @@ export class PeprRequest<T extends KubernetesObject> {
|
|
|
100
109
|
if (this.Raw.metadata?.labels?.[key]) {
|
|
101
110
|
delete this.Raw.metadata.labels[key];
|
|
102
111
|
}
|
|
112
|
+
|
|
103
113
|
return this;
|
|
104
114
|
}
|
|
105
115
|
|
|
@@ -112,6 +122,7 @@ export class PeprRequest<T extends KubernetesObject> {
|
|
|
112
122
|
if (this.Raw.metadata?.annotations?.[key]) {
|
|
113
123
|
delete this.Raw.metadata.annotations[key];
|
|
114
124
|
}
|
|
125
|
+
|
|
115
126
|
return this;
|
|
116
127
|
}
|
|
117
128
|
|
|
@@ -122,7 +133,7 @@ export class PeprRequest<T extends KubernetesObject> {
|
|
|
122
133
|
* @returns
|
|
123
134
|
*/
|
|
124
135
|
HasLabel(key: string) {
|
|
125
|
-
return this.Raw
|
|
136
|
+
return this.Raw.metadata?.labels?.[key] !== undefined;
|
|
126
137
|
}
|
|
127
138
|
|
|
128
139
|
/**
|
|
@@ -132,6 +143,6 @@ export class PeprRequest<T extends KubernetesObject> {
|
|
|
132
143
|
* @returns
|
|
133
144
|
*/
|
|
134
145
|
HasAnnotation(key: string) {
|
|
135
|
-
return this.Raw
|
|
146
|
+
return this.Raw.metadata?.annotations?.[key] !== undefined;
|
|
136
147
|
}
|
|
137
148
|
}
|