pepr 0.3.0-rc0 → 0.3.1
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 +3 -46
- package/dist/package.json +8 -6
- package/dist/src/cli/build.js +1 -1
- package/dist/src/cli/dev.js +4 -1
- package/dist/src/cli/init/index.js +1 -1
- package/dist/src/lib/capability.d.ts +29 -0
- package/dist/src/lib/capability.d.ts.map +1 -0
- package/dist/src/lib/controller.d.ts +18 -0
- package/dist/src/lib/controller.d.ts.map +1 -0
- package/dist/src/lib/fetch.d.ts +24 -0
- package/dist/src/lib/fetch.d.ts.map +1 -0
- package/dist/src/lib/filter.d.ts +11 -0
- package/dist/src/lib/filter.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +15 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/{index.js → src/lib/index.js} +6 -6
- package/dist/src/lib/k8s/index.d.ts +6 -0
- package/dist/src/lib/k8s/index.d.ts.map +1 -0
- package/dist/src/lib/k8s/kinds.d.ts +12 -0
- package/dist/src/lib/k8s/kinds.d.ts.map +1 -0
- package/dist/src/lib/k8s/tls.d.ts +18 -0
- package/dist/src/lib/k8s/tls.d.ts.map +1 -0
- package/dist/src/lib/k8s/types.d.ts +148 -0
- package/dist/src/lib/k8s/types.d.ts.map +1 -0
- package/dist/src/lib/k8s/upstream.d.ts +4 -0
- package/dist/src/lib/k8s/upstream.d.ts.map +1 -0
- package/dist/src/lib/k8s/webhook.d.ts +35 -0
- package/dist/src/lib/k8s/webhook.d.ts.map +1 -0
- package/dist/src/lib/logger.d.ts +56 -0
- package/dist/src/lib/logger.d.ts.map +1 -0
- package/dist/src/lib/module.d.ts +33 -0
- package/dist/src/lib/module.d.ts.map +1 -0
- package/dist/src/lib/processor.d.ts +5 -0
- package/dist/src/lib/processor.d.ts.map +1 -0
- package/dist/src/lib/request.d.ts +78 -0
- package/dist/src/lib/request.d.ts.map +1 -0
- package/dist/src/lib/types.d.ts +188 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/package.json +8 -6
- package/{index.ts → src/lib/index.ts} +6 -6
- package/dist/fixtures/data/cm1.json +0 -75
- package/dist/fixtures/data/deployment1.json +0 -170
- package/dist/fixtures/data/ns1.json +0 -72
- package/dist/fixtures/data/pod1.json +0 -271
- package/dist/fixtures/data/pod2.json +0 -257
- package/dist/fixtures/data/svc1.json +0 -100
- package/dist/fixtures/loader.js +0 -60
- package/dist/src/cli/init/utils.test.js +0 -29
- package/dist/src/cli/init/walkthrough.test.js +0 -21
- package/dist/src/lib/fetch.test.js +0 -98
- package/dist/src/lib/filter.test.js +0 -208
- package/dist/src/lib/k8s/kinds.test.js +0 -296
- package/dist/src/lib/logger.test.js +0 -64
- package/docs/.prettierrc.json +0 -13
- package/docs/actions.md +0 -58
- package/docs/capabilities.md +0 -17
- package/docs/cli.md +0 -58
- package/docs/module.md +0 -90
- package/osv-scanner.toml +0 -4
- package/src/lib/fetch.test.ts +0 -115
- package/src/lib/filter.test.ts +0 -231
- package/src/lib/k8s/kinds.test.ts +0 -333
- package/src/lib/logger.test.ts +0 -80
|
@@ -1,296 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
});
|
package/docs/.prettierrc.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"arrowParens": "avoid",
|
|
3
|
-
"bracketSameLine": false,
|
|
4
|
-
"bracketSpacing": true,
|
|
5
|
-
"embeddedLanguageFormatting": "auto",
|
|
6
|
-
"insertPragma": false,
|
|
7
|
-
"printWidth": 80,
|
|
8
|
-
"quoteProps": "as-needed",
|
|
9
|
-
"requirePragma": false,
|
|
10
|
-
"semi": true,
|
|
11
|
-
"tabWidth": 2,
|
|
12
|
-
"useTabs": false
|
|
13
|
-
}
|
package/docs/actions.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# CapabilityActions
|
|
2
|
-
|
|
3
|
-
A CapabilityAction is a discrete set of behaviors defined in a single function that acts on a given Kubernetes GroupVersionKind (GVK) passed in from Kubernetes. CapabilityActions are the atomic operations that are performed on Kubernetes resources by Pepr.
|
|
4
|
-
|
|
5
|
-
For example, a CapabilityAction could be responsible for adding a specific label to a Kubernetes resource, or for modifying a specific field in a resource's metadata. CapabilityActions can be grouped together within a Capability to provide a more comprehensive set of operations that can be performed on Kubernetes resources.
|
|
6
|
-
|
|
7
|
-
Let's look at some example CapabilityActions that are included in the `HelloPepr` capability that is created for you when you [`pepr init`](./cli.md#pepr-init):
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
In this first example, Pepr is adding a label and annotation to a ConfigMap with tne name `example-1` when it is created. Comments are added to each line to explain in more detail what is happening.
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
// When(a.<Kind>) tells Pepr what K8s GroupVersionKind (GVK) this CapabilityAction should act on.
|
|
15
|
-
When(a.ConfigMap)
|
|
16
|
-
// Next we tell Pepr to only act on new ConfigMaps that are created.
|
|
17
|
-
.IsCreated()
|
|
18
|
-
// Then we tell Pepr to only act on ConfigMaps with the name "example-1".
|
|
19
|
-
.WithName("example-1")
|
|
20
|
-
// Then() is where we define the actual behavior of this CapabilityAction.
|
|
21
|
-
.Then(request => {
|
|
22
|
-
// The request object is a wrapper around the K8s resource that Pepr is acting on.
|
|
23
|
-
request
|
|
24
|
-
// Here we are adding a label to the ConfigMap.
|
|
25
|
-
.SetLabel("pepr", "was-here")
|
|
26
|
-
// And here we are adding an annotation.
|
|
27
|
-
.SetAnnotation("pepr.dev", "annotations-work-too");
|
|
28
|
-
|
|
29
|
-
// Note that we are not returning anything here. This is because Pepr is tracking the changes in each CapabilityAction automatically.
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
This example is identical to the previous one, except we are acting on a different CongigMap name and using the `ThenSet()` shorthand to merge changes into the resource.
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
// Once again, we tell Pepr what K8s GVK this CapabilityAction should act on.
|
|
39
|
-
When(a.ConfigMap)
|
|
40
|
-
// Next we tell Pepr to only act on new ConfigMaps that are created.
|
|
41
|
-
.IsCreated()
|
|
42
|
-
// This time we are acting on a ConfigMap with the name "example-2".
|
|
43
|
-
.WithName("example-2")
|
|
44
|
-
// Instead of using Then(), we are using ThenSet() to merge changes into the resource without a function call.
|
|
45
|
-
.ThenSet({
|
|
46
|
-
// Using Typescript, we will get intellisense for the ConfigMap object and immediate type-validation for the values we are setting.
|
|
47
|
-
metadata: {
|
|
48
|
-
labels: {
|
|
49
|
-
pepr: "was-here",
|
|
50
|
-
},
|
|
51
|
-
annotations: {
|
|
52
|
-
"pepr.dev": "annotations-work-too",
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
There are many more examples in the `HelloPepr` capability that you can use as a reference when creating your own CapabilityActions. Note that each time you run [`pepr update`](./cli.md#pepr-update), Pepr will automatically update the `HelloPepr` capability with the latest examples and best practices for you to reference and test directly in your Pepr Module.
|
package/docs/capabilities.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Capabilities
|
|
2
|
-
|
|
3
|
-
A capability is set of related [CapabilityActions](./actions.md) that work together to achieve a specific transformation or operation on Kubernetes resources. Capabilities are user-defined and can include one or more CapabilityActions. They are defined within a Pepr module and can be used in both MutatingWebhookConfigurations and ValidatingWebhookConfigurations. A Capability can have a specific scope, such as mutating or validating, and can be reused in multiple Pepr modules.
|
|
4
|
-
|
|
5
|
-
When you [`pepr init`](./cli.md#pepr-init), a `capabilities` directory is created for you. This directory is where you will define your capabilities. You can create as many capabilities as you need, and each capability can contain one or more CapabilityActions. Pepr also automatically creates a `HelloPepr` capability with a number of example CapabilityActions to help you get started.
|
|
6
|
-
|
|
7
|
-
## Creating a Capability
|
|
8
|
-
|
|
9
|
-
Define a new capability can be done via a [VSCode Snippet](https://code.visualstudio.com/docs/editor/userdefinedsnippets) generated during [`pepr init`](./cli.md#pepr-init).
|
|
10
|
-
|
|
11
|
-
1. Create a new file in the `capabilities` directory with the name of your capability. For example, `capabilities/my-capability.ts`.
|
|
12
|
-
|
|
13
|
-
1. Open the new file in VSCode and type `create` in the file. A suggestion should prompt you to generate the content from there.
|
|
14
|
-
|
|
15
|
-
https://user-images.githubusercontent.com/882485/230897379-0bb57dff-9832-479f-8733-79e103703135.mp4
|
|
16
|
-
|
|
17
|
-
_If you prefer not to use VSCode, you can also modify or copy the `HelloPepr` capability to meet your needs instead._
|
package/docs/cli.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Pepr CLI
|
|
2
|
-
|
|
3
|
-
## `pepr init`
|
|
4
|
-
|
|
5
|
-
Initialize a new Pepr Module.
|
|
6
|
-
|
|
7
|
-
**Options:**
|
|
8
|
-
|
|
9
|
-
- `-l, --log-level [level]` - Log level: debug, info, warn, error (default: "info")
|
|
10
|
-
- `--skip-post-init` - Skip npm install, git init and VSCode launch
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## `pepr update`
|
|
15
|
-
|
|
16
|
-
Update the current Pepr Module to the latest SDK version and update the global Pepr CLI to the same version.
|
|
17
|
-
|
|
18
|
-
**Options:**
|
|
19
|
-
|
|
20
|
-
- `-l, --log-level [level]` - Log level: debug, info, warn, error (default: "info")
|
|
21
|
-
- `--skip-template-update` - Skip updating the template files
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## `pepr dev`
|
|
26
|
-
|
|
27
|
-
Connect a local cluster to a local version of the Pepr Controller to do real-time debugging of your module. Note
|
|
28
|
-
the `pepr dev` assumes a K3d cluster is running by default. If you are working with Kind or another docker-based
|
|
29
|
-
K8s distro, you will need to pass the `--host host.docker.internal` option to `pepr dev`. If working with a remote
|
|
30
|
-
cluster you will have to give Pepr a host path to your machine that is reachable from the K8s cluster.
|
|
31
|
-
|
|
32
|
-
**Options:**
|
|
33
|
-
|
|
34
|
-
- `-l, --log-level [level]` - Log level: debug, info, warn, error (default: "info")
|
|
35
|
-
- `-h, --host [host]` - Host to listen on (default: "host.k3d.internal")
|
|
36
|
-
- `--confirm` - Skip confirmation prompt
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## `pepr deploy`
|
|
41
|
-
|
|
42
|
-
Deploy the current module into a Kubernetes cluster, useful for CI systems. Not recommended for production use.
|
|
43
|
-
|
|
44
|
-
**Options:**
|
|
45
|
-
|
|
46
|
-
- `-l, --log-level [level]` - Log level: debug, info, warn, error (default: "info")
|
|
47
|
-
- `-i, --image [image]` - Override the image tag
|
|
48
|
-
- `--confirm` - Skip confirmation prompt
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## `pepr build`
|
|
53
|
-
|
|
54
|
-
Create a [zarf.yaml](https://zarf.dev) and K8s manifest for the current module. This includes everything needed to deploy Pepr and the current module into production environments.
|
|
55
|
-
|
|
56
|
-
**Options:**
|
|
57
|
-
|
|
58
|
-
- `-l, --log-level [level]` - Log level: debug, info, warn, error (default: "info")
|
package/docs/module.md
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Pepr Module
|
|
2
|
-
|
|
3
|
-
Each Pepr Module is it's own Typescript project, produced by [`pepr init`](./cli.md#pepr-init). Typically a module is maintained by a unique group or system. For example, a module for internal [Zarf](https://zarf.dev/) mutations would be different from a module for [Big Bang](https://p1.dso.mil/products/big-bang). An important idea with modules is that they are _wholly independent of one another_. This means that 2 different modules can be on completely different versions of Pepr and any other dependencies; their only interaction is through the standard K8s interfaces like any other webhook or controller.
|
|
4
|
-
|
|
5
|
-
## Module development lifecycle
|
|
6
|
-
|
|
7
|
-
1. **Create the module**:
|
|
8
|
-
|
|
9
|
-
Use [`pepr init`](./cli.md#pepr-init) to generate a new module.
|
|
10
|
-
|
|
11
|
-
1. **Quickly validate system setup**:
|
|
12
|
-
|
|
13
|
-
Every new module includes a sample Pepr Capability called `HelloPepr`. By default,
|
|
14
|
-
this capability is deployed and monitoring the `pepr-demo` namespace. There is a sample
|
|
15
|
-
yaml also included you can use to see Pepr in your cluster. Here's the quick steps to do
|
|
16
|
-
that after `pepr init`:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
# cd to the newly-created Pepr module folder
|
|
20
|
-
cd my-module-name
|
|
21
|
-
|
|
22
|
-
# If you don't already have a local K8s cluster, you can set one up with k3d
|
|
23
|
-
npm run k3d-setup
|
|
24
|
-
|
|
25
|
-
# Launch pepr dev mode (npm start or pepr dev)
|
|
26
|
-
# If using another local K8s distro instead of k3d, use `pepr dev --host host.docker.internal`
|
|
27
|
-
pepr dev
|
|
28
|
-
|
|
29
|
-
# From another terminal, apply the sample yaml
|
|
30
|
-
kubectl apply -f capabilities/hello-pepr.samples.yaml
|
|
31
|
-
|
|
32
|
-
# Verify the configmaps were transformed using kubectl, k9s or another tool
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
1. **Create your custom Pepr Capabilities**
|
|
36
|
-
|
|
37
|
-
Now that you have confirmed Pepr is working, you can now create new [capabilities](./capabilities.md). You'll also want to disable the `HelloPepr` capability in your module (`pepr.ts`) before pushing to production. You can disable by commenting out or deleting the `HelloPepr` variable below:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
new PeprModule(cfg, [
|
|
41
|
-
// Remove or comment the line below to disable the HelloPepr capability
|
|
42
|
-
HelloPepr,
|
|
43
|
-
|
|
44
|
-
// Your additional capabilities go here
|
|
45
|
-
]);
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
_Note: if you also delete the `capabilities/hello-pepr.ts` file, it will be added again on the next [`pepr update`](./cli.md#pepr-update) so you have the latest examples usages from the Pepr SDK. Therefore, it is sufficient to remove the entry from your `pepr.ts` module
|
|
49
|
-
config._
|
|
50
|
-
|
|
51
|
-
1. **Build and deploy the Pepr Module**
|
|
52
|
-
|
|
53
|
-
Most of the time, you'll likely be iterating on a module with `perp dev` for real-time feedback and validation Once you are ready to move beyond the local dev environment, Pepr provides deployment and build tools you can use.
|
|
54
|
-
|
|
55
|
-
`pepr deploy` - you can use this command to build your module and deploy it into any K8s cluster your current `kubecontext` has access to. This setup is ideal for CI systems during testing, but is not recommended for production use. See [`pepr deploy`](./cli.md#pepr-deploy) for more info.
|
|
56
|
-
|
|
57
|
-
## Advanced Module Configuration
|
|
58
|
-
|
|
59
|
-
By default, when you run `pepr init`, the module is not configured with any additional options. Currently, there are 3 options you can configure:
|
|
60
|
-
|
|
61
|
-
- `deferStart` - if set to `true`, the module will not start automatically. You will need to call `start()` manually. This is useful if you want to do some additional setup before the module controller starts. You can also use this to change the default port that the controller listens on.
|
|
62
|
-
|
|
63
|
-
- `beforeHook` - an optional callback that will be called before every request is processed. This is useful if you want to do some additional logging or validation before the request is processed.
|
|
64
|
-
|
|
65
|
-
- `afterHook` - an optional callback that will be called after every request is processed. This is useful if you want to do some additional logging or validation after the request is processed.
|
|
66
|
-
|
|
67
|
-
You can configure each of these by modifying the `pepr.ts` file in your module. Here's an example of how you would configure each of these options:
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
const module = new PeprModule(
|
|
71
|
-
cfg,
|
|
72
|
-
[
|
|
73
|
-
// Your capabilities go here
|
|
74
|
-
],
|
|
75
|
-
{
|
|
76
|
-
deferStart: true,
|
|
77
|
-
|
|
78
|
-
beforeHook: req => {
|
|
79
|
-
// Any actions you want to perform before the request is processed, including modifying the request.
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
afterHook: res => {
|
|
83
|
-
// Any actions you want to perform after the request is processed, including modifying the response.
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// Do any additional setup before starting the controller
|
|
89
|
-
module.start();
|
|
90
|
-
```
|
package/osv-scanner.toml
DELETED