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,87 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import { Request } from "./k8s";
|
|
5
|
+
import logger from "./logger";
|
|
6
|
+
import { Binding } from "./types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* shouldSkipRequest determines if a request should be skipped based on the binding filters.
|
|
10
|
+
*
|
|
11
|
+
* @param binding the capability action binding
|
|
12
|
+
* @param req the incoming request
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export function shouldSkipRequest(binding: Binding, req: Request) {
|
|
16
|
+
const { group, kind, version } = binding.kind || {};
|
|
17
|
+
const { namespaces, labels, annotations, name } = binding.filters || {};
|
|
18
|
+
const { metadata } = req.object || {};
|
|
19
|
+
|
|
20
|
+
// Test for matching operation
|
|
21
|
+
if (binding.event && !binding.event.includes(req.operation)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Test name first, since it's the most specific
|
|
26
|
+
if (name && name !== req.name) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Test for matching kinds
|
|
31
|
+
if (kind !== req.kind.kind) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Test for matching groups
|
|
36
|
+
if (group && group !== req.kind.group) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Test for matching versions
|
|
41
|
+
if (version && version !== req.kind.version) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Test for matching namespaces
|
|
46
|
+
if (namespaces.length && !namespaces.includes(req.namespace || "")) {
|
|
47
|
+
logger.debug("Namespace does not match");
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Test for matching labels
|
|
52
|
+
for (const [key, value] of Object.entries(labels)) {
|
|
53
|
+
const testKey = metadata?.labels?.[key];
|
|
54
|
+
|
|
55
|
+
// First check if the label exists
|
|
56
|
+
if (!testKey) {
|
|
57
|
+
logger.debug(`Label ${key} does not exist`);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Then check if the value matches, if specified
|
|
62
|
+
if (value && testKey !== value) {
|
|
63
|
+
logger.debug(`${testKey} does not match ${value}`);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Test for matching annotations
|
|
69
|
+
for (const [key, value] of Object.entries(annotations)) {
|
|
70
|
+
const testKey = metadata?.annotations?.[key];
|
|
71
|
+
|
|
72
|
+
// First check if the annotation exists
|
|
73
|
+
if (!testKey) {
|
|
74
|
+
logger.debug(`Annotation ${key} does not exist`);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Then check if the value matches, if specified
|
|
79
|
+
if (value && testKey !== value) {
|
|
80
|
+
logger.debug(`${testKey} does not match ${value}`);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// No failed filters, so we should not skip this request
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
// Export kinds as a single object
|
|
1
5
|
import * as kind from "./upstream";
|
|
2
6
|
/** a is a collection of K8s types to be used within a CapabilityAction: `When(a.Configmap)` */
|
|
3
7
|
export { kind as a };
|
|
8
|
+
|
|
4
9
|
export { modelToGroupVersionKind, gvkMap, RegisterKind } from "./kinds";
|
|
10
|
+
|
|
5
11
|
export * from "./types";
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import test from "ava";
|
|
5
|
+
import { a, modelToGroupVersionKind } from ".";
|
|
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.V1EndpointSlice'", t => {
|
|
88
|
+
const { name } = a.EndpointSlice;
|
|
89
|
+
const gvk = modelToGroupVersionKind(name);
|
|
90
|
+
t.is(gvk.group, "discovery.k8s.io");
|
|
91
|
+
t.is(gvk.version, "v1");
|
|
92
|
+
t.is(gvk.kind, "EndpointSlice");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("should return the correct GroupVersionKind for 'a.V1HorizontalPodAutoscaler'", t => {
|
|
96
|
+
const { name } = a.HorizontalPodAutoscaler;
|
|
97
|
+
const gvk = modelToGroupVersionKind(name);
|
|
98
|
+
t.is(gvk.group, "autoscaling");
|
|
99
|
+
t.is(gvk.version, "v2");
|
|
100
|
+
t.is(gvk.kind, "HorizontalPodAutoscaler");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("should return the correct GroupVersionKind for 'a.V1Ingress'", t => {
|
|
104
|
+
const { name } = a.Ingress;
|
|
105
|
+
const gvk = modelToGroupVersionKind(name);
|
|
106
|
+
t.is(gvk.group, "networking.k8s.io");
|
|
107
|
+
t.is(gvk.version, "v1");
|
|
108
|
+
t.is(gvk.kind, "Ingress");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("should return the correct GroupVersionKind for 'a.V1IngressClass'", t => {
|
|
112
|
+
const { name } = a.IngressClass;
|
|
113
|
+
const gvk = modelToGroupVersionKind(name);
|
|
114
|
+
t.is(gvk.group, "networking.k8s.io");
|
|
115
|
+
t.is(gvk.version, "v1");
|
|
116
|
+
t.is(gvk.kind, "IngressClass");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("should return the correct GroupVersionKind for 'a.V1Job'", t => {
|
|
120
|
+
const { name } = a.Job;
|
|
121
|
+
const gvk = modelToGroupVersionKind(name);
|
|
122
|
+
t.is(gvk.group, "batch");
|
|
123
|
+
t.is(gvk.version, "v1");
|
|
124
|
+
t.is(gvk.kind, "Job");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("should return the correct GroupVersionKind for 'a.V1LimitRange'", t => {
|
|
128
|
+
const { name } = a.LimitRange;
|
|
129
|
+
const gvk = modelToGroupVersionKind(name);
|
|
130
|
+
t.is(gvk.group, "");
|
|
131
|
+
t.is(gvk.version, "v1");
|
|
132
|
+
t.is(gvk.kind, "LimitRange");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("should return the correct GroupVersionKind for 'a.V1LocalSubjectAccessReview'", t => {
|
|
136
|
+
const { name } = a.LocalSubjectAccessReview;
|
|
137
|
+
const gvk = modelToGroupVersionKind(name);
|
|
138
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
139
|
+
t.is(gvk.version, "v1");
|
|
140
|
+
t.is(gvk.kind, "LocalSubjectAccessReview");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("should return the correct GroupVersionKind for 'a.V1MutatingWebhookConfiguration'", t => {
|
|
144
|
+
const { name } = a.MutatingWebhookConfiguration;
|
|
145
|
+
const gvk = modelToGroupVersionKind(name);
|
|
146
|
+
t.is(gvk.group, "admissionregistration.k8s.io");
|
|
147
|
+
t.is(gvk.version, "v1");
|
|
148
|
+
t.is(gvk.kind, "MutatingWebhookConfiguration");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("should return the correct GroupVersionKind for 'a.V1Namespace'", t => {
|
|
152
|
+
const { name } = a.Namespace;
|
|
153
|
+
const gvk = modelToGroupVersionKind(name);
|
|
154
|
+
t.is(gvk.group, "");
|
|
155
|
+
t.is(gvk.version, "v1");
|
|
156
|
+
t.is(gvk.kind, "Namespace");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("should return the correct GroupVersionKind for 'a.V1NetworkPolicy'", t => {
|
|
160
|
+
const { name } = a.NetworkPolicy;
|
|
161
|
+
const gvk = modelToGroupVersionKind(name);
|
|
162
|
+
t.is(gvk.group, "networking.k8s.io");
|
|
163
|
+
t.is(gvk.version, "v1");
|
|
164
|
+
t.is(gvk.kind, "NetworkPolicy");
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("should return the correct GroupVersionKind for 'a.V1Node'", t => {
|
|
168
|
+
const { name } = a.Node;
|
|
169
|
+
const gvk = modelToGroupVersionKind(name);
|
|
170
|
+
t.is(gvk.group, "");
|
|
171
|
+
t.is(gvk.version, "v1");
|
|
172
|
+
t.is(gvk.kind, "Node");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("should return the correct GroupVersionKind for 'a.V1PersistentVolume'", t => {
|
|
176
|
+
const { name } = a.PersistentVolume;
|
|
177
|
+
const gvk = modelToGroupVersionKind(name);
|
|
178
|
+
t.is(gvk.group, "");
|
|
179
|
+
t.is(gvk.version, "v1");
|
|
180
|
+
t.is(gvk.kind, "PersistentVolume");
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("should return the correct GroupVersionKind for 'a.V1PersistentVolumeClaim'", t => {
|
|
184
|
+
const { name } = a.PersistentVolumeClaim;
|
|
185
|
+
const gvk = modelToGroupVersionKind(name);
|
|
186
|
+
t.is(gvk.group, "");
|
|
187
|
+
t.is(gvk.version, "v1");
|
|
188
|
+
t.is(gvk.kind, "PersistentVolumeClaim");
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("should return the correct GroupVersionKind for 'a.V1Pod'", t => {
|
|
192
|
+
const { name } = a.Pod;
|
|
193
|
+
const gvk = modelToGroupVersionKind(name);
|
|
194
|
+
t.is(gvk.group, "");
|
|
195
|
+
t.is(gvk.version, "v1");
|
|
196
|
+
t.is(gvk.kind, "Pod");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("should return the correct GroupVersionKind for 'a.V1PodDisruptionBudget'", t => {
|
|
200
|
+
const { name } = a.PodDisruptionBudget;
|
|
201
|
+
const gvk = modelToGroupVersionKind(name);
|
|
202
|
+
t.is(gvk.group, "policy");
|
|
203
|
+
t.is(gvk.version, "v1");
|
|
204
|
+
t.is(gvk.kind, "PodDisruptionBudget");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("should return the correct GroupVersionKind for 'a.V1PodTemplate'", t => {
|
|
208
|
+
const { name } = a.PodTemplate;
|
|
209
|
+
const gvk = modelToGroupVersionKind(name);
|
|
210
|
+
t.is(gvk.group, "");
|
|
211
|
+
t.is(gvk.version, "v1");
|
|
212
|
+
t.is(gvk.kind, "PodTemplate");
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test("should return the correct GroupVersionKind for 'a.V1ReplicaSet'", t => {
|
|
216
|
+
const { name } = a.ReplicaSet;
|
|
217
|
+
const gvk = modelToGroupVersionKind(name);
|
|
218
|
+
t.is(gvk.group, "apps");
|
|
219
|
+
t.is(gvk.version, "v1");
|
|
220
|
+
t.is(gvk.kind, "ReplicaSet");
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("should return the correct GroupVersionKind for 'a.V1ReplicationController'", t => {
|
|
224
|
+
const { name } = a.ReplicationController;
|
|
225
|
+
const gvk = modelToGroupVersionKind(name);
|
|
226
|
+
t.is(gvk.group, "");
|
|
227
|
+
t.is(gvk.version, "v1");
|
|
228
|
+
t.is(gvk.kind, "ReplicationController");
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("should return the correct GroupVersionKind for 'a.V1ResourceQuota'", t => {
|
|
232
|
+
const { name } = a.ResourceQuota;
|
|
233
|
+
const gvk = modelToGroupVersionKind(name);
|
|
234
|
+
t.is(gvk.group, "");
|
|
235
|
+
t.is(gvk.version, "v1");
|
|
236
|
+
t.is(gvk.kind, "ResourceQuota");
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test("should return the correct GroupVersionKind for 'a.V1RuntimeClass'", t => {
|
|
240
|
+
const { name } = a.RuntimeClass;
|
|
241
|
+
const gvk = modelToGroupVersionKind(name);
|
|
242
|
+
t.is(gvk.group, "node.k8s.io");
|
|
243
|
+
t.is(gvk.version, "v1");
|
|
244
|
+
t.is(gvk.kind, "RuntimeClass");
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("should return the correct GroupVersionKind for 'a.V1Secret'", t => {
|
|
248
|
+
const { name } = a.Secret;
|
|
249
|
+
const gvk = modelToGroupVersionKind(name);
|
|
250
|
+
t.is(gvk.group, "");
|
|
251
|
+
t.is(gvk.version, "v1");
|
|
252
|
+
t.is(gvk.kind, "Secret");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("should return the correct GroupVersionKind for 'a.V1SelfSubjectAccessReview'", t => {
|
|
256
|
+
const { name } = a.SelfSubjectAccessReview;
|
|
257
|
+
const gvk = modelToGroupVersionKind(name);
|
|
258
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
259
|
+
t.is(gvk.version, "v1");
|
|
260
|
+
t.is(gvk.kind, "SelfSubjectAccessReview");
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("should return the correct GroupVersionKind for 'a.V1SelfSubjectRulesReview'", t => {
|
|
264
|
+
const { name } = a.SelfSubjectRulesReview;
|
|
265
|
+
const gvk = modelToGroupVersionKind(name);
|
|
266
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
267
|
+
t.is(gvk.version, "v1");
|
|
268
|
+
t.is(gvk.kind, "SelfSubjectRulesReview");
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test("should return the correct GroupVersionKind for 'a.V1Service'", t => {
|
|
272
|
+
const { name } = a.Service;
|
|
273
|
+
const gvk = modelToGroupVersionKind(name);
|
|
274
|
+
t.is(gvk.group, "");
|
|
275
|
+
t.is(gvk.version, "v1");
|
|
276
|
+
t.is(gvk.kind, "Service");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("should return the correct GroupVersionKind for 'a.V1ServiceAccount'", t => {
|
|
280
|
+
const { name } = a.ServiceAccount;
|
|
281
|
+
const gvk = modelToGroupVersionKind(name);
|
|
282
|
+
t.is(gvk.group, "");
|
|
283
|
+
t.is(gvk.version, "v1");
|
|
284
|
+
t.is(gvk.kind, "ServiceAccount");
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("should return the correct GroupVersionKind for 'a.V1StatefulSet'", t => {
|
|
288
|
+
const { name } = a.StatefulSet;
|
|
289
|
+
const gvk = modelToGroupVersionKind(name);
|
|
290
|
+
t.is(gvk.group, "apps");
|
|
291
|
+
t.is(gvk.version, "v1");
|
|
292
|
+
t.is(gvk.kind, "StatefulSet");
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("should return the correct GroupVersionKind for 'a.V1StorageClass'", t => {
|
|
296
|
+
const { name } = a.StorageClass;
|
|
297
|
+
const gvk = modelToGroupVersionKind(name);
|
|
298
|
+
t.is(gvk.group, "storage.k8s.io");
|
|
299
|
+
t.is(gvk.version, "v1");
|
|
300
|
+
t.is(gvk.kind, "StorageClass");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
test("should return the correct GroupVersionKind for 'a.V1SubjectAccessReview'", t => {
|
|
304
|
+
const { name } = a.SubjectAccessReview;
|
|
305
|
+
const gvk = modelToGroupVersionKind(name);
|
|
306
|
+
t.is(gvk.group, "authorization.k8s.io");
|
|
307
|
+
t.is(gvk.version, "v1");
|
|
308
|
+
t.is(gvk.kind, "SubjectAccessReview");
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("should return the correct GroupVersionKind for 'a.V1TokenReview'", t => {
|
|
312
|
+
const { name } = a.TokenReview;
|
|
313
|
+
const gvk = modelToGroupVersionKind(name);
|
|
314
|
+
t.is(gvk.group, "authentication.k8s.io");
|
|
315
|
+
t.is(gvk.version, "v1");
|
|
316
|
+
t.is(gvk.kind, "TokenReview");
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test("should return the correct GroupVersionKind for 'a.V1ValidatingWebhookConfiguration'", t => {
|
|
320
|
+
const { name } = a.ValidatingWebhookConfiguration;
|
|
321
|
+
const gvk = modelToGroupVersionKind(name);
|
|
322
|
+
t.is(gvk.group, "admissionregistration.k8s.io");
|
|
323
|
+
t.is(gvk.version, "v1");
|
|
324
|
+
t.is(gvk.kind, "ValidatingWebhookConfiguration");
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("should return the correct GroupVersionKind for 'a.V1VolumeAttachment'", t => {
|
|
328
|
+
const { name } = a.VolumeAttachment;
|
|
329
|
+
const gvk = modelToGroupVersionKind(name);
|
|
330
|
+
t.is(gvk.group, "storage.k8s.io");
|
|
331
|
+
t.is(gvk.version, "v1");
|
|
332
|
+
t.is(gvk.kind, "VolumeAttachment");
|
|
333
|
+
});
|