kubernetes-fluent-client 3.0.3 → 3.0.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.
Files changed (81) hide show
  1. package/.prettierignore +4 -0
  2. package/README.md +24 -0
  3. package/e2e/cli.e2e.test.ts +127 -0
  4. package/e2e/crds/policyreports.default.expected/policyreport-v1alpha1.ts +332 -0
  5. package/e2e/crds/policyreports.default.expected/policyreport-v1alpha2.ts +360 -0
  6. package/e2e/crds/policyreports.default.expected/policyreport-v1beta1.ts +360 -0
  7. package/e2e/crds/policyreports.no.post.expected/policyreport-v1alpha1.ts +331 -0
  8. package/e2e/crds/policyreports.no.post.expected/policyreport-v1alpha2.ts +360 -0
  9. package/e2e/crds/policyreports.no.post.expected/policyreport-v1beta1.ts +360 -0
  10. package/e2e/crds/test.yaml/policyreports.test.yaml +1008 -0
  11. package/e2e/crds/test.yaml/uds-podmonitors.test.yaml +1245 -0
  12. package/e2e/crds/uds-podmonitors.default.expected/podmonitor-v1.ts +1333 -0
  13. package/e2e/crds/uds-podmonitors.no.post.expected/podmonitor-v1.ts +1360 -0
  14. package/package.json +8 -7
  15. package/src/cli.ts +25 -1
  16. package/src/fileSystem.test.ts +67 -0
  17. package/src/fileSystem.ts +25 -0
  18. package/src/generate.test.ts +368 -358
  19. package/src/generate.ts +173 -154
  20. package/src/postProcessing.test.ts +742 -0
  21. package/src/postProcessing.ts +568 -0
  22. package/dist/cli.d.ts +0 -3
  23. package/dist/cli.d.ts.map +0 -1
  24. package/dist/cli.js +0 -48
  25. package/dist/fetch.d.ts +0 -22
  26. package/dist/fetch.d.ts.map +0 -1
  27. package/dist/fetch.js +0 -82
  28. package/dist/fetch.test.d.ts +0 -2
  29. package/dist/fetch.test.d.ts.map +0 -1
  30. package/dist/fetch.test.js +0 -97
  31. package/dist/fluent/index.d.ts +0 -12
  32. package/dist/fluent/index.d.ts.map +0 -1
  33. package/dist/fluent/index.js +0 -228
  34. package/dist/fluent/index.test.d.ts +0 -2
  35. package/dist/fluent/index.test.d.ts.map +0 -1
  36. package/dist/fluent/index.test.js +0 -193
  37. package/dist/fluent/types.d.ts +0 -187
  38. package/dist/fluent/types.d.ts.map +0 -1
  39. package/dist/fluent/types.js +0 -16
  40. package/dist/fluent/utils.d.ts +0 -41
  41. package/dist/fluent/utils.d.ts.map +0 -1
  42. package/dist/fluent/utils.js +0 -153
  43. package/dist/fluent/utils.test.d.ts +0 -2
  44. package/dist/fluent/utils.test.d.ts.map +0 -1
  45. package/dist/fluent/utils.test.js +0 -215
  46. package/dist/fluent/watch.d.ts +0 -86
  47. package/dist/fluent/watch.d.ts.map +0 -1
  48. package/dist/fluent/watch.js +0 -425
  49. package/dist/fluent/watch.spec.d.ts +0 -2
  50. package/dist/fluent/watch.spec.d.ts.map +0 -1
  51. package/dist/fluent/watch.spec.js +0 -261
  52. package/dist/generate.d.ts +0 -24
  53. package/dist/generate.d.ts.map +0 -1
  54. package/dist/generate.js +0 -195
  55. package/dist/generate.test.d.ts +0 -2
  56. package/dist/generate.test.d.ts.map +0 -1
  57. package/dist/generate.test.js +0 -373
  58. package/dist/helpers.d.ts +0 -33
  59. package/dist/helpers.d.ts.map +0 -1
  60. package/dist/helpers.js +0 -103
  61. package/dist/helpers.test.d.ts +0 -2
  62. package/dist/helpers.test.d.ts.map +0 -1
  63. package/dist/helpers.test.js +0 -37
  64. package/dist/index.d.ts +0 -14
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/index.js +0 -60
  67. package/dist/kinds.d.ts +0 -16
  68. package/dist/kinds.d.ts.map +0 -1
  69. package/dist/kinds.js +0 -570
  70. package/dist/kinds.test.d.ts +0 -2
  71. package/dist/kinds.test.d.ts.map +0 -1
  72. package/dist/kinds.test.js +0 -155
  73. package/dist/patch.d.ts +0 -7
  74. package/dist/patch.d.ts.map +0 -1
  75. package/dist/patch.js +0 -2
  76. package/dist/types.d.ts +0 -32
  77. package/dist/types.d.ts.map +0 -1
  78. package/dist/types.js +0 -16
  79. package/dist/upstream.d.ts +0 -4
  80. package/dist/upstream.d.ts.map +0 -1
  81. package/dist/upstream.js +0 -56
