kubernetes-fluent-client 1.5.1 → 1.6.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/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +46 -0
- package/dist/fetch.js +1 -1
- package/dist/fetch.test.js +1 -1
- package/dist/fluent/apply.js +1 -1
- package/dist/fluent/index.js +1 -1
- package/dist/fluent/types.js +1 -1
- package/dist/fluent/utils.js +1 -1
- package/dist/fluent/utils.test.js +1 -1
- package/dist/fluent/watch.js +1 -1
- package/dist/generate.d.ts +24 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +187 -0
- package/dist/generate.test.d.ts +2 -0
- package/dist/generate.test.d.ts.map +1 -0
- package/dist/generate.test.js +367 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/package.json +10 -5
- package/src/cli.ts +51 -0
- package/src/fetch.test.ts +1 -1
- package/src/fetch.ts +1 -1
- package/src/fluent/apply.ts +1 -1
- package/src/fluent/index.ts +1 -1
- package/src/fluent/types.ts +1 -1
- package/src/fluent/utils.test.ts +1 -1
- package/src/fluent/utils.ts +1 -1
- package/src/fluent/watch.ts +1 -1
- package/src/generate.test.ts +383 -0
- package/src/generate.ts +228 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,367 @@
|
|
|
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
|
+
"});",
|
|
153
|
+
];
|
|
154
|
+
const expectedBookV1 = [
|
|
155
|
+
"// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
|
|
156
|
+
'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
|
|
157
|
+
"/**",
|
|
158
|
+
" * Book nerd",
|
|
159
|
+
" */",
|
|
160
|
+
"export class Book extends GenericKind {",
|
|
161
|
+
" spec?: Spec;",
|
|
162
|
+
"}",
|
|
163
|
+
"",
|
|
164
|
+
"export interface Spec {",
|
|
165
|
+
" author?: string;",
|
|
166
|
+
" title?: string;",
|
|
167
|
+
"}",
|
|
168
|
+
"",
|
|
169
|
+
"RegisterKind(Book, {",
|
|
170
|
+
' group: "example.com",',
|
|
171
|
+
' version: "v1",',
|
|
172
|
+
' kind: "Book",',
|
|
173
|
+
"});",
|
|
174
|
+
];
|
|
175
|
+
const expectedBookV2 = expectedBookV1
|
|
176
|
+
.filter(line => !line.includes("title?"))
|
|
177
|
+
.map(line => line.replace("v1", "v2"));
|
|
178
|
+
(0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
|
|
179
|
+
(0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
|
|
180
|
+
(0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
|
|
181
|
+
});
|
|
182
|
+
(0, globals_1.test)("converts CRD to TypeScript with plain option", async () => {
|
|
183
|
+
const options = { source: "test-crd.yaml", language: "ts", plain: true, logFn: globals_1.jest.fn() };
|
|
184
|
+
const actual = await (0, generate_1.generate)(options);
|
|
185
|
+
const expectedMovie = [
|
|
186
|
+
"/**",
|
|
187
|
+
" * Movie nerd",
|
|
188
|
+
" */",
|
|
189
|
+
"export interface Movie {",
|
|
190
|
+
" spec?: Spec;",
|
|
191
|
+
"}",
|
|
192
|
+
"",
|
|
193
|
+
"export interface Spec {",
|
|
194
|
+
" author?: string;",
|
|
195
|
+
" title?: string;",
|
|
196
|
+
"}",
|
|
197
|
+
"",
|
|
198
|
+
];
|
|
199
|
+
const expectedBookV1 = [
|
|
200
|
+
"/**",
|
|
201
|
+
" * Book nerd",
|
|
202
|
+
" */",
|
|
203
|
+
"export interface Book {",
|
|
204
|
+
" spec?: Spec;",
|
|
205
|
+
"}",
|
|
206
|
+
"",
|
|
207
|
+
"export interface Spec {",
|
|
208
|
+
" author?: string;",
|
|
209
|
+
" title?: string;",
|
|
210
|
+
"}",
|
|
211
|
+
"",
|
|
212
|
+
];
|
|
213
|
+
const expectedBookV2 = expectedBookV1
|
|
214
|
+
.filter(line => !line.includes("title?"))
|
|
215
|
+
.map(line => line.replace("v1", "v2"));
|
|
216
|
+
(0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
|
|
217
|
+
(0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
|
|
218
|
+
(0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
|
|
219
|
+
});
|
|
220
|
+
(0, globals_1.test)("converts CRD to TypeScript with other options", async () => {
|
|
221
|
+
const options = {
|
|
222
|
+
source: "test-crd.yaml",
|
|
223
|
+
npmPackage: "test-package",
|
|
224
|
+
logFn: globals_1.jest.fn(),
|
|
225
|
+
};
|
|
226
|
+
const actual = await (0, generate_1.generate)(options);
|
|
227
|
+
const expectedMovie = [
|
|
228
|
+
"// This file is auto-generated by test-package, do not edit manually\n",
|
|
229
|
+
'import { GenericKind, RegisterKind } from "test-package";\n',
|
|
230
|
+
"/**",
|
|
231
|
+
" * Movie nerd",
|
|
232
|
+
" */",
|
|
233
|
+
"export class Movie extends GenericKind {",
|
|
234
|
+
" spec?: Spec;",
|
|
235
|
+
"}",
|
|
236
|
+
"",
|
|
237
|
+
"export interface Spec {",
|
|
238
|
+
" author?: string;",
|
|
239
|
+
" title?: string;",
|
|
240
|
+
"}",
|
|
241
|
+
"",
|
|
242
|
+
"RegisterKind(Movie, {",
|
|
243
|
+
' group: "example.com",',
|
|
244
|
+
' version: "v1",',
|
|
245
|
+
' kind: "Movie",',
|
|
246
|
+
"});",
|
|
247
|
+
];
|
|
248
|
+
const expectedBookV1 = [
|
|
249
|
+
"// This file is auto-generated by test-package, do not edit manually\n",
|
|
250
|
+
'import { GenericKind, RegisterKind } from "test-package";\n',
|
|
251
|
+
"/**",
|
|
252
|
+
" * Book nerd",
|
|
253
|
+
" */",
|
|
254
|
+
"export class Book extends GenericKind {",
|
|
255
|
+
" spec?: Spec;",
|
|
256
|
+
"}",
|
|
257
|
+
"",
|
|
258
|
+
"export interface Spec {",
|
|
259
|
+
" author?: string;",
|
|
260
|
+
" title?: string;",
|
|
261
|
+
"}",
|
|
262
|
+
"",
|
|
263
|
+
"RegisterKind(Book, {",
|
|
264
|
+
' group: "example.com",',
|
|
265
|
+
' version: "v1",',
|
|
266
|
+
' kind: "Book",',
|
|
267
|
+
"});",
|
|
268
|
+
];
|
|
269
|
+
const expectedBookV2 = expectedBookV1
|
|
270
|
+
.filter(line => !line.includes("title?"))
|
|
271
|
+
.map(line => line.replace("v1", "v2"));
|
|
272
|
+
(0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
|
|
273
|
+
(0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
|
|
274
|
+
(0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
|
|
275
|
+
});
|
|
276
|
+
(0, globals_1.test)("converts CRD to TypeScript and writes to the given directory", async () => {
|
|
277
|
+
const options = {
|
|
278
|
+
source: "test-crd.yaml",
|
|
279
|
+
directory: "test",
|
|
280
|
+
logFn: globals_1.jest.fn(),
|
|
281
|
+
};
|
|
282
|
+
await (0, generate_1.generate)(options);
|
|
283
|
+
const expectedMovie = [
|
|
284
|
+
"// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
|
|
285
|
+
'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
|
|
286
|
+
"/**",
|
|
287
|
+
" * Movie nerd",
|
|
288
|
+
" */",
|
|
289
|
+
"export class Movie extends GenericKind {",
|
|
290
|
+
" spec?: Spec;",
|
|
291
|
+
"}",
|
|
292
|
+
"",
|
|
293
|
+
"export interface Spec {",
|
|
294
|
+
" author?: string;",
|
|
295
|
+
" title?: string;",
|
|
296
|
+
"}",
|
|
297
|
+
"",
|
|
298
|
+
"RegisterKind(Movie, {",
|
|
299
|
+
' group: "example.com",',
|
|
300
|
+
' version: "v1",',
|
|
301
|
+
' kind: "Movie",',
|
|
302
|
+
"});",
|
|
303
|
+
];
|
|
304
|
+
const expectedBookV1 = [
|
|
305
|
+
"// This file is auto-generated by kubernetes-fluent-client, do not edit manually\n",
|
|
306
|
+
'import { GenericKind, RegisterKind } from "kubernetes-fluent-client";\n',
|
|
307
|
+
"/**",
|
|
308
|
+
" * Book nerd",
|
|
309
|
+
" */",
|
|
310
|
+
"export class Book extends GenericKind {",
|
|
311
|
+
" spec?: Spec;",
|
|
312
|
+
"}",
|
|
313
|
+
"",
|
|
314
|
+
"export interface Spec {",
|
|
315
|
+
" author?: string;",
|
|
316
|
+
" title?: string;",
|
|
317
|
+
"}",
|
|
318
|
+
"",
|
|
319
|
+
"RegisterKind(Book, {",
|
|
320
|
+
' group: "example.com",',
|
|
321
|
+
' version: "v1",',
|
|
322
|
+
' kind: "Book",',
|
|
323
|
+
"});",
|
|
324
|
+
];
|
|
325
|
+
const expectedBookV2 = expectedBookV1
|
|
326
|
+
.filter(line => !line.includes("title?"))
|
|
327
|
+
.map(line => line.replace("v1", "v2"));
|
|
328
|
+
(0, globals_1.expect)(mkdirSyncSpy).toHaveBeenCalledWith("test", { recursive: true });
|
|
329
|
+
(0, globals_1.expect)(writeFileSyncSpy).toHaveBeenCalledWith("test/movie-v1.ts", expectedMovie.join("\n"));
|
|
330
|
+
(0, globals_1.expect)(writeFileSyncSpy).toHaveBeenCalledWith("test/book-v1.ts", expectedBookV1.join("\n"));
|
|
331
|
+
(0, globals_1.expect)(writeFileSyncSpy).toHaveBeenCalledWith("test/book-v2.ts", expectedBookV2.join("\n"));
|
|
332
|
+
});
|
|
333
|
+
(0, globals_1.test)("converts CRD to Go", async () => {
|
|
334
|
+
const options = { source: "test-crd.yaml", language: "go", logFn: globals_1.jest.fn() };
|
|
335
|
+
const actual = await (0, generate_1.generate)(options);
|
|
336
|
+
const expectedMovie = [
|
|
337
|
+
"// Movie nerd",
|
|
338
|
+
"type Movie struct {",
|
|
339
|
+
'\tSpec *Spec `json:"spec,omitempty"`',
|
|
340
|
+
"}",
|
|
341
|
+
"",
|
|
342
|
+
"type Spec struct {",
|
|
343
|
+
'\tAuthor *string `json:"author,omitempty"`',
|
|
344
|
+
'\tTitle *string `json:"title,omitempty"`',
|
|
345
|
+
"}",
|
|
346
|
+
"",
|
|
347
|
+
];
|
|
348
|
+
const expectedBookV1 = [
|
|
349
|
+
"// Book nerd",
|
|
350
|
+
"type Book struct {",
|
|
351
|
+
'\tSpec *Spec `json:"spec,omitempty"`',
|
|
352
|
+
"}",
|
|
353
|
+
"",
|
|
354
|
+
"type Spec struct {",
|
|
355
|
+
'\tAuthor *string `json:"author,omitempty"`',
|
|
356
|
+
'\tTitle *string `json:"title,omitempty"`',
|
|
357
|
+
"}",
|
|
358
|
+
"",
|
|
359
|
+
];
|
|
360
|
+
const expectedBookV2 = expectedBookV1
|
|
361
|
+
.filter(line => !line.includes("Title"))
|
|
362
|
+
.map(line => line.replace("v1", "v2"));
|
|
363
|
+
(0, globals_1.expect)(actual["movie-v1"]).toEqual(expectedMovie);
|
|
364
|
+
(0, globals_1.expect)(actual["book-v1"]).toEqual(expectedBookV1);
|
|
365
|
+
(0, globals_1.expect)(actual["book-v2"]).toEqual(expectedBookV2);
|
|
366
|
+
});
|
|
367
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { fetch } from "./fetch";
|
|
|
5
5
|
export { StatusCodes as fetchStatus } from "http-status-codes";
|
|
6
6
|
export { K8s } from "./fluent";
|
|
7
7
|
export { RegisterKind, modelToGroupVersionKind } from "./kinds";
|
|
8
|
+
export { GenericKind } from "./types";
|
|
8
9
|
export * from "./types";
|
|
9
10
|
export * as K8sClientNode from "@kubernetes/client-node";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,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,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,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,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;AAExB,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
28
28
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.K8sClientNode = exports.modelToGroupVersionKind = exports.RegisterKind = exports.K8s = exports.fetchStatus = exports.fetch = exports.kind = void 0;
|
|
31
|
+
exports.K8sClientNode = exports.GenericKind = exports.modelToGroupVersionKind = exports.RegisterKind = exports.K8s = exports.fetchStatus = exports.fetch = exports.kind = void 0;
|
|
32
32
|
// Export kinds as a single object
|
|
33
33
|
const kind = __importStar(require("./upstream"));
|
|
34
34
|
exports.kind = kind;
|
|
@@ -45,5 +45,8 @@ Object.defineProperty(exports, "K8s", { enumerable: true, get: function () { ret
|
|
|
45
45
|
var kinds_1 = require("./kinds");
|
|
46
46
|
Object.defineProperty(exports, "RegisterKind", { enumerable: true, get: function () { return kinds_1.RegisterKind; } });
|
|
47
47
|
Object.defineProperty(exports, "modelToGroupVersionKind", { enumerable: true, get: function () { return kinds_1.modelToGroupVersionKind; } });
|
|
48
|
+
// Export the GenericKind interface for CRD registration
|
|
49
|
+
var types_1 = require("./types");
|
|
50
|
+
Object.defineProperty(exports, "GenericKind", { enumerable: true, get: function () { return types_1.GenericKind; } });
|
|
48
51
|
__exportStar(require("./types"), exports);
|
|
49
52
|
exports.K8sClientNode = __importStar(require("@kubernetes/client-node"));
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kubernetes-fluent-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply",
|
|
5
|
+
"bin": "./dist/cli.js",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
@@ -39,18 +40,22 @@
|
|
|
39
40
|
"fast-json-patch": "3.1.1",
|
|
40
41
|
"http-status-codes": "2.3.0",
|
|
41
42
|
"node-fetch": "2.7.0",
|
|
42
|
-
"
|
|
43
|
+
"quicktype-core": "23.0.76",
|
|
44
|
+
"type-fest": "4.4.0",
|
|
45
|
+
"yargs": "17.7.2"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
48
|
"@commitlint/cli": "17.7.2",
|
|
46
49
|
"@commitlint/config-conventional": "17.7.0",
|
|
47
50
|
"@jest/globals": "29.7.0",
|
|
48
51
|
"@types/byline": "4.2.34",
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
52
|
+
"@types/readable-stream": "4.0.3",
|
|
53
|
+
"@types/yargs": "17.0.28",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "6.7.5",
|
|
55
|
+
"@typescript-eslint/parser": "6.7.5",
|
|
51
56
|
"eslint-plugin-jsdoc": "46.8.2",
|
|
52
57
|
"jest": "29.7.0",
|
|
53
|
-
"nock": "13.3.
|
|
58
|
+
"nock": "13.3.4",
|
|
54
59
|
"prettier": "3.0.3",
|
|
55
60
|
"semantic-release": "22.0.5",
|
|
56
61
|
"ts-jest": "29.1.1",
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
5
|
+
|
|
6
|
+
import { hideBin } from "yargs/helpers";
|
|
7
|
+
import yargs from "yargs/yargs";
|
|
8
|
+
import { GenerateOptions, generate } from "./generate";
|
|
9
|
+
|
|
10
|
+
void yargs(hideBin(process.argv))
|
|
11
|
+
.version(false)
|
|
12
|
+
.command(
|
|
13
|
+
"crd [source] [directory]",
|
|
14
|
+
"generate usable types from a K8s CRD",
|
|
15
|
+
yargs => {
|
|
16
|
+
return yargs
|
|
17
|
+
.positional("source", {
|
|
18
|
+
describe: "the yaml file path, remote url, or K8s CRD name",
|
|
19
|
+
type: "string",
|
|
20
|
+
})
|
|
21
|
+
.positional("directory", {
|
|
22
|
+
describe: "the directory to output the generated types to",
|
|
23
|
+
type: "string",
|
|
24
|
+
})
|
|
25
|
+
.option("plain", {
|
|
26
|
+
alias: "p",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
description:
|
|
29
|
+
"generate plain types without binding to the fluent client, automatically enabled when an alternate language is specified",
|
|
30
|
+
})
|
|
31
|
+
.option("language", {
|
|
32
|
+
alias: "l",
|
|
33
|
+
type: "string",
|
|
34
|
+
default: "ts",
|
|
35
|
+
description:
|
|
36
|
+
"the language to generate types in, see https://github.com/glideapps/quicktype#target-languages for a list of supported languages",
|
|
37
|
+
})
|
|
38
|
+
.demandOption(["source", "directory"]);
|
|
39
|
+
},
|
|
40
|
+
async argv => {
|
|
41
|
+
const opts = argv as unknown as GenerateOptions;
|
|
42
|
+
opts.logFn = console.log;
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
await generate(opts);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.log(`\n❌ ${e.message}`);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
.parse();
|
package/src/fetch.test.ts
CHANGED
package/src/fetch.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
3
3
|
|
|
4
4
|
import { StatusCodes } from "http-status-codes";
|
|
5
5
|
import fetchRaw, { FetchError, RequestInfo, RequestInit } from "node-fetch";
|
package/src/fluent/apply.ts
CHANGED
package/src/fluent/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
3
3
|
|
|
4
4
|
import { KubernetesListObject, KubernetesObject } from "@kubernetes/client-node";
|
|
5
5
|
import { Operation } from "fast-json-patch";
|
package/src/fluent/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
|
|
3
3
|
|
|
4
4
|
import { KubernetesListObject, KubernetesObject } from "@kubernetes/client-node";
|
|
5
5
|
import { Operation } from "fast-json-patch";
|
package/src/fluent/utils.test.ts
CHANGED
package/src/fluent/utils.ts
CHANGED
package/src/fluent/watch.ts
CHANGED