pepr 0.31.1 → 0.32.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 +76 -13
- package/dist/controller.js +3 -3
- package/dist/lib/assets/helm.d.ts.map +1 -1
- package/dist/lib/assets/index.d.ts.map +1 -1
- package/dist/lib/assets/yaml.d.ts.map +1 -1
- package/dist/lib/controller/store.d.ts.map +1 -1
- package/dist/lib/mutate-processor.d.ts.map +1 -1
- package/dist/lib.js +23 -9
- package/dist/lib.js.map +3 -3
- package/package.json +6 -6
- package/src/lib/assets/helm.ts +18 -0
- package/src/lib/assets/index.ts +3 -1
- package/src/lib/assets/yaml.ts +35 -0
- package/src/lib/controller/index.ts +3 -3
- package/src/lib/controller/store.ts +7 -3
- package/src/lib/mutate-processor.ts +17 -6
- package/src/runtime/controller.ts +2 -2
- package/dist/cli.d.ts +0 -3
- package/dist/lib/assets/deploy.d.ts +0 -3
- package/dist/lib/assets/destroy.d.ts +0 -2
- package/dist/lib/assets/helm.d.ts +0 -5
- package/dist/lib/assets/index.d.ts +0 -24
- package/dist/lib/assets/loader.d.ts +0 -8
- package/dist/lib/assets/networking.d.ts +0 -7
- package/dist/lib/assets/pods.d.ts +0 -126
- package/dist/lib/assets/rbac.d.ts +0 -14
- package/dist/lib/assets/store.d.ts +0 -7
- package/dist/lib/assets/webhooks.d.ts +0 -6
- package/dist/lib/assets/yaml.d.ts +0 -5
- package/dist/lib/capability.d.ts +0 -66
- package/dist/lib/controller/index.d.ts +0 -10
- package/dist/lib/controller/store.d.ts +0 -7
- package/dist/lib/errors.d.ts +0 -12
- package/dist/lib/filter.d.ts +0 -11
- package/dist/lib/helpers.d.ts +0 -34
- package/dist/lib/included-files.d.ts +0 -2
- package/dist/lib/k8s.d.ts +0 -132
- package/dist/lib/logger.d.ts +0 -3
- package/dist/lib/metrics.d.ts +0 -39
- package/dist/lib/module.d.ts +0 -62
- package/dist/lib/mutate-processor.d.ts +0 -5
- package/dist/lib/mutate-request.d.ts +0 -79
- package/dist/lib/queue.d.ts +0 -19
- package/dist/lib/schedule.d.ts +0 -76
- package/dist/lib/storage.d.ts +0 -83
- package/dist/lib/tls.d.ts +0 -18
- package/dist/lib/types.d.ts +0 -192
- package/dist/lib/utils.d.ts +0 -23
- package/dist/lib/validate-processor.d.ts +0 -4
- package/dist/lib/validate-request.d.ts +0 -55
- package/dist/lib/watch-processor.d.ts +0 -10
- package/dist/lib.d.ts +0 -11
- package/dist/runtime/controller.d.ts +0 -3
- package/dist/sdk/sdk.d.ts +0 -38
package/dist/lib/types.d.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { GenericClass, GroupVersionKind, KubernetesObject } from "kubernetes-fluent-client";
|
|
2
|
-
import { WatchAction } from "kubernetes-fluent-client/dist/fluent/types";
|
|
3
|
-
import { PeprMutateRequest } from "./mutate-request";
|
|
4
|
-
import { PeprValidateRequest } from "./validate-request";
|
|
5
|
-
/**
|
|
6
|
-
* Specifically for parsing logs in monitor mode
|
|
7
|
-
*/
|
|
8
|
-
export interface ResponseItem {
|
|
9
|
-
uid?: string;
|
|
10
|
-
allowed: boolean;
|
|
11
|
-
status: {
|
|
12
|
-
message: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Recursively make all properties in T optional.
|
|
17
|
-
*/
|
|
18
|
-
export type DeepPartial<T> = {
|
|
19
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* The type of Kubernetes mutating webhook event that the action is registered for.
|
|
23
|
-
*/
|
|
24
|
-
export declare enum Event {
|
|
25
|
-
Create = "CREATE",
|
|
26
|
-
Update = "UPDATE",
|
|
27
|
-
Delete = "DELETE",
|
|
28
|
-
CreateOrUpdate = "CREATEORUPDATE",
|
|
29
|
-
Any = "*"
|
|
30
|
-
}
|
|
31
|
-
export interface CapabilityCfg {
|
|
32
|
-
/**
|
|
33
|
-
* The name of the capability. This should be unique.
|
|
34
|
-
*/
|
|
35
|
-
name: string;
|
|
36
|
-
/**
|
|
37
|
-
* A description of the capability and what it does.
|
|
38
|
-
*/
|
|
39
|
-
description: string;
|
|
40
|
-
/**
|
|
41
|
-
* List of namespaces that this capability applies to, if empty, applies to all namespaces (cluster-wide).
|
|
42
|
-
* This does not supersede the `alwaysIgnore` global configuration.
|
|
43
|
-
*/
|
|
44
|
-
namespaces?: string[];
|
|
45
|
-
}
|
|
46
|
-
export interface CapabilityExport extends CapabilityCfg {
|
|
47
|
-
bindings: Binding[];
|
|
48
|
-
hasSchedule: boolean;
|
|
49
|
-
}
|
|
50
|
-
export type WhenSelector<T extends GenericClass> = {
|
|
51
|
-
/** Register an action to be executed when a Kubernetes resource is created or updated. */
|
|
52
|
-
IsCreatedOrUpdated: () => BindingAll<T>;
|
|
53
|
-
/** Register an action to be executed when a Kubernetes resource is created. */
|
|
54
|
-
IsCreated: () => BindingAll<T>;
|
|
55
|
-
/** Register ann action to be executed when a Kubernetes resource is updated. */
|
|
56
|
-
IsUpdated: () => BindingAll<T>;
|
|
57
|
-
/** Register an action to be executed when a Kubernetes resource is deleted. */
|
|
58
|
-
IsDeleted: () => BindingAll<T>;
|
|
59
|
-
};
|
|
60
|
-
export type Binding = {
|
|
61
|
-
event: Event;
|
|
62
|
-
isMutate?: boolean;
|
|
63
|
-
isValidate?: boolean;
|
|
64
|
-
isWatch?: boolean;
|
|
65
|
-
isQueue?: boolean;
|
|
66
|
-
readonly model: GenericClass;
|
|
67
|
-
readonly kind: GroupVersionKind;
|
|
68
|
-
readonly filters: {
|
|
69
|
-
name: string;
|
|
70
|
-
namespaces: string[];
|
|
71
|
-
labels: Record<string, string>;
|
|
72
|
-
annotations: Record<string, string>;
|
|
73
|
-
};
|
|
74
|
-
readonly mutateCallback?: MutateAction<GenericClass, InstanceType<GenericClass>>;
|
|
75
|
-
readonly validateCallback?: ValidateAction<GenericClass, InstanceType<GenericClass>>;
|
|
76
|
-
readonly watchCallback?: WatchAction<GenericClass, InstanceType<GenericClass>>;
|
|
77
|
-
};
|
|
78
|
-
export type BindingFilter<T extends GenericClass> = CommonActionChain<T> & {
|
|
79
|
-
/**
|
|
80
|
-
* Only apply the action if the resource has the specified label. If no value is specified, the label must exist.
|
|
81
|
-
* Note multiple calls to this method will result in an AND condition. e.g.
|
|
82
|
-
*
|
|
83
|
-
* ```ts
|
|
84
|
-
* When(a.Deployment)
|
|
85
|
-
* .IsCreated()
|
|
86
|
-
* .WithLabel("foo", "bar")
|
|
87
|
-
* .WithLabel("baz", "qux")
|
|
88
|
-
* .Mutate(...)
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* Will only apply the action if the resource has both the `foo=bar` and `baz=qux` labels.
|
|
92
|
-
*
|
|
93
|
-
* @param key
|
|
94
|
-
* @param value
|
|
95
|
-
*/
|
|
96
|
-
WithLabel: (key: string, value?: string) => BindingFilter<T>;
|
|
97
|
-
/**
|
|
98
|
-
* Only apply the action if the resource has the specified annotation. If no value is specified, the annotation must exist.
|
|
99
|
-
* Note multiple calls to this method will result in an AND condition. e.g.
|
|
100
|
-
*
|
|
101
|
-
* ```ts
|
|
102
|
-
* When(a.Deployment)
|
|
103
|
-
* .IsCreated()
|
|
104
|
-
* .WithAnnotation("foo", "bar")
|
|
105
|
-
* .WithAnnotation("baz", "qux")
|
|
106
|
-
* .Mutate(...)
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* Will only apply the action if the resource has both the `foo=bar` and `baz=qux` annotations.
|
|
110
|
-
*
|
|
111
|
-
* @param key
|
|
112
|
-
* @param value
|
|
113
|
-
*/
|
|
114
|
-
WithAnnotation: (key: string, value?: string) => BindingFilter<T>;
|
|
115
|
-
};
|
|
116
|
-
export type BindingWithName<T extends GenericClass> = BindingFilter<T> & {
|
|
117
|
-
/** Only apply the action if the resource name matches the specified name. */
|
|
118
|
-
WithName: (name: string) => BindingFilter<T>;
|
|
119
|
-
};
|
|
120
|
-
export type BindingAll<T extends GenericClass> = BindingWithName<T> & {
|
|
121
|
-
/** Only apply the action if the resource is in one of the specified namespaces.*/
|
|
122
|
-
InNamespace: (...namespaces: string[]) => BindingWithName<T>;
|
|
123
|
-
};
|
|
124
|
-
export type CommonActionChain<T extends GenericClass> = MutateActionChain<T> & {
|
|
125
|
-
/**
|
|
126
|
-
* Create a new MUTATE action with the specified callback function and previously specified
|
|
127
|
-
* filters.
|
|
128
|
-
*
|
|
129
|
-
* @since 0.13.0
|
|
130
|
-
*
|
|
131
|
-
* @param action The action to be executed when the Kubernetes resource is processed by the AdmissionController.
|
|
132
|
-
*/
|
|
133
|
-
Mutate: (action: MutateAction<T, InstanceType<T>>) => MutateActionChain<T>;
|
|
134
|
-
};
|
|
135
|
-
export type ValidateActionChain<T extends GenericClass> = {
|
|
136
|
-
/**
|
|
137
|
-
* Establish a watcher for the specified resource. The callback function will be executed after the admission controller has
|
|
138
|
-
* processed the resource and the request has been persisted to the cluster.
|
|
139
|
-
*
|
|
140
|
-
* **Beta Function**: This method is still in early testing and edge cases may still exist.
|
|
141
|
-
*
|
|
142
|
-
* @since 0.14.0
|
|
143
|
-
*
|
|
144
|
-
* @param action
|
|
145
|
-
* @returns
|
|
146
|
-
*/
|
|
147
|
-
Watch: (action: WatchAction<T, InstanceType<T>>) => void;
|
|
148
|
-
/**
|
|
149
|
-
* Establish a reconcile for the specified resource. The callback function will be executed after the admission controller has
|
|
150
|
-
* processed the resource and the request has been persisted to the cluster.
|
|
151
|
-
*
|
|
152
|
-
* **Beta Function**: This method is still in early testing and edge cases may still exist.
|
|
153
|
-
*
|
|
154
|
-
* @since 0.14.0
|
|
155
|
-
*
|
|
156
|
-
* @param action
|
|
157
|
-
* @returns
|
|
158
|
-
*/
|
|
159
|
-
Reconcile: (action: WatchAction<T, InstanceType<T>>) => void;
|
|
160
|
-
};
|
|
161
|
-
export type MutateActionChain<T extends GenericClass> = ValidateActionChain<T> & {
|
|
162
|
-
/**
|
|
163
|
-
* Create a new VALIDATE action with the specified callback function and previously specified
|
|
164
|
-
* filters. Return the `request.Approve()` or `Request.Deny()` methods to approve or deny the request:
|
|
165
|
-
*
|
|
166
|
-
* @since 0.13.0
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```ts
|
|
170
|
-
* When(a.Deployment)
|
|
171
|
-
* .IsCreated()
|
|
172
|
-
* .Validate(request => {
|
|
173
|
-
* if (request.HasLabel("foo")) {
|
|
174
|
-
* return request.Approve();
|
|
175
|
-
* }
|
|
176
|
-
*
|
|
177
|
-
* return request.Deny("Deployment must have label foo");
|
|
178
|
-
* });
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
181
|
-
* @param action The action to be executed when the Kubernetes resource is processed by the AdmissionController.
|
|
182
|
-
*/
|
|
183
|
-
Validate: (action: ValidateAction<T, InstanceType<T>>) => ValidateActionChain<T>;
|
|
184
|
-
};
|
|
185
|
-
export type MutateAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (req: PeprMutateRequest<K>) => Promise<void> | void | Promise<PeprMutateRequest<K>> | PeprMutateRequest<K>;
|
|
186
|
-
export type ValidateAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (req: PeprValidateRequest<K>) => Promise<ValidateActionResponse> | ValidateActionResponse;
|
|
187
|
-
export type ValidateActionResponse = {
|
|
188
|
-
allowed: boolean;
|
|
189
|
-
statusCode?: number;
|
|
190
|
-
statusMessage?: string;
|
|
191
|
-
};
|
|
192
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/utils.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** Test if a string is ascii or not */
|
|
2
|
-
export declare const isAscii: RegExp;
|
|
3
|
-
/**
|
|
4
|
-
* Encode all ascii values in a map to base64
|
|
5
|
-
* @param obj The object to encode
|
|
6
|
-
* @param skip A list of keys to skip encoding
|
|
7
|
-
*/
|
|
8
|
-
export declare function convertToBase64Map(obj: {
|
|
9
|
-
data?: Record<string, string>;
|
|
10
|
-
}, skip: string[]): void;
|
|
11
|
-
/**
|
|
12
|
-
* Decode all ascii values in a map from base64 to utf-8
|
|
13
|
-
* @param obj The object to decode
|
|
14
|
-
* @returns A list of keys that were skipped
|
|
15
|
-
*/
|
|
16
|
-
export declare function convertFromBase64Map(obj: {
|
|
17
|
-
data?: Record<string, string>;
|
|
18
|
-
}): string[];
|
|
19
|
-
/** Decode a base64 string */
|
|
20
|
-
export declare function base64Decode(data: string): string;
|
|
21
|
-
/** Encode a string to base64 */
|
|
22
|
-
export declare function base64Encode(data: string): string;
|
|
23
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Capability } from "./capability";
|
|
2
|
-
import { AdmissionRequest, ValidateResponse } from "./k8s";
|
|
3
|
-
export declare function validateProcessor(capabilities: Capability[], req: AdmissionRequest, reqMetadata: Record<string, string>): Promise<ValidateResponse[]>;
|
|
4
|
-
//# sourceMappingURL=validate-processor.d.ts.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { KubernetesObject } from "kubernetes-fluent-client";
|
|
2
|
-
import { AdmissionRequest } from "./k8s";
|
|
3
|
-
import { ValidateActionResponse } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* The RequestWrapper class provides methods to modify Kubernetes objects in the context
|
|
6
|
-
* of a mutating webhook request.
|
|
7
|
-
*/
|
|
8
|
-
export declare class PeprValidateRequest<T extends KubernetesObject> {
|
|
9
|
-
#private;
|
|
10
|
-
Raw: T;
|
|
11
|
-
/**
|
|
12
|
-
* Provides access to the old resource in the request if available.
|
|
13
|
-
* @returns The old Kubernetes resource object or null if not available.
|
|
14
|
-
*/
|
|
15
|
-
get OldResource(): T | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Provides access to the request object.
|
|
18
|
-
* @returns The request object containing the Kubernetes resource.
|
|
19
|
-
*/
|
|
20
|
-
get Request(): AdmissionRequest<T>;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new instance of the Action class.
|
|
23
|
-
* @param input - The request object containing the Kubernetes resource to modify.
|
|
24
|
-
*/
|
|
25
|
-
constructor(input: AdmissionRequest<T>);
|
|
26
|
-
/**
|
|
27
|
-
* Check if a label exists on the Kubernetes resource.
|
|
28
|
-
*
|
|
29
|
-
* @param key the label key to check
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
HasLabel: (key: string) => boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Check if an annotation exists on the Kubernetes resource.
|
|
35
|
-
*
|
|
36
|
-
* @param key the annotation key to check
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
HasAnnotation: (key: string) => boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Create a validation response that allows the request.
|
|
42
|
-
*
|
|
43
|
-
* @returns The validation response.
|
|
44
|
-
*/
|
|
45
|
-
Approve: () => ValidateActionResponse;
|
|
46
|
-
/**
|
|
47
|
-
* Create a validation response that denies the request.
|
|
48
|
-
*
|
|
49
|
-
* @param statusMessage Optional status message to return to the user.
|
|
50
|
-
* @param statusCode Optional status code to return to the user.
|
|
51
|
-
* @returns The validation response.
|
|
52
|
-
*/
|
|
53
|
-
Deny: (statusMessage?: string, statusCode?: number) => ValidateActionResponse;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=validate-request.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { KubernetesObject, WatchEvent } from "kubernetes-fluent-client";
|
|
2
|
-
import { Capability } from "./capability";
|
|
3
|
-
/**
|
|
4
|
-
* Entrypoint for setting up watches for all capabilities
|
|
5
|
-
*
|
|
6
|
-
* @param capabilities The capabilities to load watches for
|
|
7
|
-
*/
|
|
8
|
-
export declare function setupWatch(capabilities: Capability[]): void;
|
|
9
|
-
export declare function logEvent(type: WatchEvent, message?: string, obj?: KubernetesObject): void;
|
|
10
|
-
//# sourceMappingURL=watch-processor.d.ts.map
|
package/dist/lib.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { K8s, RegisterKind, kind as a, fetch, fetchStatus, kind } from "kubernetes-fluent-client";
|
|
2
|
-
import * as R from "ramda";
|
|
3
|
-
import { Capability } from "./lib/capability";
|
|
4
|
-
import Log from "./lib/logger";
|
|
5
|
-
import { PeprModule } from "./lib/module";
|
|
6
|
-
import { PeprMutateRequest } from "./lib/mutate-request";
|
|
7
|
-
import * as PeprUtils from "./lib/utils";
|
|
8
|
-
import { PeprValidateRequest } from "./lib/validate-request";
|
|
9
|
-
import * as sdk from "./sdk/sdk";
|
|
10
|
-
export { Capability, K8s, Log, PeprModule, PeprMutateRequest, PeprUtils, PeprValidateRequest, R, RegisterKind, a, fetch, fetchStatus, kind, sdk, };
|
|
11
|
-
//# sourceMappingURL=lib.d.ts.map
|
package/dist/sdk/sdk.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PeprValidateRequest } from "../lib/validate-request";
|
|
2
|
-
import { PeprMutateRequest } from "../lib/mutate-request";
|
|
3
|
-
import { a } from "../lib";
|
|
4
|
-
import { V1OwnerReference } from "@kubernetes/client-node";
|
|
5
|
-
import { GenericKind } from "kubernetes-fluent-client";
|
|
6
|
-
import { kind } from "kubernetes-fluent-client";
|
|
7
|
-
/**
|
|
8
|
-
* Returns all containers in a pod
|
|
9
|
-
* @param request the request/pod to get the containers from
|
|
10
|
-
* @param containerType the type of container to get
|
|
11
|
-
* @returns the list of containers in the pod
|
|
12
|
-
*/
|
|
13
|
-
export declare function containers(request: PeprValidateRequest<a.Pod> | PeprMutateRequest<a.Pod>, containerType?: "containers" | "initContainers" | "ephemeralContainers"): import("@kubernetes/client-node").V1Container[];
|
|
14
|
-
/**
|
|
15
|
-
* Write a K8s event for a CRD
|
|
16
|
-
*
|
|
17
|
-
* @param cr The custom resource to write the event for
|
|
18
|
-
* @param event The event to write, should contain a human-readable message for the event
|
|
19
|
-
* @param eventType The type of event to write, for example "Warning"
|
|
20
|
-
* @param eventReason The reason for the event, for example "ReconciliationFailed"
|
|
21
|
-
* @param reportingComponent The component that is reporting the event, for example "uds.dev/operator"
|
|
22
|
-
* @param reportingInstance The instance of the component that is reporting the event, for example process.env.HOSTNAME
|
|
23
|
-
*/
|
|
24
|
-
export declare function writeEvent(cr: GenericKind, event: Partial<kind.CoreEvent>, eventType: string, eventReason: string, reportingComponent: string, reportingInstance: string): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Get the owner reference for a custom resource
|
|
27
|
-
* @param cr the custom resource to get the owner reference for
|
|
28
|
-
* @returns the owner reference for the custom resource
|
|
29
|
-
*/
|
|
30
|
-
export declare function getOwnerRefFrom(cr: GenericKind): V1OwnerReference[];
|
|
31
|
-
/**
|
|
32
|
-
* Sanitize a resource name to make it a valid Kubernetes resource name.
|
|
33
|
-
*
|
|
34
|
-
* @param name the name of the resource to sanitize
|
|
35
|
-
* @returns the sanitized resource name
|
|
36
|
-
*/
|
|
37
|
-
export declare function sanitizeResourceName(name: string): string;
|
|
38
|
-
//# sourceMappingURL=sdk.d.ts.map
|