pepr 0.32.7 → 0.34.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.
Files changed (143) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -1
  3. package/dist/cli/banner.d.ts +2 -0
  4. package/dist/cli/banner.d.ts.map +1 -0
  5. package/dist/cli/build.d.ts +19 -0
  6. package/dist/cli/build.d.ts.map +1 -0
  7. package/dist/cli/deploy.d.ts +3 -0
  8. package/dist/cli/deploy.d.ts.map +1 -0
  9. package/dist/cli/dev.d.ts +3 -0
  10. package/dist/cli/dev.d.ts.map +1 -0
  11. package/dist/cli/format.d.ts +9 -0
  12. package/dist/cli/format.d.ts.map +1 -0
  13. package/dist/cli/init/index.d.ts +3 -0
  14. package/dist/cli/init/index.d.ts.map +1 -0
  15. package/dist/cli/init/templates.d.ts +196 -0
  16. package/dist/cli/init/templates.d.ts.map +1 -0
  17. package/dist/cli/init/utils.d.ts +21 -0
  18. package/dist/cli/init/utils.d.ts.map +1 -0
  19. package/dist/cli/init/utils.test.d.ts +2 -0
  20. package/dist/cli/init/utils.test.d.ts.map +1 -0
  21. package/dist/cli/init/walkthrough.d.ts +8 -0
  22. package/dist/cli/init/walkthrough.d.ts.map +1 -0
  23. package/dist/cli/init/walkthrough.test.d.ts +2 -0
  24. package/dist/cli/init/walkthrough.test.d.ts.map +1 -0
  25. package/dist/cli/kfc.d.ts +3 -0
  26. package/dist/cli/kfc.d.ts.map +1 -0
  27. package/dist/cli/monitor.d.ts +3 -0
  28. package/dist/cli/monitor.d.ts.map +1 -0
  29. package/dist/cli/root.d.ts +5 -0
  30. package/dist/cli/root.d.ts.map +1 -0
  31. package/dist/cli/update.d.ts +3 -0
  32. package/dist/cli/update.d.ts.map +1 -0
  33. package/dist/cli/uuid.d.ts +3 -0
  34. package/dist/cli/uuid.d.ts.map +1 -0
  35. package/dist/cli.js +66 -25
  36. package/dist/controller.js +1 -1
  37. package/dist/fixtures/loader.d.ts +5 -0
  38. package/dist/fixtures/loader.d.ts.map +1 -0
  39. package/dist/lib/assets/helm.d.ts +1 -0
  40. package/dist/lib/assets/helm.d.ts.map +1 -1
  41. package/dist/lib/assets/helm.test.d.ts +2 -0
  42. package/dist/lib/assets/helm.test.d.ts.map +1 -0
  43. package/dist/lib/assets/index.d.ts.map +1 -1
  44. package/dist/lib/assets/pods.d.ts +3 -0
  45. package/dist/lib/assets/pods.d.ts.map +1 -1
  46. package/dist/lib/assets/pods.test.d.ts +2 -0
  47. package/dist/lib/assets/pods.test.d.ts.map +1 -0
  48. package/dist/lib/assets/yaml.d.ts.map +1 -1
  49. package/dist/lib/controller/store.d.ts.map +1 -1
  50. package/dist/lib/errors.test.d.ts +2 -0
  51. package/dist/lib/errors.test.d.ts.map +1 -0
  52. package/dist/lib/filter.test.d.ts +2 -0
  53. package/dist/lib/filter.test.d.ts.map +1 -0
  54. package/dist/lib/helpers.test.d.ts +2 -0
  55. package/dist/lib/helpers.test.d.ts.map +1 -0
  56. package/dist/lib/included-files.test.d.ts +2 -0
  57. package/dist/lib/included-files.test.d.ts.map +1 -0
  58. package/dist/lib/logger.test.d.ts +2 -0
  59. package/dist/lib/logger.test.d.ts.map +1 -0
  60. package/dist/lib/metrics.d.ts +18 -0
  61. package/dist/lib/metrics.d.ts.map +1 -1
  62. package/dist/lib/metrics.test.d.ts +2 -0
  63. package/dist/lib/metrics.test.d.ts.map +1 -0
  64. package/dist/lib/module.test.d.ts +2 -0
  65. package/dist/lib/module.test.d.ts.map +1 -0
  66. package/dist/lib/mutate-request.test.d.ts +2 -0
  67. package/dist/lib/mutate-request.test.d.ts.map +1 -0
  68. package/dist/lib/queue.test.d.ts +2 -0
  69. package/dist/lib/queue.test.d.ts.map +1 -0
  70. package/dist/lib/schedule.test.d.ts +15 -0
  71. package/dist/lib/schedule.test.d.ts.map +1 -0
  72. package/dist/lib/storage.d.ts +2 -0
  73. package/dist/lib/storage.d.ts.map +1 -1
  74. package/dist/lib/storage.test.d.ts +2 -0
  75. package/dist/lib/storage.test.d.ts.map +1 -0
  76. package/dist/lib/tls.test.d.ts +2 -0
  77. package/dist/lib/tls.test.d.ts.map +1 -0
  78. package/dist/lib/utils.test.d.ts +2 -0
  79. package/dist/lib/utils.test.d.ts.map +1 -0
  80. package/dist/lib/validate-request.test.d.ts +2 -0
  81. package/dist/lib/validate-request.test.d.ts.map +1 -0
  82. package/dist/lib/watch-processor.d.ts.map +1 -1
  83. package/dist/lib/watch-processor.test.d.ts +2 -0
  84. package/dist/lib/watch-processor.test.d.ts.map +1 -0
  85. package/dist/lib.js +142 -20
  86. package/dist/lib.js.map +3 -3
  87. package/dist/sdk/sdk.test.d.ts +2 -0
  88. package/dist/sdk/sdk.test.d.ts.map +1 -0
  89. package/package.json +26 -17
  90. package/src/cli/banner.ts +63 -0
  91. package/src/cli/build.ts +370 -0
  92. package/src/cli/deploy.ts +105 -0
  93. package/src/cli/dev.ts +118 -0
  94. package/src/cli/format.ts +83 -0
  95. package/src/cli/init/index.ts +99 -0
  96. package/src/cli/init/templates.ts +124 -0
  97. package/src/cli/init/utils.test.ts +28 -0
  98. package/src/cli/init/utils.ts +55 -0
  99. package/src/cli/init/walkthrough.test.ts +21 -0
  100. package/src/cli/init/walkthrough.ts +96 -0
  101. package/src/cli/kfc.ts +45 -0
  102. package/src/cli/monitor.ts +101 -0
  103. package/src/cli/root.ts +12 -0
  104. package/src/cli/update.ts +95 -0
  105. package/src/cli/uuid.ts +44 -0
  106. package/src/fixtures/data/create-pod.json +271 -0
  107. package/src/fixtures/data/delete-pod.json +271 -0
  108. package/src/fixtures/loader.ts +18 -0
  109. package/src/lib/.prettierrc +14 -0
  110. package/src/lib/assets/helm.test.ts +64 -0
  111. package/src/lib/assets/helm.ts +35 -0
  112. package/src/lib/assets/index.ts +5 -1
  113. package/src/lib/assets/pods.test.ts +553 -0
  114. package/src/lib/assets/pods.ts +14 -6
  115. package/src/lib/assets/yaml.ts +15 -18
  116. package/src/lib/controller/index.ts +2 -2
  117. package/src/lib/controller/store.ts +88 -2
  118. package/src/lib/errors.test.ts +85 -0
  119. package/src/lib/filter.test.ts +384 -0
  120. package/src/lib/helpers.test.ts +1192 -0
  121. package/src/lib/included-files.test.ts +22 -0
  122. package/src/lib/logger.test.ts +18 -0
  123. package/src/lib/metrics.test.ts +132 -0
  124. package/src/lib/metrics.ts +68 -6
  125. package/src/lib/module.test.ts +126 -0
  126. package/src/lib/mutate-request.test.ts +188 -0
  127. package/src/lib/queue.test.ts +58 -0
  128. package/src/lib/schedule.test.ts +217 -0
  129. package/src/lib/storage.test.ts +203 -0
  130. package/src/lib/storage.ts +22 -9
  131. package/src/lib/tls.test.ts +18 -0
  132. package/src/lib/utils.test.ts +69 -0
  133. package/src/lib/validate-request.test.ts +124 -0
  134. package/src/lib/watch-processor.test.ts +322 -0
  135. package/src/lib/watch-processor.ts +20 -4
  136. package/src/sdk/sdk.test.ts +243 -0
  137. package/src/templates/.eslintrc.json +6 -0
  138. package/.prettierignore +0 -1
  139. package/CODE_OF_CONDUCT.md +0 -133
  140. package/SECURITY.md +0 -18
  141. package/SUPPORT.md +0 -16
  142. package/codecov.yaml +0 -19
  143. package/commitlint.config.js +0 -1
