pepr 0.1.4 → 0.1.5
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 +1 -2
- package/dist/pepr-20e17cf6-a2e4-46b2-b626-75d88d96c88b.js +393 -0
- package/dist/pepr-cli.js +108 -1
- package/dist/pepr-cli.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -12
- package/rollup.config.mjs +0 -27
- package/src/lib/filter.test.ts +0 -211
- package/src/lib/k8s/kinds.test.ts +0 -341
- package/src/lib/logger.test.ts +0 -80
package/src/lib/filter.test.ts
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { gvkMap } from "@k8s";
|
|
2
|
-
import test from "ava";
|
|
3
|
-
import { POD1 } from "@fixtures/loader";
|
|
4
|
-
import { shouldSkipRequest } from "./filter";
|
|
5
|
-
|
|
6
|
-
test("should reject when kind does not match", t => {
|
|
7
|
-
const binding = {
|
|
8
|
-
kind: gvkMap.V1ConfigMap,
|
|
9
|
-
filters: {
|
|
10
|
-
name: "",
|
|
11
|
-
namespaces: [],
|
|
12
|
-
labels: {},
|
|
13
|
-
annotations: {},
|
|
14
|
-
},
|
|
15
|
-
callback: () => null,
|
|
16
|
-
};
|
|
17
|
-
const pod = POD1();
|
|
18
|
-
|
|
19
|
-
t.true(shouldSkipRequest(binding, pod));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("should reject when group does not match", t => {
|
|
23
|
-
const binding = {
|
|
24
|
-
kind: gvkMap.V1CronJob,
|
|
25
|
-
filters: {
|
|
26
|
-
name: "",
|
|
27
|
-
namespaces: [],
|
|
28
|
-
labels: {},
|
|
29
|
-
annotations: {},
|
|
30
|
-
},
|
|
31
|
-
callback: () => null,
|
|
32
|
-
};
|
|
33
|
-
const pod = POD1();
|
|
34
|
-
|
|
35
|
-
t.true(shouldSkipRequest(binding, pod));
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("should reject when version does not match", t => {
|
|
39
|
-
const binding = {
|
|
40
|
-
kind: {
|
|
41
|
-
group: "",
|
|
42
|
-
version: "v2",
|
|
43
|
-
kind: "Pod",
|
|
44
|
-
},
|
|
45
|
-
filters: {
|
|
46
|
-
name: "",
|
|
47
|
-
namespaces: [],
|
|
48
|
-
labels: {},
|
|
49
|
-
annotations: {},
|
|
50
|
-
},
|
|
51
|
-
callback: () => null,
|
|
52
|
-
};
|
|
53
|
-
const pod = POD1();
|
|
54
|
-
|
|
55
|
-
t.true(shouldSkipRequest(binding, pod));
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("should allow when group, version, and kind match", t => {
|
|
59
|
-
const binding = {
|
|
60
|
-
kind: gvkMap.V1Pod,
|
|
61
|
-
filters: {
|
|
62
|
-
name: "",
|
|
63
|
-
namespaces: [],
|
|
64
|
-
labels: {},
|
|
65
|
-
annotations: {},
|
|
66
|
-
},
|
|
67
|
-
callback: () => null,
|
|
68
|
-
};
|
|
69
|
-
const pod = POD1();
|
|
70
|
-
|
|
71
|
-
t.false(shouldSkipRequest(binding, pod));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("should allow when kind match and others are empty", t => {
|
|
75
|
-
const binding = {
|
|
76
|
-
kind: {
|
|
77
|
-
group: "",
|
|
78
|
-
version: "",
|
|
79
|
-
kind: "Pod",
|
|
80
|
-
},
|
|
81
|
-
filters: {
|
|
82
|
-
name: "",
|
|
83
|
-
namespaces: [],
|
|
84
|
-
labels: {},
|
|
85
|
-
annotations: {},
|
|
86
|
-
},
|
|
87
|
-
callback: () => null,
|
|
88
|
-
};
|
|
89
|
-
const pod = POD1();
|
|
90
|
-
|
|
91
|
-
t.false(shouldSkipRequest(binding, pod));
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test("should reject when namespace does not match", t => {
|
|
95
|
-
const binding = {
|
|
96
|
-
kind: gvkMap.V1Pod,
|
|
97
|
-
filters: {
|
|
98
|
-
name: "",
|
|
99
|
-
namespaces: ["bleh"],
|
|
100
|
-
labels: {},
|
|
101
|
-
annotations: {},
|
|
102
|
-
},
|
|
103
|
-
callback: () => null,
|
|
104
|
-
};
|
|
105
|
-
const pod = POD1();
|
|
106
|
-
|
|
107
|
-
t.true(shouldSkipRequest(binding, pod));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test("should allow when namespace is match", t => {
|
|
111
|
-
const binding = {
|
|
112
|
-
kind: gvkMap.V1Pod,
|
|
113
|
-
filters: {
|
|
114
|
-
name: "",
|
|
115
|
-
namespaces: ["default", "unicorn", "things"],
|
|
116
|
-
labels: {},
|
|
117
|
-
annotations: {},
|
|
118
|
-
},
|
|
119
|
-
callback: () => null,
|
|
120
|
-
};
|
|
121
|
-
const pod = POD1();
|
|
122
|
-
|
|
123
|
-
t.false(shouldSkipRequest(binding, pod));
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("should reject when label does not match", t => {
|
|
127
|
-
const binding = {
|
|
128
|
-
kind: gvkMap.V1Pod,
|
|
129
|
-
filters: {
|
|
130
|
-
name: "",
|
|
131
|
-
namespaces: [],
|
|
132
|
-
labels: {
|
|
133
|
-
foo: "bar",
|
|
134
|
-
},
|
|
135
|
-
annotations: {},
|
|
136
|
-
},
|
|
137
|
-
callback: () => null,
|
|
138
|
-
};
|
|
139
|
-
const pod = POD1();
|
|
140
|
-
|
|
141
|
-
t.true(shouldSkipRequest(binding, pod));
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test("should allow when label is match", t => {
|
|
145
|
-
const binding = {
|
|
146
|
-
kind: gvkMap.V1Pod,
|
|
147
|
-
filters: {
|
|
148
|
-
name: "",
|
|
149
|
-
|
|
150
|
-
namespaces: [],
|
|
151
|
-
labels: {
|
|
152
|
-
foo: "bar",
|
|
153
|
-
test: "test1",
|
|
154
|
-
},
|
|
155
|
-
annotations: {},
|
|
156
|
-
},
|
|
157
|
-
callback: () => null,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const pod = POD1();
|
|
161
|
-
pod.object.metadata.labels = {
|
|
162
|
-
foo: "bar",
|
|
163
|
-
test: "test1",
|
|
164
|
-
test2: "test2",
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
t.false(shouldSkipRequest(binding, pod));
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("should reject when annotation does not match", t => {
|
|
171
|
-
const binding = {
|
|
172
|
-
kind: gvkMap.V1Pod,
|
|
173
|
-
filters: {
|
|
174
|
-
name: "",
|
|
175
|
-
namespaces: [],
|
|
176
|
-
labels: {},
|
|
177
|
-
annotations: {
|
|
178
|
-
foo: "bar",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
callback: () => null,
|
|
182
|
-
};
|
|
183
|
-
const pod = POD1();
|
|
184
|
-
|
|
185
|
-
t.true(shouldSkipRequest(binding, pod));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test("should allow when annotation is match", t => {
|
|
189
|
-
const binding = {
|
|
190
|
-
kind: gvkMap.V1Pod,
|
|
191
|
-
filters: {
|
|
192
|
-
name: "",
|
|
193
|
-
namespaces: [],
|
|
194
|
-
labels: {},
|
|
195
|
-
annotations: {
|
|
196
|
-
foo: "bar",
|
|
197
|
-
test: "test1",
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
callback: () => null,
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const pod = POD1();
|
|
204
|
-
pod.object.metadata.annotations = {
|
|
205
|
-
foo: "bar",
|
|
206
|
-
test: "test1",
|
|
207
|
-
test2: "test2",
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
t.false(shouldSkipRequest(binding, pod));
|
|
211
|
-
});
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import { a, modelToGroupVersionKind } from "@k8s";
|
|
5
|
-
import test from "ava";
|
|
6
|
-
|
|
7
|
-
test("should return the correct GroupVersionKind for 'a.V1APIService'", t => {
|
|
8
|
-
const { name } = a.APIService;
|
|
9
|
-
const gvk = modelToGroupVersionKind(name);
|
|
10
|
-
t.is(gvk.group, "apiregistration.k8s.io");
|
|
11
|
-
t.is(gvk.version, "v1");
|
|
12
|
-
t.is(gvk.kind, "APIService");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("should return the correct GroupVersionKind for 'a.V1CertificateSigningRequest'", t => {
|
|
16
|
-
const { name } = a.CertificateSigningRequest;
|
|
17
|
-
const gvk = modelToGroupVersionKind(name);
|
|
18
|
-
t.is(gvk.group, "certificates.k8s.io");
|
|
19
|
-
t.is(gvk.version, "v1");
|
|
20
|
-
t.is(gvk.kind, "CertificateSigningRequest");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("should return the correct GroupVersionKind for 'a.V1ConfigMap'", t => {
|
|
24
|
-
const { name } = a.ConfigMap;
|
|
25
|
-
const gvk = modelToGroupVersionKind(name);
|
|
26
|
-
t.is(gvk.group, "");
|
|
27
|
-
t.is(gvk.version, "v1");
|
|
28
|
-
t.is(gvk.kind, "ConfigMap");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("should return the correct GroupVersionKind for 'a.V1ControllerRevision'", t => {
|
|
32
|
-
const { name } = a.ControllerRevision;
|
|
33
|
-
const gvk = modelToGroupVersionKind(name);
|
|
34
|
-
t.is(gvk.group, "apps");
|
|
35
|
-
t.is(gvk.version, "v1");
|
|
36
|
-
t.is(gvk.kind, "ControllerRevision");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("should return the correct GroupVersionKind for 'a.V1CronJob'", t => {
|
|
40
|
-
const { name } = a.CronJob;
|
|
41
|
-
const gvk = modelToGroupVersionKind(name);
|
|
42
|
-
t.is(gvk.group, "batch");
|
|
43
|
-
t.is(gvk.version, "v1");
|
|
44
|
-
t.is(gvk.kind, "CronJob");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test("should return the correct GroupVersionKind for 'a.V1CSIDriver'", t => {
|
|
48
|
-
const { name } = a.CSIDriver;
|
|
49
|
-
const gvk = modelToGroupVersionKind(name);
|
|
50
|
-
t.is(gvk.group, "storage.k8s.io");
|
|
51
|
-
t.is(gvk.version, "v1");
|
|
52
|
-
t.is(gvk.kind, "CSIDriver");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("should return the correct GroupVersionKind for 'a.V1CSIStorageCapacity'", t => {
|
|
56
|
-
const { name } = a.CSIStorageCapacity;
|
|
57
|
-
const gvk = modelToGroupVersionKind(name);
|
|
58
|
-
t.is(gvk.group, "storage.k8s.io");
|
|
59
|
-
t.is(gvk.version, "v1");
|
|
60
|
-
t.is(gvk.kind, "CSIStorageCapacity");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test("should return the correct GroupVersionKind for 'a.V1CustomResourceDefinition'", t => {
|
|
64
|
-
const { name } = a.CustomResourceDefinition;
|
|
65
|
-
const gvk = modelToGroupVersionKind(name);
|
|
66
|
-
t.is(gvk.group, "apiextensions.k8s.io");
|
|
67
|
-
t.is(gvk.version, "v1");
|
|
68
|
-
t.is(gvk.kind, "CustomResourceDefinition");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("should return the correct GroupVersionKind for 'a.V1DaemonSet'", t => {
|
|
72
|
-
const { name } = a.DaemonSet;
|
|
73
|
-
const gvk = modelToGroupVersionKind(name);
|
|
74
|
-
t.is(gvk.group, "apps");
|
|
75
|
-
t.is(gvk.version, "v1");
|
|
76
|
-
t.is(gvk.kind, "DaemonSet");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test("should return the correct GroupVersionKind for 'a.V1Deployment'", t => {
|
|
80
|
-
const { name } = a.Deployment;
|
|
81
|
-
const gvk = modelToGroupVersionKind(name);
|
|
82
|
-
t.is(gvk.group, "apps");
|
|
83
|
-
t.is(gvk.version, "v1");
|
|
84
|
-
t.is(gvk.kind, "Deployment");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test("should return the correct GroupVersionKind for 'a.V1Endpoint'", t => {
|
|
88
|
-
const { name } = a.Endpoint;
|
|
89
|
-
const gvk = modelToGroupVersionKind(name);
|
|
90
|
-
t.is(gvk.group, "");
|
|
91
|
-
t.is(gvk.version, "v1");
|
|
92
|
-
t.is(gvk.kind, "Endpoints");
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("should return the correct GroupVersionKind for 'a.V1EndpointSlice'", t => {
|
|
96
|
-
const { name } = a.EndpointSlice;
|
|
97
|
-
const gvk = modelToGroupVersionKind(name);
|
|
98
|
-
t.is(gvk.group, "discovery.k8s.io");
|
|
99
|
-
t.is(gvk.version, "v1");
|
|
100
|
-
t.is(gvk.kind, "EndpointSlice");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test("should return the correct GroupVersionKind for 'a.V1HorizontalPodAutoscaler'", t => {
|
|
104
|
-
const { name } = a.HorizontalPodAutoscaler;
|
|
105
|
-
const gvk = modelToGroupVersionKind(name);
|
|
106
|
-
t.is(gvk.group, "autoscaling");
|
|
107
|
-
t.is(gvk.version, "v2");
|
|
108
|
-
t.is(gvk.kind, "HorizontalPodAutoscaler");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test("should return the correct GroupVersionKind for 'a.V1Ingress'", t => {
|
|
112
|
-
const { name } = a.Ingress;
|
|
113
|
-
const gvk = modelToGroupVersionKind(name);
|
|
114
|
-
t.is(gvk.group, "networking.k8s.io");
|
|
115
|
-
t.is(gvk.version, "v1");
|
|
116
|
-
t.is(gvk.kind, "Ingress");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test("should return the correct GroupVersionKind for 'a.V1IngressClass'", t => {
|
|
120
|
-
const { name } = a.IngressClass;
|
|
121
|
-
const gvk = modelToGroupVersionKind(name);
|
|
122
|
-
t.is(gvk.group, "networking.k8s.io");
|
|
123
|
-
t.is(gvk.version, "v1");
|
|
124
|
-
t.is(gvk.kind, "IngressClass");
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test("should return the correct GroupVersionKind for 'a.V1Job'", t => {
|
|
128
|
-
const { name } = a.Job;
|
|
129
|
-
const gvk = modelToGroupVersionKind(name);
|
|
130
|
-
t.is(gvk.group, "batch");
|
|
131
|
-
t.is(gvk.version, "v1");
|
|
132
|
-
t.is(gvk.kind, "Job");
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("should return the correct GroupVersionKind for 'a.V1LimitRange'", t => {
|
|
136
|
-
const { name } = a.LimitRange;
|
|
137
|
-
const gvk = modelToGroupVersionKind(name);
|
|
138
|
-
t.is(gvk.group, "");
|
|
139
|
-
t.is(gvk.version, "v1");
|
|
140
|
-
t.is(gvk.kind, "LimitRange");
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("should return the correct GroupVersionKind for 'a.V1LocalSubjectAccessReview'", t => {
|
|
144
|
-
const { name } = a.LocalSubjectAccessReview;
|
|
145
|
-
const gvk = modelToGroupVersionKind(name);
|
|
146
|
-
t.is(gvk.group, "authorization.k8s.io");
|
|
147
|
-
t.is(gvk.version, "v1");
|
|
148
|
-
t.is(gvk.kind, "LocalSubjectAccessReview");
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test("should return the correct GroupVersionKind for 'a.V1MutatingWebhookConfiguration'", t => {
|
|
152
|
-
const { name } = a.MutatingWebhookConfiguration;
|
|
153
|
-
const gvk = modelToGroupVersionKind(name);
|
|
154
|
-
t.is(gvk.group, "admissionregistration.k8s.io");
|
|
155
|
-
t.is(gvk.version, "v1");
|
|
156
|
-
t.is(gvk.kind, "MutatingWebhookConfiguration");
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test("should return the correct GroupVersionKind for 'a.V1Namespace'", t => {
|
|
160
|
-
const { name } = a.Namespace;
|
|
161
|
-
const gvk = modelToGroupVersionKind(name);
|
|
162
|
-
t.is(gvk.group, "");
|
|
163
|
-
t.is(gvk.version, "v1");
|
|
164
|
-
t.is(gvk.kind, "Namespace");
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test("should return the correct GroupVersionKind for 'a.V1NetworkPolicy'", t => {
|
|
168
|
-
const { name } = a.NetworkPolicy;
|
|
169
|
-
const gvk = modelToGroupVersionKind(name);
|
|
170
|
-
t.is(gvk.group, "networking.k8s.io");
|
|
171
|
-
t.is(gvk.version, "v1");
|
|
172
|
-
t.is(gvk.kind, "NetworkPolicy");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test("should return the correct GroupVersionKind for 'a.V1Node'", t => {
|
|
176
|
-
const { name } = a.Node;
|
|
177
|
-
const gvk = modelToGroupVersionKind(name);
|
|
178
|
-
t.is(gvk.group, "");
|
|
179
|
-
t.is(gvk.version, "v1");
|
|
180
|
-
t.is(gvk.kind, "Node");
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test("should return the correct GroupVersionKind for 'a.V1PersistentVolume'", t => {
|
|
184
|
-
const { name } = a.PersistentVolume;
|
|
185
|
-
const gvk = modelToGroupVersionKind(name);
|
|
186
|
-
t.is(gvk.group, "");
|
|
187
|
-
t.is(gvk.version, "v1");
|
|
188
|
-
t.is(gvk.kind, "PersistentVolume");
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test("should return the correct GroupVersionKind for 'a.V1PersistentVolumeClaim'", t => {
|
|
192
|
-
const { name } = a.PersistentVolumeClaim;
|
|
193
|
-
const gvk = modelToGroupVersionKind(name);
|
|
194
|
-
t.is(gvk.group, "");
|
|
195
|
-
t.is(gvk.version, "v1");
|
|
196
|
-
t.is(gvk.kind, "PersistentVolumeClaim");
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
test("should return the correct GroupVersionKind for 'a.V1Pod'", t => {
|
|
200
|
-
const { name } = a.Pod;
|
|
201
|
-
const gvk = modelToGroupVersionKind(name);
|
|
202
|
-
t.is(gvk.group, "");
|
|
203
|
-
t.is(gvk.version, "v1");
|
|
204
|
-
t.is(gvk.kind, "Pod");
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test("should return the correct GroupVersionKind for 'a.V1PodDisruptionBudget'", t => {
|
|
208
|
-
const { name } = a.PodDisruptionBudget;
|
|
209
|
-
const gvk = modelToGroupVersionKind(name);
|
|
210
|
-
t.is(gvk.group, "policy");
|
|
211
|
-
t.is(gvk.version, "v1");
|
|
212
|
-
t.is(gvk.kind, "PodDisruptionBudget");
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test("should return the correct GroupVersionKind for 'a.V1PodTemplate'", t => {
|
|
216
|
-
const { name } = a.PodTemplate;
|
|
217
|
-
const gvk = modelToGroupVersionKind(name);
|
|
218
|
-
t.is(gvk.group, "");
|
|
219
|
-
t.is(gvk.version, "v1");
|
|
220
|
-
t.is(gvk.kind, "PodTemplate");
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
test("should return the correct GroupVersionKind for 'a.V1ReplicaSet'", t => {
|
|
224
|
-
const { name } = a.ReplicaSet;
|
|
225
|
-
const gvk = modelToGroupVersionKind(name);
|
|
226
|
-
t.is(gvk.group, "apps");
|
|
227
|
-
t.is(gvk.version, "v1");
|
|
228
|
-
t.is(gvk.kind, "ReplicaSet");
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
test("should return the correct GroupVersionKind for 'a.V1ReplicationController'", t => {
|
|
232
|
-
const { name } = a.ReplicationController;
|
|
233
|
-
const gvk = modelToGroupVersionKind(name);
|
|
234
|
-
t.is(gvk.group, "");
|
|
235
|
-
t.is(gvk.version, "v1");
|
|
236
|
-
t.is(gvk.kind, "ReplicationController");
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
test("should return the correct GroupVersionKind for 'a.V1ResourceQuota'", t => {
|
|
240
|
-
const { name } = a.ResourceQuota;
|
|
241
|
-
const gvk = modelToGroupVersionKind(name);
|
|
242
|
-
t.is(gvk.group, "");
|
|
243
|
-
t.is(gvk.version, "v1");
|
|
244
|
-
t.is(gvk.kind, "ResourceQuota");
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
test("should return the correct GroupVersionKind for 'a.V1RuntimeClass'", t => {
|
|
248
|
-
const { name } = a.RuntimeClass;
|
|
249
|
-
const gvk = modelToGroupVersionKind(name);
|
|
250
|
-
t.is(gvk.group, "node.k8s.io");
|
|
251
|
-
t.is(gvk.version, "v1");
|
|
252
|
-
t.is(gvk.kind, "RuntimeClass");
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test("should return the correct GroupVersionKind for 'a.V1Secret'", t => {
|
|
256
|
-
const { name } = a.Secret;
|
|
257
|
-
const gvk = modelToGroupVersionKind(name);
|
|
258
|
-
t.is(gvk.group, "");
|
|
259
|
-
t.is(gvk.version, "v1");
|
|
260
|
-
t.is(gvk.kind, "Secret");
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("should return the correct GroupVersionKind for 'a.V1SelfSubjectAccessReview'", t => {
|
|
264
|
-
const { name } = a.SelfSubjectAccessReview;
|
|
265
|
-
const gvk = modelToGroupVersionKind(name);
|
|
266
|
-
t.is(gvk.group, "authorization.k8s.io");
|
|
267
|
-
t.is(gvk.version, "v1");
|
|
268
|
-
t.is(gvk.kind, "SelfSubjectAccessReview");
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
test("should return the correct GroupVersionKind for 'a.V1SelfSubjectRulesReview'", t => {
|
|
272
|
-
const { name } = a.SelfSubjectRulesReview;
|
|
273
|
-
const gvk = modelToGroupVersionKind(name);
|
|
274
|
-
t.is(gvk.group, "authorization.k8s.io");
|
|
275
|
-
t.is(gvk.version, "v1");
|
|
276
|
-
t.is(gvk.kind, "SelfSubjectRulesReview");
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
test("should return the correct GroupVersionKind for 'a.V1Service'", t => {
|
|
280
|
-
const { name } = a.Service;
|
|
281
|
-
const gvk = modelToGroupVersionKind(name);
|
|
282
|
-
t.is(gvk.group, "");
|
|
283
|
-
t.is(gvk.version, "v1");
|
|
284
|
-
t.is(gvk.kind, "Service");
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test("should return the correct GroupVersionKind for 'a.V1ServiceAccount'", t => {
|
|
288
|
-
const { name } = a.ServiceAccount;
|
|
289
|
-
const gvk = modelToGroupVersionKind(name);
|
|
290
|
-
t.is(gvk.group, "");
|
|
291
|
-
t.is(gvk.version, "v1");
|
|
292
|
-
t.is(gvk.kind, "ServiceAccount");
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("should return the correct GroupVersionKind for 'a.V1StatefulSet'", t => {
|
|
296
|
-
const { name } = a.StatefulSet;
|
|
297
|
-
const gvk = modelToGroupVersionKind(name);
|
|
298
|
-
t.is(gvk.group, "apps");
|
|
299
|
-
t.is(gvk.version, "v1");
|
|
300
|
-
t.is(gvk.kind, "StatefulSet");
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
test("should return the correct GroupVersionKind for 'a.V1StorageClass'", t => {
|
|
304
|
-
const { name } = a.StorageClass;
|
|
305
|
-
const gvk = modelToGroupVersionKind(name);
|
|
306
|
-
t.is(gvk.group, "storage.k8s.io");
|
|
307
|
-
t.is(gvk.version, "v1");
|
|
308
|
-
t.is(gvk.kind, "StorageClass");
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test("should return the correct GroupVersionKind for 'a.V1SubjectAccessReview'", t => {
|
|
312
|
-
const { name } = a.SubjectAccessReview;
|
|
313
|
-
const gvk = modelToGroupVersionKind(name);
|
|
314
|
-
t.is(gvk.group, "authorization.k8s.io");
|
|
315
|
-
t.is(gvk.version, "v1");
|
|
316
|
-
t.is(gvk.kind, "SubjectAccessReview");
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
test("should return the correct GroupVersionKind for 'a.V1TokenReview'", t => {
|
|
320
|
-
const { name } = a.TokenReview;
|
|
321
|
-
const gvk = modelToGroupVersionKind(name);
|
|
322
|
-
t.is(gvk.group, "authentication.k8s.io");
|
|
323
|
-
t.is(gvk.version, "v1");
|
|
324
|
-
t.is(gvk.kind, "TokenReview");
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test("should return the correct GroupVersionKind for 'a.V1ValidatingWebhookConfiguration'", t => {
|
|
328
|
-
const { name } = a.ValidatingWebhookConfiguration;
|
|
329
|
-
const gvk = modelToGroupVersionKind(name);
|
|
330
|
-
t.is(gvk.group, "admissionregistration.k8s.io");
|
|
331
|
-
t.is(gvk.version, "v1");
|
|
332
|
-
t.is(gvk.kind, "ValidatingWebhookConfiguration");
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
test("should return the correct GroupVersionKind for 'a.V1VolumeAttachment'", t => {
|
|
336
|
-
const { name } = a.VolumeAttachment;
|
|
337
|
-
const gvk = modelToGroupVersionKind(name);
|
|
338
|
-
t.is(gvk.group, "storage.k8s.io");
|
|
339
|
-
t.is(gvk.version, "v1");
|
|
340
|
-
t.is(gvk.kind, "VolumeAttachment");
|
|
341
|
-
});
|
package/src/lib/logger.test.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import test from "ava";
|
|
5
|
-
import { Logger, LogLevel } from "./logger";
|
|
6
|
-
|
|
7
|
-
test("Logger debug logs correctly", t => {
|
|
8
|
-
const logger = new Logger(LogLevel.debug); // Create a logger with debug level
|
|
9
|
-
const message = "Debug message";
|
|
10
|
-
const consoleLog = console.log; // Store the original console.log function
|
|
11
|
-
const consoleOutput: string[] = [];
|
|
12
|
-
|
|
13
|
-
// Replace console.log with a mock function to capture the output
|
|
14
|
-
console.log = (output: string) => {
|
|
15
|
-
consoleOutput.push(output);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
logger.debug(message); // Call the debug method
|
|
19
|
-
|
|
20
|
-
// Check that the output matches the expected value
|
|
21
|
-
t.true(consoleOutput[0].includes(LogLevel[LogLevel.debug]));
|
|
22
|
-
t.true(consoleOutput[0].includes(message));
|
|
23
|
-
|
|
24
|
-
// Restore the original console.log function
|
|
25
|
-
console.log = consoleLog;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("Logger info logs correctly", t => {
|
|
29
|
-
const logger = new Logger(LogLevel.info); // Create a logger with info level
|
|
30
|
-
const message = "Info message";
|
|
31
|
-
const consoleLog = console.log;
|
|
32
|
-
const consoleOutput: string[] = [];
|
|
33
|
-
|
|
34
|
-
console.log = (output: string) => {
|
|
35
|
-
consoleOutput.push(output);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
logger.info(message);
|
|
39
|
-
|
|
40
|
-
t.true(consoleOutput[0].includes(LogLevel[LogLevel.info]));
|
|
41
|
-
t.true(consoleOutput[0].includes(message));
|
|
42
|
-
|
|
43
|
-
console.log = consoleLog;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("Logger warn logs correctly", t => {
|
|
47
|
-
const logger = new Logger(LogLevel.warn); // Create a logger with warn level
|
|
48
|
-
const message = "Warning message";
|
|
49
|
-
const consoleLog = console.log;
|
|
50
|
-
const consoleOutput: string[] = [];
|
|
51
|
-
|
|
52
|
-
console.log = (output: string) => {
|
|
53
|
-
consoleOutput.push(output);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
logger.warn(message);
|
|
57
|
-
|
|
58
|
-
t.true(consoleOutput[0].includes(LogLevel[LogLevel.warn]));
|
|
59
|
-
t.true(consoleOutput[0].includes(message));
|
|
60
|
-
|
|
61
|
-
console.log = consoleLog;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test("Logger error logs correctly", t => {
|
|
65
|
-
const logger = new Logger(LogLevel.error); // Create a logger with error level
|
|
66
|
-
const message = "Error message";
|
|
67
|
-
const consoleLog = console.log;
|
|
68
|
-
const consoleOutput: string[] = [];
|
|
69
|
-
|
|
70
|
-
console.log = (output: string) => {
|
|
71
|
-
consoleOutput.push(output);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
logger.error(message);
|
|
75
|
-
|
|
76
|
-
t.true(consoleOutput[0].includes(LogLevel[LogLevel.error]));
|
|
77
|
-
t.true(consoleOutput[0].includes(message));
|
|
78
|
-
|
|
79
|
-
console.log = consoleLog;
|
|
80
|
-
});
|