@@ -1,373 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const globals_1 = require("@jest/globals");
7
- const generate_1 = require("./generate");
8
- const fs_1 = __importDefault(require("fs"));
9
- const sampleYaml = `
10
- # non-crd should be ignored
11
- apiVersion: v1
12
- kind: ConfigMap
13
- metadata:
14
- name: test
15
- namespace: default
16
- data:
17
- any: bleh
18
- ---
19
- apiVersion: apiextensions.k8s.io/v1
20
- kind: CustomResourceDefinition
21
- metadata:
22
- name: movies.example.com
23
- spec:
24
- group: example.com
25
- names:
26
- kind: Movie
27
- plural: movies
28
- scope: Namespaced
29
- versions:
30
- - name: v1
31
- schema:
32
- openAPIV3Schema:
33
- type: object
34
- description: Movie nerd
35
- properties:
36
- spec:
37
- properties:
38
- title:
39
- type: string
40
- author:
41
- type: string
42
- type: object
43
- ---
44
- # duplicate entries should not break things
45
- apiVersion: apiextensions.k8s.io/v1
46
- kind: CustomResourceDefinition
47
- metadata:
48
- name: movies.example.com
49
- spec:
50
- group: example.com
51
- names:
52
- kind: Movie
53
- plural: movies
54
- scope: Namespaced
55
- versions:
56
- - name: v1
57
- schema:
58
- openAPIV3Schema:
59
- type: object
60
- description: Movie nerd
61
- properties:
62
- spec:
63
- properties:
64
- title:
65
- type: string
66
- author:
67
- type: string
68
- type: object
69
- ---
70
- # should support multiple versions
71
- apiVersion: apiextensions.k8s.io/v1
72
- kind: CustomResourceDefinition
73
- metadata:
74
- name: books.example.com
75
- spec:
76
- group: example.com
77
- names:
78
- kind: Book
79
- plural: books
80
- scope: Namespaced
81
- versions:
82
- - name: v1
83
- schema:
84
- openAPIV3Schema:
85
- type: object
86
- description: Book nerd
87
- properties:
88
- spec:
89
- properties:
90
- title:
91
- type: string
92
- author:
93
- type: string
94
- type: object
95
- - name: v2
96
- schema:
97
- openAPIV3Schema:
98
- type: object
99
- description: Book nerd
100
- properties:
101
- spec:
102
- properties:
103
- author:
104
- type: string
105
- type: object
106
- served: true
107
- storage: true
108
- `;
109
- globals_1.jest.mock("./fetch", () => ({
110
- fetch: globals_1.jest.fn(),
111
- }));
112
- globals_1.jest.mock("./fluent", () => ({
113
- K8s: globals_1.jest.fn(),
114
- }));
115
- (0, globals_1.describe)("CRD Generate", () => {
116
- const originalReadFileSync = fs_1.default.readFileSync;
117
- globals_1.jest.spyOn(fs_1.default, "existsSync").mockReturnValue(true);
118
- globals_1.jest.spyOn(fs_1.default, "readFileSync").mockImplementation((...args) => {
119
- // Super janky hack due ot source-map-support calling readFileSync internally
120
- if (args[0].toString().includes("test-crd.yaml")) {
121
- return sampleYaml;
122
- }
123
- return originalReadFileSync(...args);
124
- });
125
- const mkdirSyncSpy = globals_1.jest.spyOn(fs_1.default, "mkdirSync").mockReturnValue(undefined);
126
- const writeFileSyncSpy = globals_1.jest.spyOn(fs_1.default, "writeFileSync").mockReturnValue(undefined);
127
- (0, globals_1.beforeEach)(() => {
128
- globals_1.jest.clearAllMocks();
129
- });
130
- (0, globals_1.test)("converts CRD to TypeScript", async () => {
131
- const options = { source: "test-crd.yaml", language: "ts", logFn: globals_1.jest.fn() };
132
- const actual = await (0, generate_1.generate)(options);
133
- const expectedMovie = [
134
- "// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
135
- 'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
136
- "/**",
137
- " * Movie nerd",
138
- " */",
139
- "export class Movie extends GenericKind {",
140
- " spec?: Spec;",
141
- "}",
142
- "",
143
- "export interface Spec {",
144
- " author?: string;",
145
- " title?: string;",
146
- "}",
147
- "",
148
- "RegisterKind(Movie, {",
149
- ' group: "example.com",',
150
- ' version: "v1",',
151
- ' kind: "Movie",',
152
- ' plural: "movies",',
153
- "});",
154
- ];
155
- const expectedBookV1 = [
156
- "// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
157
- 'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
158
- "/**",
159
- " * Book nerd",
160
- " */",
161
- "export class Book extends GenericKind {",
162
- " spec?: Spec;",
163
- "}",
164
- "",
165
- "export interface Spec {",
166
- " author?: string;",
167
- " title?: string;",
168
- "}",
169
- "",
170
- "RegisterKind(Book, {",
171
- ' group: "example.com",',
172
- ' version: "v1",',
173
- ' kind: "Book",',
174
- ' plural: "books",',
175
- "});",
176
- ];
177
- const expectedBookV2 = expectedBookV1
178
- .filter(line => !line.includes("title?"))
179
- .map(line => line.replace("v1", "v2"));
180
- (0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
181
- (0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
182
- (0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
183
- });
184
- (0, globals_1.test)("converts CRD to TypeScript with plain option", async () => {
185
- const options = { source: "test-crd.yaml", language: "ts", plain: true, logFn: globals_1.jest.fn() };
186
- const actual = await (0, generate_1.generate)(options);
187
- const expectedMovie = [
188
- "/**",
189
- " * Movie nerd",
190
- " */",
191
- "export interface Movie {",
192
- " spec?: Spec;",
193
- "}",
194
- "",
195
- "export interface Spec {",
196
- " author?: string;",
197
- " title?: string;",
198
- "}",
199
- "",
200
- ];
201
- const expectedBookV1 = [
202
- "/**",
203
- " * Book nerd",
204
- " */",
205
- "export interface Book {",
206
- " spec?: Spec;",
207
- "}",
208
- "",
209
- "export interface Spec {",
210
- " author?: string;",
211
- " title?: string;",
212
- "}",
213
- "",
214
- ];
215
- const expectedBookV2 = expectedBookV1
216
- .filter(line => !line.includes("title?"))
217
- .map(line => line.replace("v1", "v2"));
218
- (0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
219
- (0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
220
- (0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
221
- });
222
- (0, globals_1.test)("converts CRD to TypeScript with other options", async () => {
223
- const options = {
224
- source: "test-crd.yaml",
225
- npmPackage: "test-package",
226
- logFn: globals_1.jest.fn(),
227
- };
228
- const actual = await (0, generate_1.generate)(options);
229
- const expectedMovie = [
230
- "// This file is auto-generated by test-package, do not edit manually\n",
231
- 'import { GenericKind, RegisterKind } from "test-package";\n',
232
- "/**",
233
- " * Movie nerd",
234
- " */",
235
- "export class Movie extends GenericKind {",
236
- " spec?: Spec;",
237
- "}",
238
- "",
239
- "export interface Spec {",
240
- " author?: string;",
241
- " title?: string;",
242
- "}",
243
- "",
244
- "RegisterKind(Movie, {",
245
- ' group: "example.com",',
246
- ' version: "v1",',
247
- ' kind: "Movie",',
248
- ' plural: "movies",',
249
- "});",
250
- ];
251
- const expectedBookV1 = [
252
- "// This file is auto-generated by test-package, do not edit manually\n",
253
- 'import { GenericKind, RegisterKind } from "test-package";\n',
254
- "/**",
255
- " * Book nerd",
256
- " */",
257
- "export class Book extends GenericKind {",
258
- " spec?: Spec;",
259
- "}",
260
- "",
261
- "export interface Spec {",
262
- " author?: string;",
263
- " title?: string;",
264
- "}",
265
- "",
266
- "RegisterKind(Book, {",
267
- ' group: "example.com",',
268
- ' version: "v1",',
269
- ' kind: "Book",',
270
- ' plural: "books",',
271
- "});",
272
- ];
273
- const expectedBookV2 = expectedBookV1
274
- .filter(line => !line.includes("title?"))
275
- .map(line => line.replace("v1", "v2"));
276
- (0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
277
- (0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
278
- (0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
279
- });
280
- (0, globals_1.test)("converts CRD to TypeScript and writes to the given directory", async () => {
281
- const options = {
282
- source: "test-crd.yaml",
283
- directory: "test",
284
- logFn: globals_1.jest.fn(),
285
- };
286
- await (0, generate_1.generate)(options);
287
- const expectedMovie = [
288
- "// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
289
- 'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
290
- "/**",
291
- " * Movie nerd",
292
- " */",
293
- "export class Movie extends GenericKind {",
294
- " spec?: Spec;",
295
- "}",
296
- "",
297
- "export interface Spec {",
298
- " author?: string;",
299
- " title?: string;",
300
- "}",
301
- "",
302
- "RegisterKind(Movie, {",
303
- ' group: "example.com",',
304
- ' version: "v1",',
305
- ' kind: "Movie",',
306
- ' plural: "movies",',
307
- "});",
308
- ];
309
- const expectedBookV1 = [
310
- "// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
311
- 'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
312
- "/**",
313
- " * Book nerd",
314
- " */",
315
- "export class Book extends GenericKind {",
316
- " spec?: Spec;",
317
- "}",
318
- "",
319
- "export interface Spec {",
320
- " author?: string;",
321
- " title?: string;",
322
- "}",
323
- "",
324
- "RegisterKind(Book, {",
325
- ' group: "example.com",',
326
- ' version: "v1",',
327
- ' kind: "Book",',
328
- ' plural: "books",',
329
- "});",
330
- ];
331
- const expectedBookV2 = expectedBookV1
332
- .filter(line => !line.includes("title?"))
333
- .map(line => line.replace("v1", "v2"));
334
- (0, globals_1.expect)(mkdirSyncSpy).toHaveBeenCalledWith("test", { recursive: true });
335
- (0, globals_1.expect)(writeFileSyncSpy).toHaveBeenCalledWith("test/movie-v1.ts", expectedMovie.join("\n"));
336
- (0, globals_1.expect)(writeFileSyncSpy).toHaveBeenCalledWith("test/book-v1.ts", expectedBookV1.join("\n"));
337
- (0, globals_1.expect)(writeFileSyncSpy).toHaveBeenCalledWith("test/book-v2.ts", expectedBookV2.join("\n"));
338
- });
339
- (0, globals_1.test)("converts CRD to Go", async () => {
340
- const options = { source: "test-crd.yaml", language: "go", logFn: globals_1.jest.fn() };
341
- const actual = await (0, generate_1.generate)(options);
342
- const expectedMovie = [
343
- "// Movie nerd",
344
- "type Movie struct {",
345
- '\tSpec *Spec `json:"spec,omitempty"`',
346
- "}",
347
- "",
348
- "type Spec struct {",
349
- '\tAuthor *string `json:"author,omitempty"`',
350
- '\tTitle *string `json:"title,omitempty"`',
351
- "}",
352
- "",
353
- ];
354
- const expectedBookV1 = [
355
- "// Book nerd",
356
- "type Book struct {",
357
- '\tSpec *Spec `json:"spec,omitempty"`',
358
- "}",
359
- "",
360
- "type Spec struct {",
361
- '\tAuthor *string `json:"author,omitempty"`',
362
- '\tTitle *string `json:"title,omitempty"`',
363
- "}",
364
- "",
365
- ];
366
- const expectedBookV2 = expectedBookV1
367
- .filter(line => !line.includes("Title"))
368
- .map(line => line.replace("v1", "v2"));
369
- (0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
370
- (0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
371
- (0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
372
- });
373
- });
package/dist/helpers.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import { Cluster } from "@kubernetes/client-node";
2
- /**
3
- * Get an environment variable (Node, Deno or Bun), or throw an error if it's not set.
4
- *
5
- * @example
6
- * const value = fromEnv("MY_ENV_VAR");
7
- * console.log(value);
8
- * // => "my-value"
9
- *
10
- * @example
11
- * const value = fromEnv("MY_MISSING_ENV_VAR");
12
- * // => Error: Environment variable MY_MISSING_ENV_VAR is not set
13
- *
14
- * @param name The name of the environment variable to get.
15
- * @returns The value of the environment variable.
16
- * @throws An error if the environment variable is not set.
17
- */
18
- export declare function fromEnv(name: string): string;
19
- /**
20
- * Wait for the Kubernetes cluster to be ready.
21
- *
22
- * @param seconds The number of seconds to wait for the cluster to be ready.
23
- * @returns The current cluster.
24
- */
25
- export declare function waitForCluster(seconds?: number): Promise<Cluster>;
26
- /**
27
- * Determines if object has logs.
28
- *
29
- * @param kind The kind of Kubernetes object.
30
- * @returns boolean.
31
- */
32
- export declare function hasLogs(kind: string): boolean;
33
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAc,MAAM,yBAAyB,CAAC;AAkB9D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB5C;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,SAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAenE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAuB7C"}
package/dist/helpers.js DELETED
@@ -1,103 +0,0 @@
1
- "use strict";
2
- // SPDX-License-Identifier: Apache-2.0
3
- // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.fromEnv = fromEnv;
6
- exports.waitForCluster = waitForCluster;
7
- exports.hasLogs = hasLogs;
8
- const client_node_1 = require("@kubernetes/client-node");
9
- /**
10
- * Sleep for a number of seconds.
11
- *
12
- * @param seconds The number of seconds to sleep.
13
- * @returns A promise that resolves after the specified number of seconds.
14
- */
15
- function sleep(seconds) {
16
- return new Promise(resolve => setTimeout(resolve, seconds * 1000));
17
- }
18
- /**
19
- * Get an environment variable (Node, Deno or Bun), or throw an error if it's not set.
20
- *
21
- * @example
22
- * const value = fromEnv("MY_ENV_VAR");
23
- * console.log(value);
24
- * // => "my-value"
25
- *
26
- * @example
27
- * const value = fromEnv("MY_MISSING_ENV_VAR");
28
- * // => Error: Environment variable MY_MISSING_ENV_VAR is not set
29
- *
30
- * @param name The name of the environment variable to get.
31
- * @returns The value of the environment variable.
32
- * @throws An error if the environment variable is not set.
33
- */
34
- function fromEnv(name) {
35
- let envValue;
36
- // Check for Node.js or Bun
37
- if (typeof process !== "undefined" && typeof process.env !== "undefined") {
38
- envValue = process.env[name];
39
- }
40
- // Check for Deno
41
- else if (typeof Deno !== "undefined") {
42
- envValue = Deno.env.get(name);
43
- }
44
- // Otherwise, throw an error
45
- else {
46
- throw new Error("Unknown runtime environment");
47
- }
48
- if (typeof envValue === "undefined") {
49
- throw new Error(`Environment variable ${name} is not set`);
50
- }
51
- return envValue;
52
- }
53
- /**
54
- * Wait for the Kubernetes cluster to be ready.
55
- *
56
- * @param seconds The number of seconds to wait for the cluster to be ready.
57
- * @returns The current cluster.
58
- */
59
- async function waitForCluster(seconds = 30) {
60
- const kubeConfig = new client_node_1.KubeConfig();
61
- kubeConfig.loadFromDefault();
62
- const cluster = kubeConfig.getCurrentCluster();
63
- if (!cluster) {
64
- await sleep(1);
65
- if (seconds > 0) {
66
- return await waitForCluster(seconds - 1);
67
- }
68
- else {
69
- throw new Error("Cluster not ready");
70
- }
71
- }
72
- return cluster;
73
- }
74
- /**
75
- * Determines if object has logs.
76
- *
77
- * @param kind The kind of Kubernetes object.
78
- * @returns boolean.
79
- */
80
- function hasLogs(kind) {
81
- let hasSelector = false;
82
- switch (kind) {
83
- case "Pod":
84
- hasSelector = true;
85
- break;
86
- case "DaemonSet":
87
- hasSelector = true;
88
- break;
89
- case "ReplicaSet":
90
- hasSelector = true;
91
- break;
92
- case "Service":
93
- hasSelector = true;
94
- break;
95
- case "StatefulSet":
96
- hasSelector = true;
97
- break;
98
- case "Deployment":
99
- hasSelector = true;
100
- break;
101
- }
102
- return hasSelector;
103
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=helpers.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.test.d.ts","sourceRoot":"","sources":["../src/helpers.test.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- // SPDX-License-Identifier: Apache-2.0
3
- // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const globals_1 = require("@jest/globals");
6
- const helpers_1 = require("./helpers");
7
- (0, globals_1.describe)("helpers", () => {
8
- (0, globals_1.test)("fromEnv for NodeJS", () => {
9
- (0, globals_1.expect)(() => {
10
- (0, helpers_1.fromEnv)("MY_MISSING_ENV_VAR");
11
- }).toThrowError("Environment variable MY_MISSING_ENV_VAR is not set");
12
- process.env.MY_ENV_VAR = "my-value";
13
- (0, globals_1.expect)((0, helpers_1.fromEnv)("MY_ENV_VAR")).toEqual("my-value");
14
- delete process.env.MY_ENV_VAR;
15
- });
16
- });
17
- (0, globals_1.describe)("Cluster Wait Function", () => {
18
- (0, globals_1.it)("should resolve if the cluster is already ready", async () => {
19
- const cluster = await (0, helpers_1.waitForCluster)(5);
20
- (0, globals_1.expect)(cluster).toEqual({ server: "http://jest-test:8080" });
21
- });
22
- });
23
- (0, globals_1.describe)("hasLogs function", () => {
24
- (0, globals_1.it)("should return true for known kinds", () => {
25
- (0, globals_1.expect)((0, helpers_1.hasLogs)("Pod")).toBe(true);
26
- (0, globals_1.expect)((0, helpers_1.hasLogs)("DaemonSet")).toBe(true);
27
- (0, globals_1.expect)((0, helpers_1.hasLogs)("ReplicaSet")).toBe(true);
28
- (0, globals_1.expect)((0, helpers_1.hasLogs)("Service")).toBe(true);
29
- (0, globals_1.expect)((0, helpers_1.hasLogs)("StatefulSet")).toBe(true);
30
- (0, globals_1.expect)((0, helpers_1.hasLogs)("Deployment")).toBe(true);
31
- });
32
- (0, globals_1.it)("should return false for unknown kinds", () => {
33
- (0, globals_1.expect)((0, helpers_1.hasLogs)("Unknown")).toBe(false);
34
- (0, globals_1.expect)((0, helpers_1.hasLogs)("")).toBe(false);
35
- (0, globals_1.expect)((0, helpers_1.hasLogs)("RandomKind")).toBe(false);
36
- });
37
- });
package/dist/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import "./patch";
2
- import * as kind from "./upstream";
3
- /** kind is a collection of K8s types to be used within a K8s call: `K8s(kind.Secret).Apply({})`. */
4
- export { kind };
5
- export { fetch } from "./fetch";
6
- export { StatusCodes as fetchStatus } from "http-status-codes";
7
- export { WatchCfg, WatchEvent } from "./fluent/watch";
8
- export { K8s } from "./fluent";
9
- export { RegisterKind, modelToGroupVersionKind } from "./kinds";
10
- export { GenericKind } from "./types";
11
- export * from "./types";
12
- export * as models from "@kubernetes/client-node/dist/gen/models/all";
13
- export { fromEnv, waitForCluster } from "./helpers";
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,CAAC;AAGjB,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAEnC,oGAAoG;AACpG,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,MAAM,MAAM,6CAA6C,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js DELETED
@@ -1,60 +0,0 @@
1
- "use strict";
2
- // SPDX-License-Identifier: Apache-2.0
3
- // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
- desc = { enumerable: true, get: function() { return m[k]; } };
9
- }
10
- Object.defineProperty(o, k2, desc);
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v });
17
- }) : function(o, v) {
18
- o["default"] = v;
19
- });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
27
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.waitForCluster = exports.fromEnv = exports.models = exports.GenericKind = exports.modelToGroupVersionKind = exports.RegisterKind = exports.K8s = exports.WatchEvent = exports.fetchStatus = exports.kind = void 0;
32
- require("./patch");
33
- // Export kinds as a single object
34
- const kind = __importStar(require("./upstream"));
35
- exports.kind = kind;
36
- // Export the node-fetch wrapper
37
- var fetch_1 = require("./fetch");
38
- Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_1.fetch; } });
39
- // Export the HTTP status codes
40
- var http_status_codes_1 = require("http-status-codes");
41
- Object.defineProperty(exports, "fetchStatus", { enumerable: true, get: function () { return http_status_codes_1.StatusCodes; } });
42
- // Export the Watch Config and Event types
43
- var watch_1 = require("./fluent/watch");
44
- Object.defineProperty(exports, "WatchEvent", { enumerable: true, get: function () { return watch_1.WatchEvent; } });
45
- // Export the fluent API entrypoint
46
- var fluent_1 = require("./fluent");
47
- Object.defineProperty(exports, "K8s", { enumerable: true, get: function () { return fluent_1.K8s; } });
48
- // Export helpers for working with K8s types
49
- var kinds_1 = require("./kinds");
50
- Object.defineProperty(exports, "RegisterKind", { enumerable: true, get: function () { return kinds_1.RegisterKind; } });
51
- Object.defineProperty(exports, "modelToGroupVersionKind", { enumerable: true, get: function () { return kinds_1.modelToGroupVersionKind; } });
52
- // Export the GenericKind interface for CRD registration
53
- var types_1 = require("./types");
54
- Object.defineProperty(exports, "GenericKind", { enumerable: true, get: function () { return types_1.GenericKind; } });
55
- __exportStar(require("./types"), exports);
56
- // Export the upstream raw models
57
- exports.models = __importStar(require("@kubernetes/client-node/dist/gen/models/all"));
58
- var helpers_1 = require("./helpers");
59
- Object.defineProperty(exports, "fromEnv", { enumerable: true, get: function () { return helpers_1.fromEnv; } });
60
- Object.defineProperty(exports, "waitForCluster", { enumerable: true, get: function () { return helpers_1.waitForCluster; } });
package/dist/kinds.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { GenericClass, GroupVersionKind } from "./types";
2
- /**
3
- * Converts a model name to a GroupVersionKind
4
- *
5
- * @param key The name of the model
6
- * @returns The GroupVersionKind for the model
7
- */
8
- export declare function modelToGroupVersionKind(key: string): GroupVersionKind;
9
- /**
10
- * Registers a new model and GroupVersionKind to be used within the fluent API.
11
- *
12
- * @param model Used to match the GroupVersionKind and define the type-data for the request
13
- * @param groupVersionKind Contains the match parameters to determine the request should be handled
14
- */
15
- export declare const RegisterKind: (model: GenericClass, groupVersionKind: GroupVersionKind) => void;
16
- //# sourceMappingURL=kinds.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAqkBzD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAErE;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,YAAY,oBAAoB,gBAAgB,SAUnF,CAAC"}