@@ -0,0 +1,44 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
+
4
+ import { KubernetesListObject } from "@kubernetes/client-node";
5
+ import { K8s, kind } from "kubernetes-fluent-client";
6
+ import { RootCmd } from "./root";
7
+
8
+ export default function (program: RootCmd) {
9
+ program
10
+ .command("uuid [uuid]")
11
+ .description("Module UUID(s) currently deployed in the cluster")
12
+ .action(async uuid => {
13
+ const uuidTable: Record<string, string> = {};
14
+ let deployments: KubernetesListObject<kind.Deployment>;
15
+
16
+ if (!uuid) {
17
+ deployments = await K8s(kind.Deployment)
18
+ .InNamespace("pepr-system")
19
+ .WithLabel("pepr.dev/uuid")
20
+ .Get();
21
+ } else {
22
+ deployments = await K8s(kind.Deployment)
23
+ .InNamespace("pepr-system")
24
+ .WithLabel("pepr.dev/uuid", uuid)
25
+ .Get();
26
+ }
27
+
28
+ // Populate the uuidTable with the UUID and description
29
+ deployments.items.map(deploy => {
30
+ const uuid = deploy.metadata?.labels?.["pepr.dev/uuid"] || "";
31
+ const description = deploy.metadata?.annotations?.["pepr.dev/description"] || "";
32
+ if (uuid !== "") {
33
+ uuidTable[uuid] = description;
34
+ }
35
+ });
36
+
37
+ console.log("UUID\t\tDescription");
38
+ console.log("--------------------------------------------");
39
+
40
+ Object.entries(uuidTable).forEach(([uuid, description]) => {
41
+ console.log(`${uuid}\t${description}`);
42
+ });
43
+ });
44
+ }
@@ -0,0 +1,271 @@
1
+ {
2
+ "uid": "af5c3d45-72b8-11eb-a3a3-0242ac130003",
3
+ "kind": {
4
+ "group": "",
5
+ "version": "v1",
6
+ "kind": "Pod"
7
+ },
8
+ "resource": {
9
+ "group": "",
10
+ "version": "v1",
11
+ "resource": "pods"
12
+ },
13
+ "subResource": "",
14
+ "name": "podinfo",
15
+ "namespace": "default",
16
+ "operation": "Create",
17
+ "userInfo": {
18
+ "username": "system:serviceaccount:kube-system:replicaset-controller",
19
+ "uid": "95c8f0ca-d31a-4d3f-9f27-9a2a2661ab3c",
20
+ "groups": [
21
+ "system:serviceaccounts",
22
+ "system:serviceaccounts:kube-system",
23
+ "system:authenticated"
24
+ ]
25
+ },
26
+ "oldObject": {},
27
+ "dryRun": false,
28
+ "options": null,
29
+ "object": {
30
+ "apiVersion": "v1",
31
+ "kind": "Pod",
32
+ "metadata": {
33
+ "annotations": {
34
+ "prometheus.io/port": "9898",
35
+ "prometheus.io/scrape": "true"
36
+ },
37
+ "creationTimestamp": "2023-03-07T07:48:13Z",
38
+ "generateName": "cool-name-podinfo-66bbff7cf4-",
39
+ "labels": {
40
+ "app.kubernetes.io/name": "cool-name-podinfo",
41
+ "pod-template-hash": "66bbff7cf4",
42
+ "zarf-agent": "patched"
43
+ },
44
+ "name": "cool-name-podinfo-66bbff7cf4-fwhl2",
45
+ "namespace": "helm-releasename",
46
+ "ownerReferences": [
47
+ {
48
+ "apiVersion": "apps/v1",
49
+ "blockOwnerDeletion": true,
50
+ "controller": true,
51
+ "kind": "ReplicaSet",
52
+ "name": "cool-name-podinfo-66bbff7cf4",
53
+ "uid": "41d30484-6ccd-462b-b96a-e166095e3681"
54
+ }
55
+ ],
56
+ "resourceVersion": "46512",
57
+ "uid": "883303bc-e4b7-4fa8-a576-575cc4407201"
58
+ },
59
+ "spec": {
60
+ "containers": [
61
+ {
62
+ "command": [
63
+ "./podinfo",
64
+ "--port=9898",
65
+ "--cert-path=/data/cert",
66
+ "--port-metrics=9797",
67
+ "--grpc-port=9999",
68
+ "--grpc-service-name=podinfo",
69
+ "--level=info",
70
+ "--random-delay=false",
71
+ "--random-error=false"
72
+ ],
73
+ "env": [
74
+ {
75
+ "name": "PODINFO_UI_COLOR",
76
+ "value": "#34577c"
77
+ }
78
+ ],
79
+ "image": "127.0.0.1:31999/stefanprodan/podinfo-2985051089:6.1.6",
80
+ "imagePullPolicy": "IfNotPresent",
81
+ "livenessProbe": {
82
+ "exec": {
83
+ "command": ["podcli", "check", "http", "localhost:9898/healthz"]
84
+ },
85
+ "failureThreshold": 3,
86
+ "initialDelaySeconds": 1,
87
+ "periodSeconds": 10,
88
+ "successThreshold": 1,
89
+ "timeoutSeconds": 5
90
+ },
91
+ "name": "podinfo",
92
+ "ports": [
93
+ {
94
+ "containerPort": 9898,
95
+ "name": "http",
96
+ "protocol": "TCP"
97
+ },
98
+ {
99
+ "containerPort": 9797,
100
+ "name": "http-metrics",
101
+ "protocol": "TCP"
102
+ },
103
+ {
104
+ "containerPort": 9999,
105
+ "name": "grpc",
106
+ "protocol": "TCP"
107
+ }
108
+ ],
109
+ "readinessProbe": {
110
+ "exec": {
111
+ "command": ["podcli", "check", "http", "localhost:9898/readyz"]
112
+ },
113
+ "failureThreshold": 3,
114
+ "initialDelaySeconds": 1,
115
+ "periodSeconds": 10,
116
+ "successThreshold": 1,
117
+ "timeoutSeconds": 5
118
+ },
119
+ "resources": {
120
+ "requests": {
121
+ "cpu": "1m",
122
+ "memory": "16Mi"
123
+ }
124
+ },
125
+ "terminationMessagePath": "/dev/termination-log",
126
+ "terminationMessagePolicy": "File",
127
+ "volumeMounts": [
128
+ {
129
+ "mountPath": "/data",
130
+ "name": "data"
131
+ },
132
+ {
133
+ "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
134
+ "name": "kube-api-access-vn9dc",
135
+ "readOnly": true
136
+ }
137
+ ]
138
+ }
139
+ ],
140
+ "dnsPolicy": "ClusterFirst",
141
+ "enableServiceLinks": true,
142
+ "imagePullSecrets": [
143
+ {
144
+ "name": "private-registry"
145
+ }
146
+ ],
147
+ "nodeName": "k3d-k3s-default-server-0",
148
+ "preemptionPolicy": "PreemptLowerPriority",
149
+ "priority": 0,
150
+ "restartPolicy": "Always",
151
+ "schedulerName": "default-scheduler",
152
+ "securityContext": {},
153
+ "serviceAccount": "default",
154
+ "serviceAccountName": "default",
155
+ "terminationGracePeriodSeconds": 30,
156
+ "tolerations": [
157
+ {
158
+ "effect": "NoExecute",
159
+ "key": "node.kubernetes.io/not-ready",
160
+ "operator": "Exists",
161
+ "tolerationSeconds": 300
162
+ },
163
+ {
164
+ "effect": "NoExecute",
165
+ "key": "node.kubernetes.io/unreachable",
166
+ "operator": "Exists",
167
+ "tolerationSeconds": 300
168
+ }
169
+ ],
170
+ "volumes": [
171
+ {
172
+ "emptyDir": {},
173
+ "name": "data"
174
+ },
175
+ {
176
+ "name": "kube-api-access-vn9dc",
177
+ "projected": {
178
+ "defaultMode": 420,
179
+ "sources": [
180
+ {
181
+ "serviceAccountToken": {
182
+ "expirationSeconds": 3607,
183
+ "path": "token"
184
+ }
185
+ },
186
+ {
187
+ "configMap": {
188
+ "items": [
189
+ {
190
+ "key": "ca.crt",
191
+ "path": "ca.crt"
192
+ }
193
+ ],
194
+ "name": "kube-root-ca.crt"
195
+ }
196
+ },
197
+ {
198
+ "downwardAPI": {
199
+ "items": [
200
+ {
201
+ "fieldRef": {
202
+ "apiVersion": "v1",
203
+ "fieldPath": "metadata.namespace"
204
+ },
205
+ "path": "namespace"
206
+ }
207
+ ]
208
+ }
209
+ }
210
+ ]
211
+ }
212
+ }
213
+ ]
214
+ },
215
+ "status": {
216
+ "conditions": [
217
+ {
218
+ "lastProbeTime": null,
219
+ "lastTransitionTime": "2023-03-07T07:48:13Z",
220
+ "status": "True",
221
+ "type": "Initialized"
222
+ },
223
+ {
224
+ "lastProbeTime": null,
225
+ "lastTransitionTime": "2023-03-07T07:48:16Z",
226
+ "status": "True",
227
+ "type": "Ready"
228
+ },
229
+ {
230
+ "lastProbeTime": null,
231
+ "lastTransitionTime": "2023-03-07T07:48:16Z",
232
+ "status": "True",
233
+ "type": "ContainersReady"
234
+ },
235
+ {
236
+ "lastProbeTime": null,
237
+ "lastTransitionTime": "2023-03-07T07:48:13Z",
238
+ "status": "True",
239
+ "type": "PodScheduled"
240
+ }
241
+ ],
242
+ "containerStatuses": [
243
+ {
244
+ "containerID": "containerd://81b20dafbf2498a52c8ab46fa1e95ce25c06271684e590a377ee4ac9fd2a85ee",
245
+ "image": "127.0.0.1:31999/stefanprodan/podinfo-2985051089:6.1.6",
246
+ "imageID": "127.0.0.1:31999/stefanprodan/podinfo-2985051089@sha256:1f1fb2d1bfadac8a487106ea62b2b582bedc83fe17b3332dffe9151dfc820742",
247
+ "lastState": {},
248
+ "name": "podinfo",
249
+ "ready": true,
250
+ "restartCount": 0,
251
+ "started": true,
252
+ "state": {
253
+ "running": {
254
+ "startedAt": "2023-03-07T07:48:14Z"
255
+ }
256
+ }
257
+ }
258
+ ],
259
+ "hostIP": "172.19.0.3",
260
+ "phase": "Running",
261
+ "podIP": "10.42.0.26",
262
+ "podIPs": [
263
+ {
264
+ "ip": "10.42.0.26"
265
+ }
266
+ ],
267
+ "qosClass": "Burstable",
268
+ "startTime": "2023-03-07T07:48:13Z"
269
+ }
270
+ }
271
+ }
@@ -0,0 +1,271 @@
1
+ {
2
+ "uid": "af5c3d45-72b8-11eb-a3a3-0242ac130003",
3
+ "kind": {
4
+ "group": "",
5
+ "version": "v1",
6
+ "kind": "Pod"
7
+ },
8
+ "resource": {
9
+ "group": "",
10
+ "version": "v1",
11
+ "resource": "pods"
12
+ },
13
+ "subResource": "",
14
+ "name": "podinfo",
15
+ "namespace": "default",
16
+ "operation": "Delete",
17
+ "userInfo": {
18
+ "username": "system:serviceaccount:kube-system:replicaset-controller",
19
+ "uid": "95c8f0ca-d31a-4d3f-9f27-9a2a2661ab3c",
20
+ "groups": [
21
+ "system:serviceaccounts",
22
+ "system:serviceaccounts:kube-system",
23
+ "system:authenticated"
24
+ ]
25
+ },
26
+ "oldObject": {
27
+ "apiVersion": "v1",
28
+ "kind": "Pod",
29
+ "metadata": {
30
+ "annotations": {
31
+ "prometheus.io/port": "9898",
32
+ "prometheus.io/scrape": "true"
33
+ },
34
+ "creationTimestamp": "2023-03-07T07:48:13Z",
35
+ "generateName": "cool-name-podinfo-66bbff7cf4-",
36
+ "labels": {
37
+ "app.kubernetes.io/name": "cool-name-podinfo",
38
+ "pod-template-hash": "66bbff7cf4",
39
+ "zarf-agent": "patched"
40
+ },
41
+ "name": "cool-name-podinfo-66bbff7cf4-fwhl2",
42
+ "namespace": "helm-releasename",
43
+ "ownerReferences": [
44
+ {
45
+ "apiVersion": "apps/v1",
46
+ "blockOwnerDeletion": true,
47
+ "controller": true,
48
+ "kind": "ReplicaSet",
49
+ "name": "cool-name-podinfo-66bbff7cf4",
50
+ "uid": "41d30484-6ccd-462b-b96a-e166095e3681"
51
+ }
52
+ ],
53
+ "resourceVersion": "46512",
54
+ "uid": "883303bc-e4b7-4fa8-a576-575cc4407201"
55
+ },
56
+ "spec": {
57
+ "containers": [
58
+ {
59
+ "command": [
60
+ "./podinfo",
61
+ "--port=9898",
62
+ "--cert-path=/data/cert",
63
+ "--port-metrics=9797",
64
+ "--grpc-port=9999",
65
+ "--grpc-service-name=podinfo",
66
+ "--level=info",
67
+ "--random-delay=false",
68
+ "--random-error=false"
69
+ ],
70
+ "env": [
71
+ {
72
+ "name": "PODINFO_UI_COLOR",
73
+ "value": "#34577c"
74
+ }
75
+ ],
76
+ "image": "127.0.0.1:31999/stefanprodan/podinfo-2985051089:6.1.6",
77
+ "imagePullPolicy": "IfNotPresent",
78
+ "livenessProbe": {
79
+ "exec": {
80
+ "command": ["podcli", "check", "http", "localhost:9898/healthz"]
81
+ },
82
+ "failureThreshold": 3,
83
+ "initialDelaySeconds": 1,
84
+ "periodSeconds": 10,
85
+ "successThreshold": 1,
86
+ "timeoutSeconds": 5
87
+ },
88
+ "name": "podinfo",
89
+ "ports": [
90
+ {
91
+ "containerPort": 9898,
92
+ "name": "http",
93
+ "protocol": "TCP"
94
+ },
95
+ {
96
+ "containerPort": 9797,
97
+ "name": "http-metrics",
98
+ "protocol": "TCP"
99
+ },
100
+ {
101
+ "containerPort": 9999,
102
+ "name": "grpc",
103
+ "protocol": "TCP"
104
+ }
105
+ ],
106
+ "readinessProbe": {
107
+ "exec": {
108
+ "command": ["podcli", "check", "http", "localhost:9898/readyz"]
109
+ },
110
+ "failureThreshold": 3,
111
+ "initialDelaySeconds": 1,
112
+ "periodSeconds": 10,
113
+ "successThreshold": 1,
114
+ "timeoutSeconds": 5
115
+ },
116
+ "resources": {
117
+ "requests": {
118
+ "cpu": "1m",
119
+ "memory": "16Mi"
120
+ }
121
+ },
122
+ "terminationMessagePath": "/dev/termination-log",
123
+ "terminationMessagePolicy": "File",
124
+ "volumeMounts": [
125
+ {
126
+ "mountPath": "/data",
127
+ "name": "data"
128
+ },
129
+ {
130
+ "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
131
+ "name": "kube-api-access-vn9dc",
132
+ "readOnly": true
133
+ }
134
+ ]
135
+ }
136
+ ],
137
+ "dnsPolicy": "ClusterFirst",
138
+ "enableServiceLinks": true,
139
+ "imagePullSecrets": [
140
+ {
141
+ "name": "private-registry"
142
+ }
143
+ ],
144
+ "nodeName": "k3d-k3s-default-server-0",
145
+ "preemptionPolicy": "PreemptLowerPriority",
146
+ "priority": 0,
147
+ "restartPolicy": "Always",
148
+ "schedulerName": "default-scheduler",
149
+ "securityContext": {},
150
+ "serviceAccount": "default",
151
+ "serviceAccountName": "default",
152
+ "terminationGracePeriodSeconds": 30,
153
+ "tolerations": [
154
+ {
155
+ "effect": "NoExecute",
156
+ "key": "node.kubernetes.io/not-ready",
157
+ "operator": "Exists",
158
+ "tolerationSeconds": 300
159
+ },
160
+ {
161
+ "effect": "NoExecute",
162
+ "key": "node.kubernetes.io/unreachable",
163
+ "operator": "Exists",
164
+ "tolerationSeconds": 300
165
+ }
166
+ ],
167
+ "volumes": [
168
+ {
169
+ "emptyDir": {},
170
+ "name": "data"
171
+ },
172
+ {
173
+ "name": "kube-api-access-vn9dc",
174
+ "projected": {
175
+ "defaultMode": 420,
176
+ "sources": [
177
+ {
178
+ "serviceAccountToken": {
179
+ "expirationSeconds": 3607,
180
+ "path": "token"
181
+ }
182
+ },
183
+ {
184
+ "configMap": {
185
+ "items": [
186
+ {
187
+ "key": "ca.crt",
188
+ "path": "ca.crt"
189
+ }
190
+ ],
191
+ "name": "kube-root-ca.crt"
192
+ }
193
+ },
194
+ {
195
+ "downwardAPI": {
196
+ "items": [
197
+ {
198
+ "fieldRef": {
199
+ "apiVersion": "v1",
200
+ "fieldPath": "metadata.namespace"
201
+ },
202
+ "path": "namespace"
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ ]
208
+ }
209
+ }
210
+ ]
211
+ },
212
+ "status": {
213
+ "conditions": [
214
+ {
215
+ "lastProbeTime": null,
216
+ "lastTransitionTime": "2023-03-07T07:48:13Z",
217
+ "status": "True",
218
+ "type": "Initialized"
219
+ },
220
+ {
221
+ "lastProbeTime": null,
222
+ "lastTransitionTime": "2023-03-07T07:48:16Z",
223
+ "status": "True",
224
+ "type": "Ready"
225
+ },
226
+ {
227
+ "lastProbeTime": null,
228
+ "lastTransitionTime": "2023-03-07T07:48:16Z",
229
+ "status": "True",
230
+ "type": "ContainersReady"
231
+ },
232
+ {
233
+ "lastProbeTime": null,
234
+ "lastTransitionTime": "2023-03-07T07:48:13Z",
235
+ "status": "True",
236
+ "type": "PodScheduled"
237
+ }
238
+ ],
239
+ "containerStatuses": [
240
+ {
241
+ "containerID": "containerd://81b20dafbf2498a52c8ab46fa1e95ce25c06271684e590a377ee4ac9fd2a85ee",
242
+ "image": "127.0.0.1:31999/stefanprodan/podinfo-2985051089:6.1.6",
243
+ "imageID": "127.0.0.1:31999/stefanprodan/podinfo-2985051089@sha256:1f1fb2d1bfadac8a487106ea62b2b582bedc83fe17b3332dffe9151dfc820742",
244
+ "lastState": {},
245
+ "name": "podinfo",
246
+ "ready": true,
247
+ "restartCount": 0,
248
+ "started": true,
249
+ "state": {
250
+ "running": {
251
+ "startedAt": "2023-03-07T07:48:14Z"
252
+ }
253
+ }
254
+ }
255
+ ],
256
+ "hostIP": "172.19.0.3",
257
+ "phase": "Running",
258
+ "podIP": "10.42.0.26",
259
+ "podIPs": [
260
+ {
261
+ "ip": "10.42.0.26"
262
+ }
263
+ ],
264
+ "qosClass": "Burstable",
265
+ "startTime": "2023-03-07T07:48:13Z"
266
+ }
267
+ },
268
+ "dryRun": false,
269
+ "options": null,
270
+ "object": null
271
+ }
@@ -0,0 +1,18 @@
1
+ import { kind } from "kubernetes-fluent-client";
2
+
3
+ import { AdmissionRequest } from "../lib/k8s";
4
+ import createPod from "./data/create-pod.json";
5
+ import deletePod from "./data/delete-pod.json";
6
+
7
+ export function CreatePod() {
8
+ return cloneObject<kind.Pod>(createPod);
9
+ }
10
+
11
+ export function DeletePod() {
12
+ return cloneObject<kind.Pod>(deletePod);
13
+ }
14
+
15
+ function cloneObject<T>(obj: unknown): AdmissionRequest<T> {
16
+ // JSON to avoid funky typescript silliness on jsonmodules
17
+ return JSON.parse(JSON.stringify(obj)) as AdmissionRequest<T>;
18
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSameLine": false,
4
+ "bracketSpacing": true,
5
+ "embeddedLanguageFormatting": "auto",
6
+ "insertPragma": false,
7
+ "printWidth": 120,
8
+ "quoteProps": "as-needed",
9
+ "requirePragma": false,
10
+ "semi": true,
11
+ "useTabs": false,
12
+ "vueIndentScriptAndStyle": false,
13
+ "tabWidth": 2
14
+ }
@@ -0,0 +1,64 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
+
4
+ import { nsTemplate, chartYaml, watcherDeployTemplate, admissionDeployTemplate, serviceMonitorTemplate } from "./helm";
5
+ import { expect, describe, test } from "@jest/globals";
6
+ describe("Kubernetes Template Generators", () => {
7
+ describe("nsTemplate", () => {
8
+ test("should generate a Namespace template correctly", () => {
9
+ const result = nsTemplate();
10
+ expect(result).toContain("apiVersion: v1");
11
+ expect(result).toContain("kind: Namespace");
12
+ expect(result).toContain("name: pepr-system");
13
+ });
14
+ });
15
+
16
+ describe("chartYaml", () => {
17
+ test("should generate a Chart.yaml content correctly", () => {
18
+ const name = "test-app";
19
+ const description = "A test application";
20
+ const result = chartYaml(name, description);
21
+ expect(result).toContain("apiVersion: v2");
22
+ expect(result).toContain(`name: ${name}`);
23
+ expect(result).toContain(`description: ${description}`);
24
+ });
25
+ });
26
+
27
+ describe("watcherDeployTemplate", () => {
28
+ test("should generate a Deployment template for the watcher correctly", () => {
29
+ const result = watcherDeployTemplate(`${Date.now()}`);
30
+ expect(result).toContain("apiVersion: apps/v1");
31
+ expect(result).toContain("kind: Deployment");
32
+ expect(result).toContain("name: {{ .Values.uuid }}-watcher");
33
+ });
34
+ });
35
+
36
+ describe("admissionDeployTemplate", () => {
37
+ test("should generate a Deployment template for the admission controller correctly", () => {
38
+ const result = admissionDeployTemplate(`${Date.now()}`);
39
+ expect(result).toContain("apiVersion: apps/v1");
40
+ expect(result).toContain("kind: Deployment");
41
+ expect(result).toContain("name: {{ .Values.uuid }}");
42
+ });
43
+ });
44
+
45
+ describe("admissionServiceMonitor", () => {
46
+ test("should generate a Service Monitor template for the admission controller correctly", () => {
47
+ const result = serviceMonitorTemplate("admission");
48
+ expect(result).toContain("apiVersion: monitoring.coreos.com/v1");
49
+ expect(result).toContain("kind: ServiceMonitor");
50
+ expect(result).toContain("name: admission");
51
+ expect(result).toContain("pepr.dev/controller: admission");
52
+ });
53
+ });
54
+
55
+ describe("watcherServiceMonitor", () => {
56
+ test("should generate a Service Monitor template for the watcher controller correctly", () => {
57
+ const result = serviceMonitorTemplate("watcher");
58
+ expect(result).toContain("apiVersion: monitoring.coreos.com/v1");
59
+ expect(result).toContain("kind: ServiceMonitor");
60
+ expect(result).toContain("name: watcher");
61
+ expect(result).toContain("pepr.dev/controller: watcher");
62
+ });
63
+ });
64
+ });