pepr 0.1.27 → 0.1.28

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.
Files changed (59) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +5 -0
  3. package/dist/package.json +76 -0
  4. package/dist/src/cli/banner.d.ts +1 -0
  5. package/dist/{pepr-cli.js → src/cli/banner.js} +1 -1251
  6. package/dist/src/cli/build.d.ts +7 -0
  7. package/dist/src/cli/build.js +95 -0
  8. package/dist/src/cli/capability.d.ts +2 -0
  9. package/dist/src/cli/capability.js +12 -0
  10. package/dist/src/cli/deploy.d.ts +2 -0
  11. package/dist/src/cli/deploy.js +49 -0
  12. package/dist/src/cli/dev.d.ts +2 -0
  13. package/dist/src/cli/dev.js +90 -0
  14. package/dist/src/cli/index.d.ts +1 -0
  15. package/dist/src/cli/index.js +28 -0
  16. package/dist/src/cli/init/index.d.ts +2 -0
  17. package/dist/src/cli/init/index.js +48 -0
  18. package/dist/src/cli/init/templates.d.ts +82 -0
  19. package/dist/src/cli/init/templates.js +224 -0
  20. package/dist/src/cli/init/utils.d.ts +20 -0
  21. package/dist/src/cli/init/utils.js +50 -0
  22. package/dist/src/cli/init/walkthrough.d.ts +7 -0
  23. package/dist/src/cli/init/walkthrough.js +76 -0
  24. package/dist/src/cli/root.d.ts +4 -0
  25. package/dist/src/cli/root.js +14 -0
  26. package/dist/src/cli/test.d.ts +2 -0
  27. package/dist/src/cli/test.js +45 -0
  28. package/dist/src/lib/capability.d.ts +26 -0
  29. package/dist/src/lib/capability.js +112 -0
  30. package/dist/src/lib/controller.d.ts +13 -0
  31. package/dist/src/lib/controller.js +77 -0
  32. package/dist/src/lib/filter.d.ts +10 -0
  33. package/dist/src/lib/filter.js +41 -0
  34. package/dist/src/lib/k8s/index.d.ts +4 -0
  35. package/dist/src/lib/k8s/index.js +7 -0
  36. package/dist/src/lib/k8s/kinds.d.ts +3 -0
  37. package/dist/src/lib/k8s/kinds.js +427 -0
  38. package/dist/src/lib/k8s/tls.d.ts +17 -0
  39. package/dist/src/lib/k8s/tls.js +67 -0
  40. package/dist/src/lib/k8s/types.d.ts +136 -0
  41. package/dist/src/lib/k8s/types.js +9 -0
  42. package/dist/src/lib/k8s/upstream.d.ts +1 -0
  43. package/dist/src/lib/k8s/upstream.js +3 -0
  44. package/dist/src/lib/k8s/webhook.d.ts +33 -0
  45. package/dist/src/lib/k8s/webhook.js +490 -0
  46. package/dist/src/lib/logger.d.ts +54 -0
  47. package/dist/{types-1709b44f.js → src/lib/logger.js} +3 -40
  48. package/dist/src/lib/module.d.ts +22 -0
  49. package/dist/src/lib/module.js +32 -0
  50. package/dist/src/lib/processor.d.ts +4 -0
  51. package/dist/src/lib/processor.js +66 -0
  52. package/dist/src/lib/request.d.ts +77 -0
  53. package/dist/src/lib/request.js +117 -0
  54. package/dist/src/lib/types.d.ts +187 -0
  55. package/dist/src/lib/types.js +31 -0
  56. package/package.json +8 -11
  57. package/tsconfig.build.json +4 -0
  58. package/dist/pepr-core.js +0 -949
  59. package/tsconfig.json +0 -17
