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,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const ava_1 = __importDefault(require("ava"));
|
|
9
|
+
const _1 = require(".");
|
|
10
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1APIService'", t => {
|
|
11
|
+
const { name } = _1.a.APIService;
|
|
12
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
13
|
+
t.is(gvk.group, "apiregistration.k8s.io");
|
|
14
|
+
t.is(gvk.version, "v1");
|
|
15
|
+
t.is(gvk.kind, "APIService");
|
|
16
|
+
});
|
|
17
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1CertificateSigningRequest'", t => {
|
|
18
|
+
const { name } = _1.a.CertificateSigningRequest;
|
|
19
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
20
|
+
t.is(gvk.group, "certificates.k8s.io");
|
|
21
|
+
t.is(gvk.version, "v1");
|
|
22
|
+
t.is(gvk.kind, "CertificateSigningRequest");
|
|
23
|
+
});
|
|
24
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ConfigMap'", t => {
|
|
25
|
+
const { name } = _1.a.ConfigMap;
|
|
26
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
27
|
+
t.is(gvk.group, "");
|
|
28
|
+
t.is(gvk.version, "v1");
|
|
29
|
+
t.is(gvk.kind, "ConfigMap");
|
|
30
|
+
});
|
|
31
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ControllerRevision'", t => {
|
|
32
|
+
const { name } = _1.a.ControllerRevision;
|
|
33
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
34
|
+
t.is(gvk.group, "apps");
|
|
35
|
+
t.is(gvk.version, "v1");
|
|
36
|
+
t.is(gvk.kind, "ControllerRevision");
|
|
37
|
+
});
|
|
38
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1CronJob'", t => {
|
|
39
|
+
const { name } = _1.a.CronJob;
|
|
40
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
41
|
+
t.is(gvk.group, "batch");
|
|
42
|
+
t.is(gvk.version, "v1");
|
|
43
|
+
t.is(gvk.kind, "CronJob");
|
|
44
|
+
});
|
|
45
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1CSIDriver'", t => {
|
|
46
|
+
const { name } = _1.a.CSIDriver;
|
|
47
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
48
|
+
t.is(gvk.group, "storage.k8s.io");
|
|
49
|
+
t.is(gvk.version, "v1");
|
|
50
|
+
t.is(gvk.kind, "CSIDriver");
|
|
51
|
+
});
|
|
52
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1CSIStorageCapacity'", t => {
|
|
53
|
+
const { name } = _1.a.CSIStorageCapacity;
|
|
54
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
55
|
+
t.is(gvk.group, "storage.k8s.io");
|
|
56
|
+
t.is(gvk.version, "v1");
|
|
57
|
+
t.is(gvk.kind, "CSIStorageCapacity");
|
|
58
|
+
});
|
|
59
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1CustomResourceDefinition'", t => {
|
|
60
|
+
const { name } = _1.a.CustomResourceDefinition;
|
|
61
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
62
|
+
t.is(gvk.group, "apiextensions.k8s.io");
|
|
63
|
+
t.is(gvk.version, "v1");
|
|
64
|
+
t.is(gvk.kind, "CustomResourceDefinition");
|
|
65
|
+
});
|
|
66
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1DaemonSet'", t => {
|
|
67
|
+
const { name } = _1.a.DaemonSet;
|
|
68
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
69
|
+
t.is(gvk.group, "apps");
|
|
70
|
+
t.is(gvk.version, "v1");
|
|
71
|
+
t.is(gvk.kind, "DaemonSet");
|
|
72
|
+
});
|
|
73
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Deployment'", t => {
|
|
74
|
+
const { name } = _1.a.Deployment;
|
|
75
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
76
|
+
t.is(gvk.group, "apps");
|
|
77
|
+
t.is(gvk.version, "v1");
|
|
78
|
+
t.is(gvk.kind, "Deployment");
|
|
79
|
+
});
|
|
80
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1EndpointSlice'", t => {
|
|
81
|
+
const { name } = _1.a.EndpointSlice;
|
|
82
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
83
|
+
t.is(gvk.group, "discovery.k8s.io");
|
|
84
|
+
t.is(gvk.version, "v1");
|
|
85
|
+
t.is(gvk.kind, "EndpointSlice");
|
|
86
|
+
});
|
|
87
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1HorizontalPodAutoscaler'", t => {
|
|
88
|
+
const { name } = _1.a.HorizontalPodAutoscaler;
|
|
89
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
90
|
+
t.is(gvk.group, "autoscaling");
|
|
91
|
+
t.is(gvk.version, "v2");
|
|
92
|
+
t.is(gvk.kind, "HorizontalPodAutoscaler");
|
|
93
|
+
});
|
|
94
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Ingress'", t => {
|
|
95
|
+
const { name } = _1.a.Ingress;
|
|
96
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
97
|
+
t.is(gvk.group, "networking.k8s.io");
|
|
98
|
+
t.is(gvk.version, "v1");
|
|
99
|
+
t.is(gvk.kind, "Ingress");
|
|
100
|
+
});
|
|
101
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1IngressClass'", t => {
|
|
102
|
+
const { name } = _1.a.IngressClass;
|
|
103
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
104
|
+
t.is(gvk.group, "networking.k8s.io");
|
|
105
|
+
t.is(gvk.version, "v1");
|
|
106
|
+
t.is(gvk.kind, "IngressClass");
|
|
107
|
+
});
|
|
108
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Job'", t => {
|
|
109
|
+
const { name } = _1.a.Job;
|
|
110
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
111
|
+
t.is(gvk.group, "batch");
|
|
112
|
+
t.is(gvk.version, "v1");
|
|
113
|
+
t.is(gvk.kind, "Job");
|
|
114
|
+
});
|
|
115
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1LimitRange'", t => {
|
|
116
|
+
const { name } = _1.a.LimitRange;
|
|
117
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
118
|
+
t.is(gvk.group, "");
|
|
119
|
+
t.is(gvk.version, "v1");
|
|
120
|
+
t.is(gvk.kind, "LimitRange");
|
|
121
|
+
});
|
|
122
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1LocalSubjectAccessReview'", t => {
|
|
123
|
+
const { name } = _1.a.LocalSubjectAccessReview;
|
|
124
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
125
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
126
|
+
t.is(gvk.version, "v1");
|
|
127
|
+
t.is(gvk.kind, "LocalSubjectAccessReview");
|
|
128
|
+
});
|
|
129
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1MutatingWebhookConfiguration'", t => {
|
|
130
|
+
const { name } = _1.a.MutatingWebhookConfiguration;
|
|
131
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
132
|
+
t.is(gvk.group, "admissionregistration.k8s.io");
|
|
133
|
+
t.is(gvk.version, "v1");
|
|
134
|
+
t.is(gvk.kind, "MutatingWebhookConfiguration");
|
|
135
|
+
});
|
|
136
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Namespace'", t => {
|
|
137
|
+
const { name } = _1.a.Namespace;
|
|
138
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
139
|
+
t.is(gvk.group, "");
|
|
140
|
+
t.is(gvk.version, "v1");
|
|
141
|
+
t.is(gvk.kind, "Namespace");
|
|
142
|
+
});
|
|
143
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1NetworkPolicy'", t => {
|
|
144
|
+
const { name } = _1.a.NetworkPolicy;
|
|
145
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
146
|
+
t.is(gvk.group, "networking.k8s.io");
|
|
147
|
+
t.is(gvk.version, "v1");
|
|
148
|
+
t.is(gvk.kind, "NetworkPolicy");
|
|
149
|
+
});
|
|
150
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Node'", t => {
|
|
151
|
+
const { name } = _1.a.Node;
|
|
152
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
153
|
+
t.is(gvk.group, "");
|
|
154
|
+
t.is(gvk.version, "v1");
|
|
155
|
+
t.is(gvk.kind, "Node");
|
|
156
|
+
});
|
|
157
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1PersistentVolume'", t => {
|
|
158
|
+
const { name } = _1.a.PersistentVolume;
|
|
159
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
160
|
+
t.is(gvk.group, "");
|
|
161
|
+
t.is(gvk.version, "v1");
|
|
162
|
+
t.is(gvk.kind, "PersistentVolume");
|
|
163
|
+
});
|
|
164
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1PersistentVolumeClaim'", t => {
|
|
165
|
+
const { name } = _1.a.PersistentVolumeClaim;
|
|
166
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
167
|
+
t.is(gvk.group, "");
|
|
168
|
+
t.is(gvk.version, "v1");
|
|
169
|
+
t.is(gvk.kind, "PersistentVolumeClaim");
|
|
170
|
+
});
|
|
171
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Pod'", t => {
|
|
172
|
+
const { name } = _1.a.Pod;
|
|
173
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
174
|
+
t.is(gvk.group, "");
|
|
175
|
+
t.is(gvk.version, "v1");
|
|
176
|
+
t.is(gvk.kind, "Pod");
|
|
177
|
+
});
|
|
178
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1PodDisruptionBudget'", t => {
|
|
179
|
+
const { name } = _1.a.PodDisruptionBudget;
|
|
180
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
181
|
+
t.is(gvk.group, "policy");
|
|
182
|
+
t.is(gvk.version, "v1");
|
|
183
|
+
t.is(gvk.kind, "PodDisruptionBudget");
|
|
184
|
+
});
|
|
185
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1PodTemplate'", t => {
|
|
186
|
+
const { name } = _1.a.PodTemplate;
|
|
187
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
188
|
+
t.is(gvk.group, "");
|
|
189
|
+
t.is(gvk.version, "v1");
|
|
190
|
+
t.is(gvk.kind, "PodTemplate");
|
|
191
|
+
});
|
|
192
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ReplicaSet'", t => {
|
|
193
|
+
const { name } = _1.a.ReplicaSet;
|
|
194
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
195
|
+
t.is(gvk.group, "apps");
|
|
196
|
+
t.is(gvk.version, "v1");
|
|
197
|
+
t.is(gvk.kind, "ReplicaSet");
|
|
198
|
+
});
|
|
199
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ReplicationController'", t => {
|
|
200
|
+
const { name } = _1.a.ReplicationController;
|
|
201
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
202
|
+
t.is(gvk.group, "");
|
|
203
|
+
t.is(gvk.version, "v1");
|
|
204
|
+
t.is(gvk.kind, "ReplicationController");
|
|
205
|
+
});
|
|
206
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ResourceQuota'", t => {
|
|
207
|
+
const { name } = _1.a.ResourceQuota;
|
|
208
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
209
|
+
t.is(gvk.group, "");
|
|
210
|
+
t.is(gvk.version, "v1");
|
|
211
|
+
t.is(gvk.kind, "ResourceQuota");
|
|
212
|
+
});
|
|
213
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1RuntimeClass'", t => {
|
|
214
|
+
const { name } = _1.a.RuntimeClass;
|
|
215
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
216
|
+
t.is(gvk.group, "node.k8s.io");
|
|
217
|
+
t.is(gvk.version, "v1");
|
|
218
|
+
t.is(gvk.kind, "RuntimeClass");
|
|
219
|
+
});
|
|
220
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Secret'", t => {
|
|
221
|
+
const { name } = _1.a.Secret;
|
|
222
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
223
|
+
t.is(gvk.group, "");
|
|
224
|
+
t.is(gvk.version, "v1");
|
|
225
|
+
t.is(gvk.kind, "Secret");
|
|
226
|
+
});
|
|
227
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1SelfSubjectAccessReview'", t => {
|
|
228
|
+
const { name } = _1.a.SelfSubjectAccessReview;
|
|
229
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
230
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
231
|
+
t.is(gvk.version, "v1");
|
|
232
|
+
t.is(gvk.kind, "SelfSubjectAccessReview");
|
|
233
|
+
});
|
|
234
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1SelfSubjectRulesReview'", t => {
|
|
235
|
+
const { name } = _1.a.SelfSubjectRulesReview;
|
|
236
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
237
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
238
|
+
t.is(gvk.version, "v1");
|
|
239
|
+
t.is(gvk.kind, "SelfSubjectRulesReview");
|
|
240
|
+
});
|
|
241
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1Service'", t => {
|
|
242
|
+
const { name } = _1.a.Service;
|
|
243
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
244
|
+
t.is(gvk.group, "");
|
|
245
|
+
t.is(gvk.version, "v1");
|
|
246
|
+
t.is(gvk.kind, "Service");
|
|
247
|
+
});
|
|
248
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ServiceAccount'", t => {
|
|
249
|
+
const { name } = _1.a.ServiceAccount;
|
|
250
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
251
|
+
t.is(gvk.group, "");
|
|
252
|
+
t.is(gvk.version, "v1");
|
|
253
|
+
t.is(gvk.kind, "ServiceAccount");
|
|
254
|
+
});
|
|
255
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1StatefulSet'", t => {
|
|
256
|
+
const { name } = _1.a.StatefulSet;
|
|
257
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
258
|
+
t.is(gvk.group, "apps");
|
|
259
|
+
t.is(gvk.version, "v1");
|
|
260
|
+
t.is(gvk.kind, "StatefulSet");
|
|
261
|
+
});
|
|
262
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1StorageClass'", t => {
|
|
263
|
+
const { name } = _1.a.StorageClass;
|
|
264
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
265
|
+
t.is(gvk.group, "storage.k8s.io");
|
|
266
|
+
t.is(gvk.version, "v1");
|
|
267
|
+
t.is(gvk.kind, "StorageClass");
|
|
268
|
+
});
|
|
269
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1SubjectAccessReview'", t => {
|
|
270
|
+
const { name } = _1.a.SubjectAccessReview;
|
|
271
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
272
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
273
|
+
t.is(gvk.version, "v1");
|
|
274
|
+
t.is(gvk.kind, "SubjectAccessReview");
|
|
275
|
+
});
|
|
276
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1TokenReview'", t => {
|
|
277
|
+
const { name } = _1.a.TokenReview;
|
|
278
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
279
|
+
t.is(gvk.group, "authentication.k8s.io");
|
|
280
|
+
t.is(gvk.version, "v1");
|
|
281
|
+
t.is(gvk.kind, "TokenReview");
|
|
282
|
+
});
|
|
283
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1ValidatingWebhookConfiguration'", t => {
|
|
284
|
+
const { name } = _1.a.ValidatingWebhookConfiguration;
|
|
285
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
286
|
+
t.is(gvk.group, "admissionregistration.k8s.io");
|
|
287
|
+
t.is(gvk.version, "v1");
|
|
288
|
+
t.is(gvk.kind, "ValidatingWebhookConfiguration");
|
|
289
|
+
});
|
|
290
|
+
(0, ava_1.default)("should return the correct GroupVersionKind for 'a.V1VolumeAttachment'", t => {
|
|
291
|
+
const { name } = _1.a.VolumeAttachment;
|
|
292
|
+
const gvk = (0, _1.modelToGroupVersionKind)(name);
|
|
293
|
+
t.is(gvk.group, "storage.k8s.io");
|
|
294
|
+
t.is(gvk.version, "v1");
|
|
295
|
+
t.is(gvk.kind, "VolumeAttachment");
|
|
296
|
+
});
|
|
@@ -106,7 +106,7 @@ class Webhook {
|
|
|
106
106
|
const { name } = this;
|
|
107
107
|
const ignore = [peprIgnore];
|
|
108
108
|
// Add any namespaces to ignore
|
|
109
|
-
if (this.config.alwaysIgnore.namespaces.length > 0) {
|
|
109
|
+
if (this.config.alwaysIgnore.namespaces && this.config.alwaysIgnore.namespaces.length > 0) {
|
|
110
110
|
ignore.push({
|
|
111
111
|
key: "kubernetes.io/metadata.name",
|
|
112
112
|
operator: "NotIn",
|
|
@@ -193,7 +193,7 @@ class Webhook {
|
|
|
193
193
|
name: "server",
|
|
194
194
|
image: this.image,
|
|
195
195
|
imagePullPolicy: "IfNotPresent",
|
|
196
|
-
command: ["node", "/app/node_modules/pepr/dist/run.js", hash
|
|
196
|
+
command: ["node", "/app/node_modules/pepr/dist/src/cli/run.js", hash],
|
|
197
197
|
livenessProbe: {
|
|
198
198
|
httpGet: {
|
|
199
199
|
path: "/healthz",
|
|
@@ -386,7 +386,7 @@ class Webhook {
|
|
|
386
386
|
await coreV1Api.readNamespace(namespace);
|
|
387
387
|
}
|
|
388
388
|
catch (e) {
|
|
389
|
-
logger_1.default.debug(e.body);
|
|
389
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
390
390
|
logger_1.default.info("Creating namespace");
|
|
391
391
|
await coreV1Api.createNamespace(ns);
|
|
392
392
|
}
|
|
@@ -396,9 +396,9 @@ class Webhook {
|
|
|
396
396
|
await admissionApi.createMutatingWebhookConfiguration(wh);
|
|
397
397
|
}
|
|
398
398
|
catch (e) {
|
|
399
|
-
logger_1.default.debug(e.body);
|
|
399
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
400
400
|
logger_1.default.info("Removing and re-creating mutating webhook");
|
|
401
|
-
await admissionApi.deleteMutatingWebhookConfiguration(wh.metadata
|
|
401
|
+
await admissionApi.deleteMutatingWebhookConfiguration(wh.metadata?.name ?? "");
|
|
402
402
|
await admissionApi.createMutatingWebhookConfiguration(wh);
|
|
403
403
|
}
|
|
404
404
|
// If a host is specified, we don't need to deploy the rest of the resources
|
|
@@ -408,10 +408,10 @@ class Webhook {
|
|
|
408
408
|
const netpol = this.networkPolicy();
|
|
409
409
|
try {
|
|
410
410
|
logger_1.default.info("Checking for network policy");
|
|
411
|
-
await networkApi.readNamespacedNetworkPolicy(netpol.metadata
|
|
411
|
+
await networkApi.readNamespacedNetworkPolicy(netpol.metadata?.name ?? "", namespace);
|
|
412
412
|
}
|
|
413
413
|
catch (e) {
|
|
414
|
-
logger_1.default.debug(e.body);
|
|
414
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
415
415
|
logger_1.default.info("Creating network policy");
|
|
416
416
|
await networkApi.createNamespacedNetworkPolicy(namespace, netpol);
|
|
417
417
|
}
|
|
@@ -421,9 +421,9 @@ class Webhook {
|
|
|
421
421
|
await rbacApi.createClusterRoleBinding(crb);
|
|
422
422
|
}
|
|
423
423
|
catch (e) {
|
|
424
|
-
logger_1.default.debug(e.body);
|
|
424
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
425
425
|
logger_1.default.info("Removing and re-creating cluster role binding");
|
|
426
|
-
await rbacApi.deleteClusterRoleBinding(crb.metadata
|
|
426
|
+
await rbacApi.deleteClusterRoleBinding(crb.metadata?.name ?? "");
|
|
427
427
|
await rbacApi.createClusterRoleBinding(crb);
|
|
428
428
|
}
|
|
429
429
|
const cr = this.clusterRole();
|
|
@@ -432,14 +432,14 @@ class Webhook {
|
|
|
432
432
|
await rbacApi.createClusterRole(cr);
|
|
433
433
|
}
|
|
434
434
|
catch (e) {
|
|
435
|
-
logger_1.default.debug(e.body);
|
|
435
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
436
436
|
logger_1.default.info("Removing and re-creating the cluster role");
|
|
437
437
|
try {
|
|
438
|
-
await rbacApi.deleteClusterRole(cr.metadata
|
|
438
|
+
await rbacApi.deleteClusterRole(cr.metadata?.name ?? "");
|
|
439
439
|
await rbacApi.createClusterRole(cr);
|
|
440
440
|
}
|
|
441
441
|
catch (e) {
|
|
442
|
-
logger_1.default.debug(e.body);
|
|
442
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
const sa = this.serviceAccount();
|
|
@@ -448,9 +448,9 @@ class Webhook {
|
|
|
448
448
|
await coreV1Api.createNamespacedServiceAccount(namespace, sa);
|
|
449
449
|
}
|
|
450
450
|
catch (e) {
|
|
451
|
-
logger_1.default.debug(e.body);
|
|
451
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
452
452
|
logger_1.default.info("Removing and re-creating service account");
|
|
453
|
-
await coreV1Api.deleteNamespacedServiceAccount(sa.metadata
|
|
453
|
+
await coreV1Api.deleteNamespacedServiceAccount(sa.metadata?.name ?? "", namespace);
|
|
454
454
|
await coreV1Api.createNamespacedServiceAccount(namespace, sa);
|
|
455
455
|
}
|
|
456
456
|
const mod = this.moduleSecret(code, hash);
|
|
@@ -459,9 +459,9 @@ class Webhook {
|
|
|
459
459
|
await coreV1Api.createNamespacedSecret(namespace, mod);
|
|
460
460
|
}
|
|
461
461
|
catch (e) {
|
|
462
|
-
logger_1.default.debug(e.body);
|
|
462
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
463
463
|
logger_1.default.info("Removing and re-creating module secret");
|
|
464
|
-
await coreV1Api.deleteNamespacedSecret(mod.metadata
|
|
464
|
+
await coreV1Api.deleteNamespacedSecret(mod.metadata?.name ?? "", namespace);
|
|
465
465
|
await coreV1Api.createNamespacedSecret(namespace, mod);
|
|
466
466
|
}
|
|
467
467
|
const svc = this.service();
|
|
@@ -470,9 +470,9 @@ class Webhook {
|
|
|
470
470
|
await coreV1Api.createNamespacedService(namespace, svc);
|
|
471
471
|
}
|
|
472
472
|
catch (e) {
|
|
473
|
-
logger_1.default.debug(e.body);
|
|
473
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
474
474
|
logger_1.default.info("Removing and re-creating service");
|
|
475
|
-
await coreV1Api.deleteNamespacedService(svc.metadata
|
|
475
|
+
await coreV1Api.deleteNamespacedService(svc.metadata?.name ?? "", namespace);
|
|
476
476
|
await coreV1Api.createNamespacedService(namespace, svc);
|
|
477
477
|
}
|
|
478
478
|
const tls = this.tlsSecret();
|
|
@@ -481,9 +481,9 @@ class Webhook {
|
|
|
481
481
|
await coreV1Api.createNamespacedSecret(namespace, tls);
|
|
482
482
|
}
|
|
483
483
|
catch (e) {
|
|
484
|
-
logger_1.default.debug(e.body);
|
|
484
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
485
485
|
logger_1.default.info("Removing and re-creating TLS secret");
|
|
486
|
-
await coreV1Api.deleteNamespacedSecret(tls.metadata
|
|
486
|
+
await coreV1Api.deleteNamespacedSecret(tls.metadata?.name ?? "", namespace);
|
|
487
487
|
await coreV1Api.createNamespacedSecret(namespace, tls);
|
|
488
488
|
}
|
|
489
489
|
const dep = this.deployment(hash);
|
|
@@ -492,9 +492,9 @@ class Webhook {
|
|
|
492
492
|
await appsApi.createNamespacedDeployment(namespace, dep);
|
|
493
493
|
}
|
|
494
494
|
catch (e) {
|
|
495
|
-
logger_1.default.debug(e.body);
|
|
495
|
+
logger_1.default.debug(e instanceof client_node_1.HttpError ? e.body : e);
|
|
496
496
|
logger_1.default.info("Removing and re-creating deployment");
|
|
497
|
-
await appsApi.deleteNamespacedDeployment(dep.metadata
|
|
497
|
+
await appsApi.deleteNamespacedDeployment(dep.metadata?.name ?? "", namespace);
|
|
498
498
|
await appsApi.createNamespacedDeployment(namespace, dep);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const ava_1 = __importDefault(require("ava"));
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
|
+
(0, ava_1.default)("Logger debug logs correctly", t => {
|
|
11
|
+
const logger = new logger_1.Logger(logger_1.LogLevel.debug); // Create a logger with debug level
|
|
12
|
+
const message = "Debug message";
|
|
13
|
+
const consoleLog = console.log; // Store the original console.log function
|
|
14
|
+
const consoleOutput = [];
|
|
15
|
+
// Replace console.log with a mock function to capture the output
|
|
16
|
+
console.log = (output) => {
|
|
17
|
+
consoleOutput.push(output);
|
|
18
|
+
};
|
|
19
|
+
logger.debug(message); // Call the debug method
|
|
20
|
+
// Check that the output matches the expected value
|
|
21
|
+
t.true(consoleOutput[0].includes(logger_1.LogLevel[logger_1.LogLevel.debug]));
|
|
22
|
+
t.true(consoleOutput[0].includes(message));
|
|
23
|
+
// Restore the original console.log function
|
|
24
|
+
console.log = consoleLog;
|
|
25
|
+
});
|
|
26
|
+
(0, ava_1.default)("Logger info logs correctly", t => {
|
|
27
|
+
const logger = new logger_1.Logger(logger_1.LogLevel.info); // Create a logger with info level
|
|
28
|
+
const message = "Info message";
|
|
29
|
+
const consoleLog = console.log;
|
|
30
|
+
const consoleOutput = [];
|
|
31
|
+
console.log = (output) => {
|
|
32
|
+
consoleOutput.push(output);
|
|
33
|
+
};
|
|
34
|
+
logger.info(message);
|
|
35
|
+
t.true(consoleOutput[0].includes(logger_1.LogLevel[logger_1.LogLevel.info]));
|
|
36
|
+
t.true(consoleOutput[0].includes(message));
|
|
37
|
+
console.log = consoleLog;
|
|
38
|
+
});
|
|
39
|
+
(0, ava_1.default)("Logger warn logs correctly", t => {
|
|
40
|
+
const logger = new logger_1.Logger(logger_1.LogLevel.warn); // Create a logger with warn level
|
|
41
|
+
const message = "Warning message";
|
|
42
|
+
const consoleLog = console.log;
|
|
43
|
+
const consoleOutput = [];
|
|
44
|
+
console.log = (output) => {
|
|
45
|
+
consoleOutput.push(output);
|
|
46
|
+
};
|
|
47
|
+
logger.warn(message);
|
|
48
|
+
t.true(consoleOutput[0].includes(logger_1.LogLevel[logger_1.LogLevel.warn]));
|
|
49
|
+
t.true(consoleOutput[0].includes(message));
|
|
50
|
+
console.log = consoleLog;
|
|
51
|
+
});
|
|
52
|
+
(0, ava_1.default)("Logger error logs correctly", t => {
|
|
53
|
+
const logger = new logger_1.Logger(logger_1.LogLevel.error); // Create a logger with error level
|
|
54
|
+
const message = "Error message";
|
|
55
|
+
const consoleLog = console.log;
|
|
56
|
+
const consoleOutput = [];
|
|
57
|
+
console.log = (output) => {
|
|
58
|
+
consoleOutput.push(output);
|
|
59
|
+
};
|
|
60
|
+
logger.error(message);
|
|
61
|
+
t.true(consoleOutput[0].includes(logger_1.LogLevel[logger_1.LogLevel.error]));
|
|
62
|
+
t.true(consoleOutput[0].includes(message));
|
|
63
|
+
console.log = consoleLog;
|
|
64
|
+
});
|
|
@@ -35,6 +35,7 @@ async function processor(config, capabilities, req) {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
const identifier = `${config.uuid}.pepr.dev/${name}`;
|
|
38
|
+
wrapped.Raw.metadata = wrapped.Raw.metadata || {};
|
|
38
39
|
wrapped.Raw.metadata.annotations = wrapped.Raw.metadata.annotations || {};
|
|
39
40
|
wrapped.Raw.metadata.annotations[identifier] = status;
|
|
40
41
|
};
|
|
@@ -47,6 +48,8 @@ async function processor(config, capabilities, req) {
|
|
|
47
48
|
updateStatus("succeeded");
|
|
48
49
|
}
|
|
49
50
|
catch (e) {
|
|
51
|
+
// Annoying ts false positive
|
|
52
|
+
response.warnings = response.warnings || [];
|
|
50
53
|
response.warnings.push(`Action failed: ${e}`);
|
|
51
54
|
// If errors are not allowed, note the failure in the Response
|
|
52
55
|
if (config.onError) {
|
|
@@ -73,7 +76,7 @@ async function processor(config, capabilities, req) {
|
|
|
73
76
|
response.patch = Buffer.from(JSON.stringify(patches)).toString("base64");
|
|
74
77
|
}
|
|
75
78
|
// Remove the warnings array if it's empty
|
|
76
|
-
if (response.warnings.length < 1) {
|
|
79
|
+
if (response.warnings && response.warnings.length < 1) {
|
|
77
80
|
delete response.warnings;
|
|
78
81
|
}
|
|
79
82
|
logger_1.default.debug(patches);
|
|
@@ -7,8 +7,26 @@ import { RegisterKind, a } from "./src/lib/k8s";
|
|
|
7
7
|
import Log from "./src/lib/logger";
|
|
8
8
|
import { PeprModule } from "./src/lib/module";
|
|
9
9
|
import { PeprRequest } from "./src/lib/request";
|
|
10
|
+
|
|
11
|
+
// Import type information for external packages
|
|
10
12
|
import type * as KubernetesClientNode from "@kubernetes/client-node";
|
|
11
13
|
import type * as RamdaUtils from "ramda";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
a,
|
|
17
|
+
/** PeprModule is used to setup a complete Pepr Module: `new PeprModule(cfg, {...capabilities})` */
|
|
18
|
+
PeprModule,
|
|
19
|
+
PeprRequest,
|
|
20
|
+
RegisterKind,
|
|
21
|
+
Capability,
|
|
22
|
+
Log,
|
|
23
|
+
utils,
|
|
24
|
+
fetch,
|
|
25
|
+
fetchRaw,
|
|
26
|
+
fetchStatus,
|
|
27
|
+
k8s,
|
|
28
|
+
|
|
29
|
+
// Export the imported type information for external packages
|
|
30
|
+
RamdaUtils,
|
|
31
|
+
KubernetesClientNode,
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -4,29 +4,17 @@
|
|
|
4
4
|
"author": "Defense Unicorns",
|
|
5
5
|
"homepage": "https://github.com/defenseunicorns/pepr",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"bin": "dist/cli.js",
|
|
7
|
+
"bin": "dist/src/cli/index.js",
|
|
8
8
|
"repository": "defenseunicorns/pepr",
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=18.0.0"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.3.0-rc0",
|
|
13
13
|
"main": "dist/index.js",
|
|
14
|
-
"types": "dist/index.d.ts",
|
|
15
|
-
"pepr": {
|
|
16
|
-
"name": "Development Module",
|
|
17
|
-
"uuid": "20e17cf6-a2e4-46b2-b626-75d88d96c88b",
|
|
18
|
-
"description": "Development module for pepr",
|
|
19
|
-
"version": "dev",
|
|
20
|
-
"onError": "ignore",
|
|
21
|
-
"alwaysIgnore": {
|
|
22
|
-
"namespaces": [],
|
|
23
|
-
"labels": []
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
14
|
"scripts": {
|
|
27
15
|
"prebuild": "rm -fr dist/* && node hack/build-template-data.js",
|
|
28
|
-
"build": "tsc
|
|
29
|
-
"test:unit": "npm run build && ava",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"test:unit": "npm run build && ava dist/**/*.test.js",
|
|
30
18
|
"test:e2e": "npm run test:e2e:k3d && npm run test:e2e:build && npm run test:e2e:image && npm run test:e2e:run",
|
|
31
19
|
"test:e2e:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'",
|
|
32
20
|
"test:e2e:build": "npm run build && npm uninstall pepr -g && npm install -g . && pepr",
|
|
@@ -37,45 +25,39 @@
|
|
|
37
25
|
},
|
|
38
26
|
"dependencies": {
|
|
39
27
|
"@kubernetes/client-node": "0.18.1",
|
|
40
|
-
"@rollup/plugin-json": "6.0.0",
|
|
41
|
-
"@rollup/plugin-node-resolve": "15.0.2",
|
|
42
|
-
"@rollup/plugin-typescript": "11.1.0",
|
|
43
|
-
"@types/ramda": "0.29.0",
|
|
44
|
-
"chokidar": "3.5.3",
|
|
45
|
-
"commander": "10.0.1",
|
|
46
28
|
"express": "4.18.2",
|
|
47
29
|
"fast-json-patch": "3.1.1",
|
|
48
30
|
"http-status-codes": "2.2.0",
|
|
49
31
|
"node-fetch": "2.6.9",
|
|
50
|
-
"
|
|
51
|
-
"prettier": "2.8.8",
|
|
52
|
-
"prompts": "2.4.2",
|
|
53
|
-
"ramda": "0.29.0",
|
|
54
|
-
"rollup": "3.21.0",
|
|
55
|
-
"ts-node": "10.9.1",
|
|
56
|
-
"tslib": "2.5.0",
|
|
57
|
-
"typescript": "5.0.4",
|
|
58
|
-
"uuid": "9.0.0"
|
|
32
|
+
"ramda": "0.29.0"
|
|
59
33
|
},
|
|
60
34
|
"devDependencies": {
|
|
61
35
|
"@types/express": "4.17.17",
|
|
62
36
|
"@types/node-fetch": "2.6.3",
|
|
63
37
|
"@types/node-forge": "1.3.2",
|
|
64
38
|
"@types/prompts": "2.4.4",
|
|
39
|
+
"@types/ramda": "0.29.1",
|
|
65
40
|
"@types/uuid": "9.0.1",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "5.59.
|
|
67
|
-
"@typescript-eslint/parser": "5.59.
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "5.59.2",
|
|
42
|
+
"@typescript-eslint/parser": "5.59.2",
|
|
68
43
|
"ava": "5.2.0",
|
|
69
|
-
"eslint": "8.
|
|
70
|
-
"nock": "13.3.1"
|
|
44
|
+
"eslint": "8.40.0",
|
|
45
|
+
"nock": "13.3.1",
|
|
46
|
+
"prettier": "2.8.8"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@rollup/plugin-json": "6.0.0",
|
|
50
|
+
"@rollup/plugin-node-resolve": "15.0.2",
|
|
51
|
+
"@rollup/plugin-typescript": "11.1.0",
|
|
52
|
+
"chokidar": "3.5.3",
|
|
53
|
+
"commander": "10.0.1",
|
|
54
|
+
"node-forge": "1.3.1",
|
|
55
|
+
"prompts": "2.4.2",
|
|
56
|
+
"rollup": "3.21.5",
|
|
57
|
+
"typescript": "5.0.4",
|
|
58
|
+
"uuid": "9.0.0"
|
|
71
59
|
},
|
|
72
60
|
"ava": {
|
|
73
|
-
"extensions": [
|
|
74
|
-
"ts"
|
|
75
|
-
],
|
|
76
|
-
"require": [
|
|
77
|
-
"ts-node/register"
|
|
78
|
-
],
|
|
79
61
|
"failFast": true,
|
|
80
62
|
"verbose": true
|
|
81
63
|
}
|