pepr 0.12.2 → 0.13.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/CODE_OF_CONDUCT.md +83 -0
- package/CONTRIBUTING.md +70 -0
- package/README.md +28 -30
- package/dist/cli.js +644 -679
- package/dist/controller.js +13 -81
- package/dist/lib/assets/deploy.d.ts +3 -0
- package/dist/lib/assets/deploy.d.ts.map +1 -0
- package/dist/lib/assets/index.d.ts +18 -0
- package/dist/lib/assets/index.d.ts.map +1 -0
- package/dist/lib/assets/loader.d.ts +14 -0
- package/dist/lib/assets/loader.d.ts.map +1 -0
- package/dist/lib/assets/networking.d.ts +6 -0
- package/dist/lib/assets/networking.d.ts.map +1 -0
- package/dist/lib/assets/pods.d.ts +8 -0
- package/dist/lib/assets/pods.d.ts.map +1 -0
- package/dist/lib/assets/rbac.d.ts +11 -0
- package/dist/lib/assets/rbac.d.ts.map +1 -0
- package/dist/lib/assets/webhooks.d.ts +6 -0
- package/dist/lib/assets/webhooks.d.ts.map +1 -0
- package/dist/lib/assets/yaml.d.ts +4 -0
- package/dist/lib/assets/yaml.d.ts.map +1 -0
- package/dist/lib/capability.d.ts +1 -3
- package/dist/lib/capability.d.ts.map +1 -1
- package/dist/lib/controller.d.ts +45 -10
- package/dist/lib/controller.d.ts.map +1 -1
- package/dist/lib/filter.d.ts +1 -1
- package/dist/lib/filter.d.ts.map +1 -1
- package/dist/lib/k8s/index.d.ts +2 -1
- package/dist/lib/k8s/index.d.ts.map +1 -1
- package/dist/lib/k8s/kinds.d.ts.map +1 -1
- package/dist/lib/k8s/types.d.ts +13 -13
- package/dist/lib/k8s/types.d.ts.map +1 -1
- package/dist/lib/k8s/upstream.d.ts +2 -2
- package/dist/lib/k8s/upstream.d.ts.map +1 -1
- package/dist/lib/logger.d.ts +8 -54
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/metrics.d.ts +11 -4
- package/dist/lib/metrics.d.ts.map +1 -1
- package/dist/lib/module.d.ts +2 -2
- package/dist/lib/module.d.ts.map +1 -1
- package/dist/lib/mutate-processor.d.ts +5 -0
- package/dist/lib/mutate-processor.d.ts.map +1 -0
- package/dist/lib/{request.d.ts → mutate-request.d.ts} +5 -5
- package/dist/lib/mutate-request.d.ts.map +1 -0
- package/dist/lib/types.d.ts +45 -46
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/validate-processor.d.ts +4 -0
- package/dist/lib/validate-processor.d.ts.map +1 -0
- package/dist/lib/validate-request.d.ts +54 -0
- package/dist/lib/validate-request.d.ts.map +1 -0
- package/dist/lib.d.ts +3 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +502 -302
- package/dist/lib.js.map +4 -4
- package/package.json +15 -12
- package/src/cli.ts +2 -11
- package/src/lib/assets/deploy.ts +179 -0
- package/src/lib/assets/index.ts +46 -0
- package/src/lib/assets/loader.ts +49 -0
- package/src/lib/assets/networking.ts +58 -0
- package/src/lib/assets/pods.ts +148 -0
- package/src/lib/assets/rbac.ts +57 -0
- package/src/lib/assets/webhooks.ts +139 -0
- package/src/lib/assets/yaml.ts +75 -0
- package/src/lib/capability.ts +54 -44
- package/src/lib/controller.ts +171 -89
- package/src/lib/fetch.ts +1 -1
- package/src/lib/filter.ts +1 -3
- package/src/lib/k8s/index.ts +4 -1
- package/src/lib/k8s/kinds.ts +40 -0
- package/src/lib/k8s/types.ts +16 -14
- package/src/lib/k8s/upstream.ts +5 -1
- package/src/lib/logger.ts +14 -125
- package/src/lib/metrics.ts +67 -23
- package/src/lib/module.ts +13 -11
- package/src/lib/{processor.ts → mutate-processor.ts} +37 -28
- package/src/lib/{request.ts → mutate-request.ts} +4 -4
- package/src/lib/types.ts +51 -51
- package/src/lib/validate-processor.ts +68 -0
- package/src/lib/validate-request.ts +94 -0
- package/src/lib.ts +4 -2
- package/src/runtime/controller.ts +1 -1
- package/dist/lib/k8s/webhook.d.ts +0 -37
- package/dist/lib/k8s/webhook.d.ts.map +0 -1
- package/dist/lib/processor.d.ts +0 -5
- package/dist/lib/processor.d.ts.map +0 -1
- package/dist/lib/request.d.ts.map +0 -1
- package/src/lib/k8s/webhook.ts +0 -643
package/src/lib/types.ts
CHANGED
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
4
|
import { GroupVersionKind, KubernetesObject, WebhookIgnore } from "./k8s/types";
|
|
5
|
-
import {
|
|
5
|
+
import { PeprMutateRequest } from "./mutate-request";
|
|
6
|
+
import { PeprValidateRequest } from "./validate-request";
|
|
6
7
|
|
|
7
8
|
export type PackageJSON = {
|
|
8
9
|
description: string;
|
|
9
10
|
pepr: ModuleConfig;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
/**
|
|
13
|
-
* The behavior of this module when an error occurs.
|
|
14
|
-
*/
|
|
15
|
-
export enum ErrorBehavior {
|
|
16
|
-
ignore = "ignore",
|
|
17
|
-
audit = "audit",
|
|
18
|
-
reject = "reject",
|
|
19
|
-
}
|
|
20
|
-
|
|
21
13
|
/**
|
|
22
14
|
* The phase of the Kubernetes admission webhook that the capability is registered for.
|
|
23
15
|
*
|
|
@@ -36,9 +28,8 @@ export type DeepPartial<T> = {
|
|
|
36
28
|
};
|
|
37
29
|
|
|
38
30
|
/**
|
|
39
|
-
* The type of Kubernetes mutating webhook event that the
|
|
31
|
+
* The type of Kubernetes mutating webhook event that the action is registered for.
|
|
40
32
|
*/
|
|
41
|
-
|
|
42
33
|
export enum Event {
|
|
43
34
|
Create = "CREATE",
|
|
44
35
|
Update = "UPDATE",
|
|
@@ -61,14 +52,6 @@ export interface CapabilityCfg {
|
|
|
61
52
|
* This does not supersede the `alwaysIgnore` global configuration.
|
|
62
53
|
*/
|
|
63
54
|
namespaces?: string[];
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* FUTURE USE.
|
|
67
|
-
*
|
|
68
|
-
* Declare if this capability should be used for mutation or validation. Currently this is not used
|
|
69
|
-
* and everything is considered a mutation.
|
|
70
|
-
*/
|
|
71
|
-
mutateOrValidate?: HookPhase;
|
|
72
55
|
}
|
|
73
56
|
|
|
74
57
|
export type ModuleSigning = {
|
|
@@ -99,7 +82,7 @@ export type ModuleConfig = {
|
|
|
99
82
|
/** A description of the Pepr module and what it does. */
|
|
100
83
|
description?: string;
|
|
101
84
|
/** Reject K8s resource AdmissionRequests on error. */
|
|
102
|
-
onError
|
|
85
|
+
onError?: string;
|
|
103
86
|
/** Configure global exclusions that will never be processed by Pepr. */
|
|
104
87
|
alwaysIgnore: WebhookIgnore;
|
|
105
88
|
/**
|
|
@@ -115,18 +98,20 @@ export type ModuleConfig = {
|
|
|
115
98
|
export type GenericClass = abstract new () => any;
|
|
116
99
|
|
|
117
100
|
export type WhenSelector<T extends GenericClass> = {
|
|
118
|
-
/** Register
|
|
101
|
+
/** Register an action to be executed when a Kubernetes resource is created or updated. */
|
|
119
102
|
IsCreatedOrUpdated: () => BindingAll<T>;
|
|
120
|
-
/** Register
|
|
103
|
+
/** Register an action to be executed when a Kubernetes resource is created. */
|
|
121
104
|
IsCreated: () => BindingAll<T>;
|
|
122
|
-
/** Register
|
|
105
|
+
/** Register ann action to be executed when a Kubernetes resource is updated. */
|
|
123
106
|
IsUpdated: () => BindingAll<T>;
|
|
124
|
-
/** Register
|
|
107
|
+
/** Register an action to be executed when a Kubernetes resource is deleted. */
|
|
125
108
|
IsDeleted: () => BindingAll<T>;
|
|
126
109
|
};
|
|
127
110
|
|
|
128
111
|
export type Binding = {
|
|
129
112
|
event: Event;
|
|
113
|
+
isMutate?: boolean;
|
|
114
|
+
isValidate?: boolean;
|
|
130
115
|
readonly kind: GroupVersionKind;
|
|
131
116
|
readonly filters: {
|
|
132
117
|
name: string;
|
|
@@ -134,12 +119,13 @@ export type Binding = {
|
|
|
134
119
|
labels: Record<string, string>;
|
|
135
120
|
annotations: Record<string, string>;
|
|
136
121
|
};
|
|
137
|
-
readonly
|
|
122
|
+
readonly mutateCallback?: MutateAction<GenericClass, InstanceType<GenericClass>>;
|
|
123
|
+
readonly validateCallback?: ValidateAction<GenericClass, InstanceType<GenericClass>>;
|
|
138
124
|
};
|
|
139
125
|
|
|
140
|
-
export type BindingFilter<T extends GenericClass> =
|
|
126
|
+
export type BindingFilter<T extends GenericClass> = CommonActionChain<T> & {
|
|
141
127
|
/**
|
|
142
|
-
* Only apply the
|
|
128
|
+
* Only apply the action if the resource has the specified label. If no value is specified, the label must exist.
|
|
143
129
|
* Note multiple calls to this method will result in an AND condition. e.g.
|
|
144
130
|
*
|
|
145
131
|
* ```ts
|
|
@@ -147,17 +133,17 @@ export type BindingFilter<T extends GenericClass> = BindToActionOrSet<T> & {
|
|
|
147
133
|
* .IsCreated()
|
|
148
134
|
* .WithLabel("foo", "bar")
|
|
149
135
|
* .WithLabel("baz", "qux")
|
|
150
|
-
* .
|
|
136
|
+
* .Mutate(...)
|
|
151
137
|
* ```
|
|
152
138
|
*
|
|
153
|
-
* Will only apply the
|
|
139
|
+
* Will only apply the action if the resource has both the `foo=bar` and `baz=qux` labels.
|
|
154
140
|
*
|
|
155
141
|
* @param key
|
|
156
142
|
* @param value
|
|
157
143
|
*/
|
|
158
144
|
WithLabel: (key: string, value?: string) => BindingFilter<T>;
|
|
159
145
|
/**
|
|
160
|
-
* Only apply the
|
|
146
|
+
* Only apply the action if the resource has the specified annotation. If no value is specified, the annotation must exist.
|
|
161
147
|
* Note multiple calls to this method will result in an AND condition. e.g.
|
|
162
148
|
*
|
|
163
149
|
* ```ts
|
|
@@ -165,10 +151,10 @@ export type BindingFilter<T extends GenericClass> = BindToActionOrSet<T> & {
|
|
|
165
151
|
* .IsCreated()
|
|
166
152
|
* .WithAnnotation("foo", "bar")
|
|
167
153
|
* .WithAnnotation("baz", "qux")
|
|
168
|
-
* .
|
|
154
|
+
* .Mutate(...)
|
|
169
155
|
* ```
|
|
170
156
|
*
|
|
171
|
-
* Will only apply the
|
|
157
|
+
* Will only apply the action if the resource has both the `foo=bar` and `baz=qux` annotations.
|
|
172
158
|
*
|
|
173
159
|
* @param key
|
|
174
160
|
* @param value
|
|
@@ -177,43 +163,57 @@ export type BindingFilter<T extends GenericClass> = BindToActionOrSet<T> & {
|
|
|
177
163
|
};
|
|
178
164
|
|
|
179
165
|
export type BindingWithName<T extends GenericClass> = BindingFilter<T> & {
|
|
180
|
-
/** Only apply the
|
|
166
|
+
/** Only apply the action if the resource name matches the specified name. */
|
|
181
167
|
WithName: (name: string) => BindingFilter<T>;
|
|
182
168
|
};
|
|
183
169
|
|
|
184
170
|
export type BindingAll<T extends GenericClass> = BindingWithName<T> & {
|
|
185
|
-
/** Only apply the
|
|
171
|
+
/** Only apply the action if the resource is in one of the specified namespaces.*/
|
|
186
172
|
InNamespace: (...namespaces: string[]) => BindingWithName<T>;
|
|
187
173
|
};
|
|
188
174
|
|
|
189
|
-
export type
|
|
175
|
+
export type CommonActionChain<T extends GenericClass> = MutateActionChain<T> & {
|
|
190
176
|
/**
|
|
191
|
-
* Create a new
|
|
177
|
+
* Create a new MUTATE action with the specified callback function and previously specified
|
|
192
178
|
* filters.
|
|
193
|
-
* @param action The
|
|
179
|
+
* @param action The action to be executed when the Kubernetes resource is processed by the AdmissionController.
|
|
194
180
|
*/
|
|
195
|
-
|
|
181
|
+
Mutate: (action: MutateAction<T, InstanceType<T>>) => MutateActionChain<T>;
|
|
196
182
|
};
|
|
197
183
|
|
|
198
|
-
export type
|
|
184
|
+
export type MutateActionChain<T extends GenericClass> = {
|
|
199
185
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* Example change the `minReadySeconds` to 3 of a deployment when it is created:
|
|
186
|
+
* Create a new VALIDATE action with the specified callback function and previously specified
|
|
187
|
+
* filters. Return the `request.Approve()` or `Request.Deny()` methods to approve or deny the request:
|
|
204
188
|
*
|
|
189
|
+
* @example
|
|
205
190
|
* ```ts
|
|
206
191
|
* When(a.Deployment)
|
|
207
192
|
* .IsCreated()
|
|
208
|
-
* .
|
|
193
|
+
* .Validate(request => {
|
|
194
|
+
* if (request.HasLabel("foo")) {
|
|
195
|
+
* return request.Approve();
|
|
196
|
+
* }
|
|
197
|
+
*
|
|
198
|
+
* return request.Deny("Deployment must have label foo");
|
|
199
|
+
* });
|
|
209
200
|
* ```
|
|
210
201
|
*
|
|
211
|
-
* @param
|
|
212
|
-
* @returns
|
|
202
|
+
* @param action The action to be executed when the Kubernetes resource is processed by the AdmissionController.
|
|
213
203
|
*/
|
|
214
|
-
|
|
204
|
+
Validate: (action: ValidateAction<T, InstanceType<T>>) => void;
|
|
215
205
|
};
|
|
216
206
|
|
|
217
|
-
export type
|
|
218
|
-
req:
|
|
219
|
-
) => Promise<void> | void | Promise<
|
|
207
|
+
export type MutateAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (
|
|
208
|
+
req: PeprMutateRequest<K>,
|
|
209
|
+
) => Promise<void> | void | Promise<PeprMutateRequest<K>> | PeprMutateRequest<K>;
|
|
210
|
+
|
|
211
|
+
export type ValidateAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (
|
|
212
|
+
req: PeprValidateRequest<K>,
|
|
213
|
+
) => Promise<ValidateResponse> | ValidateResponse;
|
|
214
|
+
|
|
215
|
+
export type ValidateResponse = {
|
|
216
|
+
allowed: boolean;
|
|
217
|
+
statusCode?: number;
|
|
218
|
+
statusMessage?: string;
|
|
219
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import { Capability } from "./capability";
|
|
5
|
+
import { shouldSkipRequest } from "./filter";
|
|
6
|
+
import { Request, ValidateResponse } from "./k8s/types";
|
|
7
|
+
import Log from "./logger";
|
|
8
|
+
import { PeprValidateRequest } from "./validate-request";
|
|
9
|
+
|
|
10
|
+
export async function validateProcessor(
|
|
11
|
+
capabilities: Capability[],
|
|
12
|
+
req: Request,
|
|
13
|
+
reqMetadata: Record<string, string>,
|
|
14
|
+
): Promise<ValidateResponse> {
|
|
15
|
+
const wrapped = new PeprValidateRequest(req);
|
|
16
|
+
const response: ValidateResponse = {
|
|
17
|
+
uid: req.uid,
|
|
18
|
+
allowed: true, // Assume it's allowed until a validation check fails
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Log.info(reqMetadata, `Processing validation request`);
|
|
22
|
+
|
|
23
|
+
for (const { name, bindings } of capabilities) {
|
|
24
|
+
const actionMetadata = { ...reqMetadata, name };
|
|
25
|
+
|
|
26
|
+
for (const action of bindings) {
|
|
27
|
+
// Skip this action if it's not a validation action
|
|
28
|
+
if (!action.validateCallback) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Continue to the next action without doing anything if this one should be skipped
|
|
33
|
+
if (shouldSkipRequest(action, req)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const label = action.validateCallback.name;
|
|
38
|
+
Log.info(actionMetadata, `Processing matched action ${label}`);
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Run the validation callback, if it fails set allowed to false
|
|
42
|
+
const resp = await action.validateCallback(wrapped);
|
|
43
|
+
response.allowed = resp.allowed;
|
|
44
|
+
|
|
45
|
+
// If the validation callback returned a status code or message, set it in the Response
|
|
46
|
+
if (resp.statusCode || resp.statusMessage) {
|
|
47
|
+
response.status = {
|
|
48
|
+
code: resp.statusCode || 400,
|
|
49
|
+
message: resp.statusMessage || `Validation failed for ${name}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Log.info(actionMetadata, `Validation Action completed: ${resp.allowed ? "allowed" : "denied"}`);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
// If any validation throws an error, note the failure in the Response
|
|
56
|
+
Log.error(actionMetadata, `Action failed: ${e}`);
|
|
57
|
+
response.allowed = false;
|
|
58
|
+
response.status = {
|
|
59
|
+
code: 500,
|
|
60
|
+
message: `Action failed with error: ${e}`,
|
|
61
|
+
};
|
|
62
|
+
return response;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import { clone } from "ramda";
|
|
5
|
+
import { KubernetesObject, Operation, Request } from "./k8s/types";
|
|
6
|
+
import { ValidateResponse } from "./types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The RequestWrapper class provides methods to modify Kubernetes objects in the context
|
|
10
|
+
* of a mutating webhook request.
|
|
11
|
+
*/
|
|
12
|
+
export class PeprValidateRequest<T extends KubernetesObject> {
|
|
13
|
+
public Raw: T;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Provides access to the old resource in the request if available.
|
|
17
|
+
* @returns The old Kubernetes resource object or null if not available.
|
|
18
|
+
*/
|
|
19
|
+
get OldResource() {
|
|
20
|
+
return this._input.oldObject;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Provides access to the request object.
|
|
25
|
+
* @returns The request object containing the Kubernetes resource.
|
|
26
|
+
*/
|
|
27
|
+
get Request() {
|
|
28
|
+
return this._input;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new instance of the Action class.
|
|
33
|
+
* @param input - The request object containing the Kubernetes resource to modify.
|
|
34
|
+
*/
|
|
35
|
+
constructor(protected _input: Request<T>) {
|
|
36
|
+
// If this is a DELETE operation, use the oldObject instead
|
|
37
|
+
if (_input.operation.toUpperCase() === Operation.DELETE) {
|
|
38
|
+
this.Raw = clone(_input.oldObject as T);
|
|
39
|
+
} else {
|
|
40
|
+
// Otherwise, use the incoming object
|
|
41
|
+
this.Raw = clone(_input.object);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!this.Raw) {
|
|
45
|
+
throw new Error("unable to load the request object into PeprRequest.RawP");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Check if a label exists on the Kubernetes resource.
|
|
51
|
+
*
|
|
52
|
+
* @param key the label key to check
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
HasLabel(key: string) {
|
|
56
|
+
return this.Raw.metadata?.labels?.[key] !== undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Check if an annotation exists on the Kubernetes resource.
|
|
61
|
+
*
|
|
62
|
+
* @param key the annotation key to check
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
HasAnnotation(key: string) {
|
|
66
|
+
return this.Raw.metadata?.annotations?.[key] !== undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create a validation response that allows the request.
|
|
71
|
+
*
|
|
72
|
+
* @returns The validation response.
|
|
73
|
+
*/
|
|
74
|
+
Approve(): ValidateResponse {
|
|
75
|
+
return {
|
|
76
|
+
allowed: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create a validation response that denies the request.
|
|
82
|
+
*
|
|
83
|
+
* @param statusMessage Optional status message to return to the user.
|
|
84
|
+
* @param statusCode Optional status code to return to the user.
|
|
85
|
+
* @returns The validation response.
|
|
86
|
+
*/
|
|
87
|
+
Deny(statusMessage?: string, statusCode?: number): ValidateResponse {
|
|
88
|
+
return {
|
|
89
|
+
allowed: false,
|
|
90
|
+
statusCode,
|
|
91
|
+
statusMessage,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
package/src/lib.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { fetch, fetchRaw } from "./lib/fetch";
|
|
|
6
6
|
import { RegisterKind, a } from "./lib/k8s/index";
|
|
7
7
|
import Log from "./lib/logger";
|
|
8
8
|
import { PeprModule } from "./lib/module";
|
|
9
|
-
import {
|
|
9
|
+
import { PeprMutateRequest } from "./lib/mutate-request";
|
|
10
|
+
import { PeprValidateRequest } from "./lib/validate-request";
|
|
10
11
|
import * as PeprUtils from "./lib/utils";
|
|
11
12
|
|
|
12
13
|
// Import type information for external packages
|
|
@@ -17,7 +18,8 @@ export {
|
|
|
17
18
|
a,
|
|
18
19
|
/** PeprModule is used to setup a complete Pepr Module: `new PeprModule(cfg, {...capabilities})` */
|
|
19
20
|
PeprModule,
|
|
20
|
-
|
|
21
|
+
PeprMutateRequest,
|
|
22
|
+
PeprValidateRequest,
|
|
21
23
|
PeprUtils,
|
|
22
24
|
RegisterKind,
|
|
23
25
|
Capability,
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { V1ClusterRole, V1ClusterRoleBinding, V1Deployment, V1MutatingWebhookConfiguration, V1Namespace, V1RuleWithOperations, V1Secret, V1Service, V1ServiceAccount } from "@kubernetes/client-node";
|
|
3
|
-
import { ModuleConfig } from "../types";
|
|
4
|
-
import { TLSOut } from "./tls";
|
|
5
|
-
export declare class Webhook {
|
|
6
|
-
private readonly config;
|
|
7
|
-
private readonly host?;
|
|
8
|
-
private name;
|
|
9
|
-
private _tls;
|
|
10
|
-
private _apiToken;
|
|
11
|
-
image: string;
|
|
12
|
-
get tls(): TLSOut;
|
|
13
|
-
get apiToken(): string;
|
|
14
|
-
constructor(config: ModuleConfig, host?: string | undefined);
|
|
15
|
-
/** Generate the pepr-system namespace */
|
|
16
|
-
namespace(): V1Namespace;
|
|
17
|
-
/**
|
|
18
|
-
* Grants the controller access to cluster resources beyond the mutating webhook.
|
|
19
|
-
*
|
|
20
|
-
* @todo: should dynamically generate this based on resources used by the module. will also need to explore how this should work for multiple modules.
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
clusterRole(): V1ClusterRole;
|
|
24
|
-
clusterRoleBinding(): V1ClusterRoleBinding;
|
|
25
|
-
serviceAccount(): V1ServiceAccount;
|
|
26
|
-
apiTokenSecret(): V1Secret;
|
|
27
|
-
tlsSecret(): V1Secret;
|
|
28
|
-
generateWebhookRules(path: string): Promise<V1RuleWithOperations[]>;
|
|
29
|
-
mutatingWebhook(path: string, timeoutSeconds?: number): Promise<V1MutatingWebhookConfiguration>;
|
|
30
|
-
deployment(hash: string): V1Deployment;
|
|
31
|
-
service(): V1Service;
|
|
32
|
-
moduleSecret(data: Buffer, hash: string): V1Secret;
|
|
33
|
-
zarfYaml(path: string): string;
|
|
34
|
-
allYaml(path: string): Promise<string>;
|
|
35
|
-
deploy(path: string, webhookTimeout?: number): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=webhook.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../src/lib/k8s/webhook.ts"],"names":[],"mappings":";AAGA,OAAO,EAQL,aAAa,EACb,oBAAoB,EACpB,YAAY,EAEZ,8BAA8B,EAC9B,WAAW,EACX,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACT,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAA6B,YAAY,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,MAAM,EAAU,MAAM,OAAO,CAAC;AAQvC,qBAAa,OAAO;IAeN,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAgB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IAdzE,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,SAAS,CAAS;IAEnB,KAAK,EAAE,MAAM,CAAC;IAErB,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;gBAE4B,MAAM,EAAE,YAAY,EAAmB,IAAI,CAAC,oBAAQ;IAYjF,yCAAyC;IACzC,SAAS,IAAI,WAAW;IAQxB;;;;;OAKG;IACH,WAAW,IAAI,aAAa;IAgB5B,kBAAkB,IAAI,oBAAoB;IAqB1C,cAAc,IAAI,gBAAgB;IAWlC,cAAc,IAAI,QAAQ;IAe1B,SAAS,IAAI,QAAQ;IAgBrB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAwF7D,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,SAAK,GAAG,OAAO,CAAC,8BAA8B,CAAC;IA4DjG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAoGtC,OAAO,IAAI,SAAS;IAsBpB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ;IAkBlD,QAAQ,CAAC,IAAI,EAAE,MAAM;IA4Bf,OAAO,CAAC,IAAI,EAAE,MAAM;IAyBpB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CA6InD"}
|
package/dist/lib/processor.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Capability } from "./capability";
|
|
2
|
-
import { Request, Response } from "./k8s/types";
|
|
3
|
-
import { ModuleConfig } from "./types";
|
|
4
|
-
export declare function processor(config: ModuleConfig, capabilities: Capability[], req: Request, parentPrefix: string): Promise<Response>;
|
|
5
|
-
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../../src/lib/processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,QAAQ,CAAC,CAsHnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/lib/request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAa,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;GAGG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,gBAAgB;IAmCrC,OAAO,CAAC,MAAM;IAlCnB,GAAG,EAAE,CAAC,CAAC;IAEd,IAAI,iBAAiB,YAEpB;IAED;;;OAGG;IACH,IAAI,QAAQ,wBAEX;IAED;;;OAGG;IACH,IAAI,WAAW,kBAEd;IAED;;;OAGG;IACH,IAAI,OAAO,eAEV;IAED;;;OAGG;gBACiB,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IActC;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;IAIzB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAUnC;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAUxC;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM;IAQvB;;;;OAIG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAQ5B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM;IAIpB;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM;CAG1B"}
|