pepr 0.2.9 → 0.3.0-rc0
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/README.md +10 -3
- package/dist/fixtures/data/cm1.json +75 -0
- package/dist/fixtures/data/deployment1.json +170 -0
- package/dist/fixtures/data/ns1.json +72 -0
- package/dist/fixtures/data/pod1.json +271 -0
- package/dist/fixtures/data/pod2.json +257 -0
- package/dist/fixtures/data/svc1.json +100 -0
- package/dist/fixtures/loader.js +60 -0
- package/dist/package.json +23 -41
- package/dist/src/cli/build.js +3 -1
- package/dist/src/cli/dev.js +31 -19
- package/dist/src/cli/index.js +1 -0
- package/dist/src/cli/init/index.js +3 -1
- package/dist/src/cli/init/templates.js +3 -2
- package/dist/src/cli/init/utils.js +1 -1
- package/dist/src/cli/init/utils.test.js +29 -0
- package/dist/src/cli/init/walkthrough.js +1 -1
- package/dist/src/cli/init/walkthrough.test.js +21 -0
- package/dist/src/cli/run.js +17 -17
- package/dist/src/cli/update.js +3 -1
- package/dist/src/lib/capability.js +1 -1
- package/dist/src/lib/controller.js +9 -1
- package/dist/src/lib/fetch.js +39 -6
- package/dist/src/lib/fetch.test.js +98 -0
- package/dist/src/lib/filter.test.js +208 -0
- package/dist/src/lib/k8s/kinds.test.js +296 -0
- package/dist/src/lib/k8s/webhook.js +22 -22
- package/dist/src/lib/logger.test.js +64 -0
- package/dist/src/lib/processor.js +4 -1
- package/{dist/index.d.ts → index.ts} +21 -3
- package/package.json +23 -41
- package/src/lib/capability.ts +158 -0
- package/src/lib/controller.ts +127 -0
- package/src/lib/fetch.test.ts +115 -0
- package/src/lib/fetch.ts +75 -0
- package/src/lib/filter.test.ts +231 -0
- package/src/lib/filter.ts +87 -0
- package/{dist/src/lib/k8s/index.d.ts → src/lib/k8s/index.ts} +6 -0
- package/src/lib/k8s/kinds.test.ts +333 -0
- package/src/lib/k8s/kinds.ts +489 -0
- package/src/lib/k8s/tls.ts +90 -0
- package/src/lib/k8s/types.ts +183 -0
- package/src/lib/k8s/upstream.ts +49 -0
- package/src/lib/k8s/webhook.ts +547 -0
- package/src/lib/logger.test.ts +80 -0
- package/src/lib/logger.ts +136 -0
- package/src/lib/module.ts +63 -0
- package/src/lib/processor.ts +98 -0
- package/src/lib/request.ts +140 -0
- package/src/lib/types.ts +211 -0
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -4
- package/dist/run.d.ts +0 -2
- package/dist/run.js +0 -4
- package/dist/src/cli/banner.d.ts +0 -1
- package/dist/src/cli/build.d.ts +0 -7
- package/dist/src/cli/capability.d.ts +0 -2
- package/dist/src/cli/deploy.d.ts +0 -2
- package/dist/src/cli/dev.d.ts +0 -2
- package/dist/src/cli/index.d.ts +0 -1
- package/dist/src/cli/init/index.d.ts +0 -2
- package/dist/src/cli/init/templates.d.ts +0 -94
- package/dist/src/cli/init/utils.d.ts +0 -20
- package/dist/src/cli/init/walkthrough.d.ts +0 -7
- package/dist/src/cli/root.d.ts +0 -4
- package/dist/src/cli/run.d.ts +0 -1
- package/dist/src/cli/test.d.ts +0 -2
- package/dist/src/cli/update.d.ts +0 -2
- package/dist/src/lib/capability.d.ts +0 -28
- package/dist/src/lib/controller.d.ts +0 -17
- package/dist/src/lib/fetch.d.ts +0 -23
- package/dist/src/lib/filter.d.ts +0 -10
- package/dist/src/lib/k8s/kinds.d.ts +0 -11
- package/dist/src/lib/k8s/tls.d.ts +0 -17
- package/dist/src/lib/k8s/types.d.ts +0 -147
- package/dist/src/lib/k8s/upstream.d.ts +0 -3
- package/dist/src/lib/k8s/webhook.d.ts +0 -34
- package/dist/src/lib/logger.d.ts +0 -55
- package/dist/src/lib/module.d.ts +0 -32
- package/dist/src/lib/processor.d.ts +0 -4
- package/dist/src/lib/request.d.ts +0 -77
- package/dist/src/lib/types.d.ts +0 -187
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import { V1ListMeta, V1ObjectMeta } from "@kubernetes/client-node";
|
|
5
|
+
|
|
6
|
+
export enum Operation {
|
|
7
|
+
CREATE = "CREATE",
|
|
8
|
+
UPDATE = "UPDATE",
|
|
9
|
+
DELETE = "DELETE",
|
|
10
|
+
CONNECT = "CONNECT",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface KubernetesObject {
|
|
14
|
+
apiVersion?: string;
|
|
15
|
+
kind?: string;
|
|
16
|
+
metadata?: V1ObjectMeta;
|
|
17
|
+
}
|
|
18
|
+
export interface KubernetesListObject<T extends KubernetesObject> {
|
|
19
|
+
apiVersion?: string;
|
|
20
|
+
kind?: string;
|
|
21
|
+
metadata?: V1ListMeta;
|
|
22
|
+
items: T[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
|
|
27
|
+
* that is not explicitly supported by Pepr. This can be used on its own or as a base class for
|
|
28
|
+
* other types. See the examples in `HelloPepr.ts` for more information.
|
|
29
|
+
*/
|
|
30
|
+
export class GenericKind {
|
|
31
|
+
apiVersion?: string;
|
|
32
|
+
kind?: string;
|
|
33
|
+
metadata?: V1ObjectMeta;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
|
|
40
|
+
* to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
|
|
41
|
+
**/
|
|
42
|
+
export interface GroupVersionKind {
|
|
43
|
+
/** The K8s resource kind, e..g "Pod". */
|
|
44
|
+
readonly kind: string;
|
|
45
|
+
readonly group: string;
|
|
46
|
+
readonly version?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
|
|
51
|
+
* to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
|
|
52
|
+
*/
|
|
53
|
+
export interface GroupVersionResource {
|
|
54
|
+
readonly group: string;
|
|
55
|
+
readonly version: string;
|
|
56
|
+
readonly resource: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A Kubernetes admission request to be processed by a capability.
|
|
61
|
+
*/
|
|
62
|
+
export interface Request<T = KubernetesObject> {
|
|
63
|
+
/** UID is an identifier for the individual request/response. */
|
|
64
|
+
readonly uid: string;
|
|
65
|
+
|
|
66
|
+
/** Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) */
|
|
67
|
+
readonly kind: GroupVersionKind;
|
|
68
|
+
|
|
69
|
+
/** Resource is the fully-qualified resource being requested (for example, v1.pods) */
|
|
70
|
+
readonly resource: GroupVersionResource;
|
|
71
|
+
|
|
72
|
+
/** SubResource is the sub-resource being requested, if any (for example, "status" or "scale") */
|
|
73
|
+
readonly subResource?: string;
|
|
74
|
+
|
|
75
|
+
/** RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). */
|
|
76
|
+
readonly requestKind?: GroupVersionKind;
|
|
77
|
+
|
|
78
|
+
/** RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). */
|
|
79
|
+
readonly requestResource?: GroupVersionResource;
|
|
80
|
+
|
|
81
|
+
/** RequestSubResource is the sub-resource of the original API request, if any (for example, "status" or "scale"). */
|
|
82
|
+
readonly requestSubResource?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and
|
|
86
|
+
* rely on the server to generate the name. If that is the case, this method will return the empty string.
|
|
87
|
+
*/
|
|
88
|
+
readonly name: string;
|
|
89
|
+
|
|
90
|
+
/** Namespace is the namespace associated with the request (if any). */
|
|
91
|
+
readonly namespace?: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Operation is the operation being performed. This may be different than the operation
|
|
95
|
+
* requested. e.g. a patch can result in either a CREATE or UPDATE Operation.
|
|
96
|
+
*/
|
|
97
|
+
readonly operation: Operation;
|
|
98
|
+
|
|
99
|
+
/** UserInfo is information about the requesting user */
|
|
100
|
+
readonly userInfo: {
|
|
101
|
+
/** The name that uniquely identifies this user among all active users. */
|
|
102
|
+
username?: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A unique value that identifies this user across time. If this user is deleted
|
|
106
|
+
* and another user by the same name is added, they will have different UIDs.
|
|
107
|
+
*/
|
|
108
|
+
uid?: string;
|
|
109
|
+
|
|
110
|
+
/** The names of groups this user is a part of. */
|
|
111
|
+
groups?: string[];
|
|
112
|
+
|
|
113
|
+
/** Any additional information provided by the authenticator. */
|
|
114
|
+
extra?: {
|
|
115
|
+
[key: string]: string[];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** Object is the object from the incoming request prior to default values being applied */
|
|
120
|
+
readonly object: T;
|
|
121
|
+
|
|
122
|
+
/** OldObject is the existing object. Only populated for UPDATE requests. */
|
|
123
|
+
readonly oldObject?: T;
|
|
124
|
+
|
|
125
|
+
/** DryRun indicates that modifications will definitely not be persisted for this request. Defaults to false. */
|
|
126
|
+
readonly dryRun?: boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Options contains the options for the operation being performed.
|
|
130
|
+
* e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be
|
|
131
|
+
* different than the options the caller provided. e.g. for a patch request the performed
|
|
132
|
+
* Operation might be a CREATE, in which case the Options will a
|
|
133
|
+
* `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`.
|
|
134
|
+
*/
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
readonly options?: any;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface Response {
|
|
140
|
+
/** UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest. */
|
|
141
|
+
uid: string;
|
|
142
|
+
|
|
143
|
+
/** Allowed indicates whether or not the admission request was permitted. */
|
|
144
|
+
allowed: boolean;
|
|
145
|
+
|
|
146
|
+
/** Result contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
|
|
147
|
+
result?: string;
|
|
148
|
+
|
|
149
|
+
/** The patch body. Currently we only support "JSONPatch" which implements RFC 6902. */
|
|
150
|
+
patch?: string;
|
|
151
|
+
|
|
152
|
+
/** The type of Patch. Currently we only allow "JSONPatch". */
|
|
153
|
+
patchType?: "JSONPatch";
|
|
154
|
+
|
|
155
|
+
/** AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted). */
|
|
156
|
+
auditAnnotations?: {
|
|
157
|
+
[key: string]: string;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** warnings is a list of warning messages to return to the requesting API client. */
|
|
161
|
+
warnings?: string[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type WebhookIgnore = {
|
|
165
|
+
/**
|
|
166
|
+
* List of Kubernetes namespaces to always ignore.
|
|
167
|
+
* Any resources in these namespaces will be ignored by Pepr.
|
|
168
|
+
*
|
|
169
|
+
* Note: `kube-system` and `pepr-system` are always ignored.
|
|
170
|
+
*/
|
|
171
|
+
namespaces?: string[];
|
|
172
|
+
/**
|
|
173
|
+
* List of Kubernetes labels to always ignore.
|
|
174
|
+
* Any resources with these labels will be ignored by Pepr.
|
|
175
|
+
*
|
|
176
|
+
* The example below will ignore any resources with the label `my-label=ulta-secret`:
|
|
177
|
+
* ```
|
|
178
|
+
* alwaysIgnore:
|
|
179
|
+
* labels: [{ "my-label": "ultra-secret" }]
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
labels?: Record<string, string>[];
|
|
183
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
/** a is a colleciton of K8s types to be used within a CapabilityAction: `When(a.Configmap)` */
|
|
5
|
+
export {
|
|
6
|
+
V1APIService as APIService,
|
|
7
|
+
V1CertificateSigningRequest as CertificateSigningRequest,
|
|
8
|
+
V1ConfigMap as ConfigMap,
|
|
9
|
+
V1ControllerRevision as ControllerRevision,
|
|
10
|
+
V1CronJob as CronJob,
|
|
11
|
+
V1CSIDriver as CSIDriver,
|
|
12
|
+
V1CSIStorageCapacity as CSIStorageCapacity,
|
|
13
|
+
V1CustomResourceDefinition as CustomResourceDefinition,
|
|
14
|
+
V1DaemonSet as DaemonSet,
|
|
15
|
+
V1Deployment as Deployment,
|
|
16
|
+
V1EndpointSlice as EndpointSlice,
|
|
17
|
+
V1HorizontalPodAutoscaler as HorizontalPodAutoscaler,
|
|
18
|
+
V1Ingress as Ingress,
|
|
19
|
+
V1IngressClass as IngressClass,
|
|
20
|
+
V1Job as Job,
|
|
21
|
+
V1LimitRange as LimitRange,
|
|
22
|
+
V1LocalSubjectAccessReview as LocalSubjectAccessReview,
|
|
23
|
+
V1MutatingWebhookConfiguration as MutatingWebhookConfiguration,
|
|
24
|
+
V1Namespace as Namespace,
|
|
25
|
+
V1NetworkPolicy as NetworkPolicy,
|
|
26
|
+
V1Node as Node,
|
|
27
|
+
V1PersistentVolume as PersistentVolume,
|
|
28
|
+
V1PersistentVolumeClaim as PersistentVolumeClaim,
|
|
29
|
+
V1Pod as Pod,
|
|
30
|
+
V1PodDisruptionBudget as PodDisruptionBudget,
|
|
31
|
+
V1PodTemplate as PodTemplate,
|
|
32
|
+
V1ReplicaSet as ReplicaSet,
|
|
33
|
+
V1ReplicationController as ReplicationController,
|
|
34
|
+
V1ResourceQuota as ResourceQuota,
|
|
35
|
+
V1RuntimeClass as RuntimeClass,
|
|
36
|
+
V1Secret as Secret,
|
|
37
|
+
V1SelfSubjectAccessReview as SelfSubjectAccessReview,
|
|
38
|
+
V1SelfSubjectRulesReview as SelfSubjectRulesReview,
|
|
39
|
+
V1Service as Service,
|
|
40
|
+
V1ServiceAccount as ServiceAccount,
|
|
41
|
+
V1StatefulSet as StatefulSet,
|
|
42
|
+
V1StorageClass as StorageClass,
|
|
43
|
+
V1SubjectAccessReview as SubjectAccessReview,
|
|
44
|
+
V1TokenReview as TokenReview,
|
|
45
|
+
V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration,
|
|
46
|
+
V1VolumeAttachment as VolumeAttachment,
|
|
47
|
+
} from "@kubernetes/client-node/dist";
|
|
48
|
+
|
|
49
|
+
export { GenericKind } from "./types";
|