@@ -0,0 +1,427 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
+ export const gvkMap = {
4
+ /**
5
+ * Represents a K8s ConfigMap resource.
6
+ * ConfigMap holds configuration data for pods to consume.
7
+ * @see {@link https://kubernetes.io/docs/concepts/configuration/configmap/}
8
+ */
9
+ V1ConfigMap: {
10
+ kind: "ConfigMap",
11
+ version: "v1",
12
+ group: "",
13
+ },
14
+ /**
15
+ * Represents a K8s Endpoints resource.
16
+ * Endpoints expose a service's IP addresses and ports to other resources.
17
+ * @see {@link https://kubernetes.io/docs/concepts/services-networking/service/#endpoints}
18
+ */
19
+ V1Endpoint: {
20
+ kind: "Endpoints",
21
+ version: "v1",
22
+ group: "",
23
+ },
24
+ /**
25
+ * Represents a K8s LimitRange resource.
26
+ * LimitRange enforces constraints on the resource consumption of objects in a namespace.
27
+ * @see {@link https://kubernetes.io/docs/concepts/policy/limit-range/}
28
+ */
29
+ V1LimitRange: {
30
+ kind: "LimitRange",
31
+ version: "v1",
32
+ group: "",
33
+ },
34
+ /**
35
+ * Represents a K8s Namespace resource.
36
+ * Namespace is a way to divide cluster resources between multiple users.
37
+ * @see {@link https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/}
38
+ */
39
+ V1Namespace: {
40
+ kind: "Namespace",
41
+ version: "v1",
42
+ group: "",
43
+ },
44
+ /**
45
+ * Represents a K8s Node resource.
46
+ * Node is a worker machine in Kubernetes.
47
+ * @see {@link https://kubernetes.io/docs/concepts/architecture/nodes/}
48
+ */
49
+ V1Node: {
50
+ kind: "Node",
51
+ version: "v1",
52
+ group: "",
53
+ },
54
+ /**
55
+ * Represents a K8s PersistentVolumeClaim resource.
56
+ * PersistentVolumeClaim is a user's request for and claim to a persistent volume.
57
+ * @see {@link https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims}
58
+ */
59
+ V1PersistentVolumeClaim: {
60
+ kind: "PersistentVolumeClaim",
61
+ version: "v1",
62
+ group: "",
63
+ },
64
+ /**
65
+ * Represents a K8s PersistentVolume resource.
66
+ * PersistentVolume is a piece of storage in the cluster that has been provisioned by an administrator.
67
+ * @see {@link https://kubernetes.io/docs/concepts/storage/persistent-volumes/}
68
+ */
69
+ V1PersistentVolume: {
70
+ kind: "PersistentVolume",
71
+ version: "v1",
72
+ group: "",
73
+ },
74
+ /**
75
+ * Represents a K8s Pod resource.
76
+ * Pod is the smallest and simplest unit in the Kubernetes object model.
77
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/pods/}
78
+ */
79
+ V1Pod: {
80
+ kind: "Pod",
81
+ version: "v1",
82
+ group: "",
83
+ },
84
+ /**
85
+ * Represents a K8s PodTemplate resource.
86
+ * PodTemplate is an object that describes the pod that will be created from a higher level abstraction.
87
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/#pod-template}
88
+ */
89
+ V1PodTemplate: {
90
+ kind: "PodTemplate",
91
+ version: "v1",
92
+ group: "",
93
+ },
94
+ /**
95
+ * Represents a K8s ReplicationController resource.
96
+ * ReplicationController ensures that a specified number of pod replicas are running at any given time.
97
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/}
98
+ */
99
+ V1ReplicationController: {
100
+ kind: "ReplicationController",
101
+ version: "v1",
102
+ group: "",
103
+ },
104
+ /**
105
+ * Represents a K8s ResourceQuota resource.
106
+ * ResourceQuota provides constraints that limit resource consumption per namespace.
107
+ * @see {@link https://kubernetes.io/docs/concepts/policy/resource-quotas/}
108
+ */
109
+ V1ResourceQuota: {
110
+ kind: "ResourceQuota",
111
+ version: "v1",
112
+ group: "",
113
+ },
114
+ /**
115
+ * Represents a K8s Secret resource.
116
+ * Secret holds secret data of a certain type.
117
+ * @see {@link https://kubernetes.io/docs/concepts/configuration/secret/}
118
+ */
119
+ V1Secret: {
120
+ kind: "Secret",
121
+ version: "v1",
122
+ group: "",
123
+ },
124
+ /**
125
+ * Represents a K8s ServiceAccount resource.
126
+ * ServiceAccount is an identity that processes in a pod can use to access the Kubernetes API.
127
+ * @see {@link https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/}
128
+ */
129
+ V1ServiceAccount: {
130
+ kind: "ServiceAccount",
131
+ version: "v1",
132
+ group: "",
133
+ },
134
+ /**
135
+ * Represents a K8s Service resource.
136
+ * Service is an abstraction which defines a logical set of Pods and a policy by which to access them.
137
+ * @see {@link https://kubernetes.io/docs/concepts/services-networking/service/}
138
+ */
139
+ V1Service: {
140
+ kind: "Service",
141
+ version: "v1",
142
+ group: "",
143
+ },
144
+ /**
145
+ * Represents a K8s MutatingWebhookConfiguration resource.
146
+ * MutatingWebhookConfiguration configures a mutating admission webhook.
147
+ * @see {@link https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#configure-admission-webhooks-on-the-fly}
148
+ */
149
+ V1MutatingWebhookConfiguration: {
150
+ kind: "MutatingWebhookConfiguration",
151
+ version: "v1",
152
+ group: "admissionregistration.k8s.io",
153
+ },
154
+ /**
155
+ * Represents a K8s ValidatingWebhookConfiguration resource.
156
+ * ValidatingWebhookConfiguration configures a validating admission webhook.
157
+ * @see {@link https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#configure-admission-webhooks-on-the-fly}
158
+ */
159
+ V1ValidatingWebhookConfiguration: {
160
+ kind: "ValidatingWebhookConfiguration",
161
+ version: "v1",
162
+ group: "admissionregistration.k8s.io",
163
+ },
164
+ /**
165
+ * Represents a K8s CustomResourceDefinition resource.
166
+ * CustomResourceDefinition is a custom resource in a Kubernetes cluster.
167
+ * @see {@link https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/}
168
+ */
169
+ V1CustomResourceDefinition: {
170
+ kind: "CustomResourceDefinition",
171
+ version: "v1",
172
+ group: "apiextensions.k8s.io",
173
+ },
174
+ /**
175
+ * Represents a K8s APIService resource.
176
+ * APIService represents a server for a particular API version and group.
177
+ * @see {@link https://kubernetes.io/docs/tasks/access-kubernetes-api/setup-extension-api-server/}
178
+ */
179
+ V1APIService: {
180
+ kind: "APIService",
181
+ version: "v1",
182
+ group: "apiregistration.k8s.io",
183
+ },
184
+ /**
185
+ * Represents a K8s ControllerRevision resource.
186
+ * ControllerRevision is used to manage the history of a StatefulSet or DaemonSet.
187
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#revision-history}
188
+ */
189
+ V1ControllerRevision: {
190
+ kind: "ControllerRevision",
191
+ version: "v1",
192
+ group: "apps",
193
+ },
194
+ /**
195
+ * Represents a K8s DaemonSet resource.
196
+ * DaemonSet ensures that all (or some) nodes run a copy of a Pod.
197
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/}
198
+ */
199
+ V1DaemonSet: {
200
+ kind: "DaemonSet",
201
+ version: "v1",
202
+ group: "apps",
203
+ },
204
+ /**
205
+ * Represents a K8s Deployment resource.
206
+ * Deployment provides declarative updates for Pods and ReplicaSets.
207
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/deployment/}
208
+ */
209
+ V1Deployment: {
210
+ kind: "Deployment",
211
+ version: "v1",
212
+ group: "apps",
213
+ },
214
+ /**
215
+ * Represents a K8s ReplicaSet resource.
216
+ * ReplicaSet ensures that a specified number of pod replicas are running at any given time.
217
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/}
218
+ */
219
+ V1ReplicaSet: {
220
+ kind: "ReplicaSet",
221
+ version: "v1",
222
+ group: "apps",
223
+ },
224
+ /**
225
+ * Represents a K8s StatefulSet resource.
226
+ * StatefulSet is used to manage stateful applications.
227
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/}
228
+ */
229
+ V1StatefulSet: {
230
+ kind: "StatefulSet",
231
+ version: "v1",
232
+ group: "apps",
233
+ },
234
+ /**
235
+ * Represents a K8s TokenReview resource.
236
+ * TokenReview attempts to authenticate a token to a known user.
237
+ * @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#tokenreview-v1-authentication-k8s-io}
238
+ */
239
+ V1TokenReview: {
240
+ kind: "TokenReview",
241
+ version: "v1",
242
+ group: "authentication.k8s.io",
243
+ },
244
+ /**
245
+ * Represents a K8s LocalSubjectAccessReview resource.
246
+ * LocalSubjectAccessReview checks whether a specific user can perform a specific action in a specific namespace.
247
+ * @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localsubjectaccessreview-v1-authorization-k8s-io}
248
+ */
249
+ V1LocalSubjectAccessReview: {
250
+ kind: "LocalSubjectAccessReview",
251
+ version: "v1",
252
+ group: "authorization.k8s.io",
253
+ },
254
+ /**
255
+ * Represents a K8s SelfSubjectAccessReview resource.
256
+ * SelfSubjectAccessReview checks whether the current user can perform a specific action.
257
+ * @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#selfsubjectaccessreview-v1-authorization-k8s-io}
258
+ */
259
+ V1SelfSubjectAccessReview: {
260
+ kind: "SelfSubjectAccessReview",
261
+ version: "v1",
262
+ group: "authorization.k8s.io",
263
+ },
264
+ /**
265
+ * Represents a K8s SelfSubjectRulesReview resource.
266
+ * SelfSubjectRulesReview lists the permissions a specific user has within a namespace.
267
+ * @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#selfsubjectrulesreview-v1-authorization-k8s-io}
268
+ */
269
+ V1SelfSubjectRulesReview: {
270
+ kind: "SelfSubjectRulesReview",
271
+ version: "v1",
272
+ group: "authorization.k8s.io",
273
+ },
274
+ /**
275
+ * Represents a K8s SubjectAccessReview resource.
276
+ * SubjectAccessReview checks whether a specific user can perform a specific action.
277
+ * @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#subjectaccessreview-v1-authorization-k8s-io}
278
+ */
279
+ V1SubjectAccessReview: {
280
+ kind: "SubjectAccessReview",
281
+ version: "v1",
282
+ group: "authorization.k8s.io",
283
+ },
284
+ /**
285
+ * Represents a K8s HorizontalPodAutoscaler resource.
286
+ * HorizontalPodAutoscaler automatically scales the number of Pods in a replication controller, deployment, or replica set.
287
+ * @see {@link https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/}
288
+ */
289
+ V1HorizontalPodAutoscaler: {
290
+ kind: "HorizontalPodAutoscaler",
291
+ version: "v2",
292
+ group: "autoscaling",
293
+ },
294
+ /**
295
+ * Represents a K8s CronJob resource.
296
+ * CronJob manages time-based jobs, specifically those that run periodically and complete after a successful execution.
297
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/}
298
+ */
299
+ V1CronJob: {
300
+ kind: "CronJob",
301
+ version: "v1",
302
+ group: "batch",
303
+ },
304
+ /**
305
+ * Represents a K8s Job resource.
306
+ * Job represents the configuration of a single job.
307
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/job/}
308
+ */
309
+ V1Job: {
310
+ kind: "Job",
311
+ version: "v1",
312
+ group: "batch",
313
+ },
314
+ /**
315
+ * Represents a K8s CertificateSigningRequest resource.
316
+ * CertificateSigningRequest represents a certificate signing request.
317
+ * @see {@link https://kubernetes.io/docs/reference/access-authn-authz/certificate-signing-requests/}
318
+ */
319
+ V1CertificateSigningRequest: {
320
+ kind: "CertificateSigningRequest",
321
+ version: "v1",
322
+ group: "certificates.k8s.io",
323
+ },
324
+ /**
325
+ * Represents a K8s EndpointSlice resource.
326
+ * EndpointSlice represents a scalable set of network endpoints for a Kubernetes Service.
327
+ * @see {@link https://kubernetes.io/docs/concepts/services-networking/endpoint-slices/}
328
+ */
329
+ V1EndpointSlice: {
330
+ kind: "EndpointSlice",
331
+ version: "v1",
332
+ group: "discovery.k8s.io",
333
+ },
334
+ /**
335
+ * Represents a K8s IngressClass resource.
336
+ * IngressClass represents the class of the Ingress, referenced by the Ingress spec.
337
+ * @see {@link https://kubernetes.io/docs/concepts/services-networking/ingress/}
338
+ */
339
+ V1IngressClass: {
340
+ kind: "IngressClass",
341
+ version: "v1",
342
+ group: "networking.k8s.io",
343
+ },
344
+ /**
345
+ * Represents a K8s Ingress resource.
346
+ * Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
347
+ * @see {@link https://kubernetes.io/docs/concepts/services-networking/ingress/}
348
+ */
349
+ V1Ingress: {
350
+ kind: "Ingress",
351
+ version: "v1",
352
+ group: "networking.k8s.io",
353
+ },
354
+ /**
355
+ * Represents a K8s NetworkPolicy resource.
356
+ * NetworkPolicy defines a set of rules for how pods communicate with each other.
357
+ * @see {@link https://kubernetes.io/docs/concepts/services-networking/network-policies/}
358
+ */
359
+ V1NetworkPolicy: {
360
+ kind: "NetworkPolicy",
361
+ version: "v1",
362
+ group: "networking.k8s.io",
363
+ },
364
+ /**
365
+ * Represents a K8s RuntimeClass resource.
366
+ * RuntimeClass is a cluster-scoped resource that surfaces container runtime properties to the control plane.
367
+ * @see {@link https://kubernetes.io/docs/concepts/containers/runtime-class/}
368
+ */
369
+ V1RuntimeClass: {
370
+ kind: "RuntimeClass",
371
+ version: "v1",
372
+ group: "node.k8s.io",
373
+ },
374
+ /**
375
+ * Represents a K8s PodDisruptionBudget resource.
376
+ * PodDisruptionBudget is an API object that limits the number of pods of a replicated application that are down simultaneously.
377
+ * @see {@link https://kubernetes.io/docs/concepts/workloads/pods/disruptions/}
378
+ */
379
+ V1PodDisruptionBudget: {
380
+ kind: "PodDisruptionBudget",
381
+ version: "v1",
382
+ group: "policy",
383
+ },
384
+ /**
385
+ * Represents a K8s VolumeAttachment resource.
386
+ * VolumeAttachment captures the intent to attach or detach the specified volume to/from the specified node.
387
+ * @see {@link https://kubernetes.io/docs/concepts/storage/storage-classes/}
388
+ */
389
+ V1VolumeAttachment: {
390
+ kind: "VolumeAttachment",
391
+ version: "v1",
392
+ group: "storage.k8s.io",
393
+ },
394
+ /**
395
+ * Represents a K8s CSIDriver resource.
396
+ * CSIDriver captures information about a Container Storage Interface (CSI) volume driver.
397
+ * @see {@link https://kubernetes.io/docs/concepts/storage/volumes/}
398
+ */
399
+ V1CSIDriver: {
400
+ kind: "CSIDriver",
401
+ version: "v1",
402
+ group: "storage.k8s.io",
403
+ },
404
+ /**
405
+ * Represents a K8s CSIStorageCapacity resource.
406
+ * CSIStorageCapacity stores the reported storage capacity of a CSI node or storage class.
407
+ * @see {@link https://kubernetes.io/docs/concepts/storage/csi/}
408
+ */
409
+ V1CSIStorageCapacity: {
410
+ kind: "CSIStorageCapacity",
411
+ version: "v1",
412
+ group: "storage.k8s.io",
413
+ },
414
+ /**
415
+ * Represents a K8s StorageClass resource.
416
+ * StorageClass is a cluster-scoped resource that provides a way for administrators to describe the classes of storage they offer.
417
+ * @see {@link https://kubernetes.io/docs/concepts/storage/storage-classes/}
418
+ */
419
+ V1StorageClass: {
420
+ kind: "StorageClass",
421
+ version: "v1",
422
+ group: "storage.k8s.io",
423
+ },
424
+ };
425
+ export function modelToGroupVersionKind(key) {
426
+ return gvkMap[key];
427
+ }
@@ -0,0 +1,17 @@
1
+ export interface TLSOut {
2
+ ca: string;
3
+ crt: string;
4
+ key: string;
5
+ pem: {
6
+ ca: string;
7
+ crt: string;
8
+ key: string;
9
+ };
10
+ }
11
+ /**
12
+ * Generates a self-signed CA and server certificate with Subject Alternative Names (SANs) for the K8s webhook.
13
+ *
14
+ * @param {string} name - The name to use for the server certificate's Common Name and SAN DNS entry.
15
+ * @returns {TLSOut} - An object containing the Base64-encoded CA, server certificate, and server private key.
16
+ */
17
+ export declare function genTLS(name: string): TLSOut;
@@ -0,0 +1,67 @@
1
+ import forge from "node-forge";
2
+ const caName = "Pepr Ephemeral CA";
3
+ /**
4
+ * Generates a self-signed CA and server certificate with Subject Alternative Names (SANs) for the K8s webhook.
5
+ *
6
+ * @param {string} name - The name to use for the server certificate's Common Name and SAN DNS entry.
7
+ * @returns {TLSOut} - An object containing the Base64-encoded CA, server certificate, and server private key.
8
+ */
9
+ export function genTLS(name) {
10
+ // Generate a new CA key pair and create a self-signed CA certificate
11
+ const caKeys = forge.pki.rsa.generateKeyPair(2048);
12
+ const caCert = genCert(caKeys, caName, [{ name: "commonName", value: caName }]);
13
+ caCert.setExtensions([
14
+ {
15
+ name: "basicConstraints",
16
+ cA: true,
17
+ },
18
+ {
19
+ name: "keyUsage",
20
+ keyCertSign: true,
21
+ digitalSignature: true,
22
+ nonRepudiation: true,
23
+ keyEncipherment: true,
24
+ dataEncipherment: true,
25
+ },
26
+ ]);
27
+ // Generate a new server key pair and create a server certificate signed by the CA
28
+ const serverKeys = forge.pki.rsa.generateKeyPair(2048);
29
+ const serverCert = genCert(serverKeys, name, caCert.subject.attributes);
30
+ // Sign both certificates with the CA private key
31
+ caCert.sign(caKeys.privateKey, forge.md.sha256.create());
32
+ serverCert.sign(caKeys.privateKey, forge.md.sha256.create());
33
+ // Convert the keys and certificates to PEM format
34
+ const pem = {
35
+ ca: forge.pki.certificateToPem(caCert),
36
+ crt: forge.pki.certificateToPem(serverCert),
37
+ key: forge.pki.privateKeyToPem(serverKeys.privateKey),
38
+ };
39
+ // Base64-encode the PEM strings
40
+ const ca = Buffer.from(pem.ca).toString("base64");
41
+ const key = Buffer.from(pem.key).toString("base64");
42
+ const crt = Buffer.from(pem.crt).toString("base64");
43
+ return { ca, key, crt, pem };
44
+ }
45
+ function genCert(key, name, issuer) {
46
+ const crt = forge.pki.createCertificate();
47
+ crt.publicKey = key.publicKey;
48
+ crt.serialNumber = "01";
49
+ crt.validity.notBefore = new Date();
50
+ crt.validity.notAfter = new Date();
51
+ crt.validity.notAfter.setFullYear(crt.validity.notBefore.getFullYear() + 1);
52
+ // Add SANs to the server certificate
53
+ crt.setExtensions([
54
+ {
55
+ name: "subjectAltName",
56
+ altNames: [
57
+ {
58
+ type: 2,
59
+ value: name,
60
+ },
61
+ ],
62
+ },
63
+ ]);
64
+ // Set the server certificate's issuer to the CA
65
+ crt.setIssuer(issuer);
66
+ return crt;
67
+ }
@@ -0,0 +1,136 @@
1
+ import { V1ListMeta, V1ObjectMeta } from "@kubernetes/client-node";
2
+ export declare enum Operation {
3
+ CREATE = "CREATE",
4
+ UPDATE = "UPDATE",
5
+ DELETE = "DELETE",
6
+ CONNECT = "CONNECT"
7
+ }
8
+ export interface KubernetesObject {
9
+ apiVersion?: string;
10
+ kind?: string;
11
+ metadata?: V1ObjectMeta;
12
+ }
13
+ export interface KubernetesListObject<T extends KubernetesObject> {
14
+ apiVersion?: string;
15
+ kind?: string;
16
+ metadata?: V1ListMeta;
17
+ items: T[];
18
+ }
19
+ /**
20
+ * GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
21
+ * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
22
+ **/
23
+ export interface GroupVersionKind {
24
+ /** The K8s resource kind, e..g "Pod". */
25
+ readonly kind: string;
26
+ readonly group: string;
27
+ readonly version?: string;
28
+ }
29
+ /**
30
+ * GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
31
+ * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
32
+ */
33
+ export interface GroupVersionResource {
34
+ readonly group: string;
35
+ readonly version: string;
36
+ readonly resource: string;
37
+ }
38
+ /**
39
+ * A Kubernetes admission request to be processed by a capability.
40
+ */
41
+ export interface Request<T = KubernetesObject> {
42
+ /** UID is an identifier for the individual request/response. */
43
+ readonly uid: string;
44
+ /** Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) */
45
+ readonly kind: GroupVersionKind;
46
+ /** Resource is the fully-qualified resource being requested (for example, v1.pods) */
47
+ readonly resource: GroupVersionResource;
48
+ /** SubResource is the subresource being requested, if any (for example, "status" or "scale") */
49
+ readonly subResource?: string;
50
+ /** RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). */
51
+ readonly requestKind?: GroupVersionKind;
52
+ /** RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). */
53
+ readonly requestResource?: GroupVersionResource;
54
+ /** RequestSubResource is the subresource of the original API request, if any (for example, "status" or "scale"). */
55
+ readonly requestSubResource?: string;
56
+ /**
57
+ * Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and
58
+ * rely on the server to generate the name. If that is the case, this method will return the empty string.
59
+ */
60
+ readonly name: string;
61
+ /** Namespace is the namespace associated with the request (if any). */
62
+ readonly namespace?: string;
63
+ /**
64
+ * Operation is the operation being performed. This may be different than the operation
65
+ * requested. e.g. a patch can result in either a CREATE or UPDATE Operation.
66
+ */
67
+ readonly operation: Operation;
68
+ /** UserInfo is information about the requesting user */
69
+ readonly userInfo: {
70
+ /** The name that uniquely identifies this user among all active users. */
71
+ username?: string;
72
+ /**
73
+ * A unique value that identifies this user across time. If this user is deleted
74
+ * and another user by the same name is added, they will have different UIDs.
75
+ */
76
+ uid?: string;
77
+ /** The names of groups this user is a part of. */
78
+ groups?: string[];
79
+ /** Any additional information provided by the authenticator. */
80
+ extra?: {
81
+ [key: string]: string[];
82
+ };
83
+ };
84
+ /** Object is the object from the incoming request prior to default values being applied */
85
+ readonly object: T;
86
+ /** OldObject is the existing object. Only populated for UPDATE requests. */
87
+ readonly oldObject?: T;
88
+ /** DryRun indicates that modifications will definitely not be persisted for this request. Defaults to false. */
89
+ readonly dryRun?: boolean;
90
+ /**
91
+ * Options contains the options for the operation being performed.
92
+ * e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be
93
+ * different than the options the caller provided. e.g. for a patch request the performed
94
+ * Operation might be a CREATE, in which case the Options will a
95
+ * `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`.
96
+ */
97
+ readonly options?: any;
98
+ }
99
+ export interface Response {
100
+ /** UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest. */
101
+ uid: string;
102
+ /** Allowed indicates whether or not the admission request was permitted. */
103
+ allowed: boolean;
104
+ /** Result contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
105
+ result?: string;
106
+ /** The patch body. Currently we only support "JSONPatch" which implements RFC 6902. */
107
+ patch?: string;
108
+ /** The type of Patch. Currently we only allow "JSONPatch". */
109
+ patchType?: "JSONPatch";
110
+ /** AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted). */
111
+ auditAnnotations?: {
112
+ [key: string]: string;
113
+ };
114
+ /** warnings is a list of warning messages to return to the requesting API client. */
115
+ warnings?: string[];
116
+ }
117
+ export type WebhookIgnore = {
118
+ /**
119
+ * List of Kubernetes namespaces to always ignore.
120
+ * Any resources in these namespaces will be ignored by Pepr.
121
+ *
122
+ * Note: `kube-system` and `pepr-system` are always ignored.
123
+ */
124
+ namespaces?: string[];
125
+ /**
126
+ * List of Kubernetes labels to always ignore.
127
+ * Any resources with these labels will be ignored by Pepr.
128
+ *
129
+ * The example below will ignore any resources with the label `my-label=ulta-secret`:
130
+ * ```
131
+ * alwaysIgnore:
132
+ * labels: [{ "my-label": "ultra-secret" }]
133
+ * ```
134
+ */
135
+ labels?: Record<string, string>[];
136
+ };
@@ -0,0 +1,9 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
+ export var Operation;
4
+ (function (Operation) {
5
+ Operation["CREATE"] = "CREATE";
6
+ Operation["UPDATE"] = "UPDATE";
7
+ Operation["DELETE"] = "DELETE";
8
+ Operation["CONNECT"] = "CONNECT";
9
+ })(Operation || (Operation = {}));
@@ -0,0 +1 @@
1
+ export { V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CSIStorageCapacity as CSIStorageCapacity, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node/dist";
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
+ export { V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CSIStorageCapacity as CSIStorageCapacity, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node/dist";