kubernetes-fluent-client 3.10.8 → 3.10.9-nightly.0

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.
@@ -121,5 +121,17 @@ export declare function processClassContext(line: string, insideClass: boolean,
121
121
  * @param logFn The logging function.
122
122
  */
123
123
  export declare function logError(error: Error, filePath: string, logFn: (msg: string) => void): void;
124
+ /**
125
+ * Extends the generated Metadata interface with V1ObjectMeta when the CRD
126
+ * schema for this version defines a metadata property.
127
+ *
128
+ * This ensures that generated types keep the full Kubernetes ObjectMeta
129
+ * contract while still including CRD-specific constraints like name enums.
130
+ *
131
+ * @param lines
132
+ * @param crd
133
+ * @param version
134
+ */
135
+ export declare function extendMetadataWithV1ObjectMeta(lines: string[], crd: CustomResourceDefinition, version: string): string[];
124
136
  export {};
125
137
  //# sourceMappingURL=postProcessing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postProcessing.d.ts","sourceRoot":"","sources":["../src/postProcessing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAMzD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,wBAAwB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAIvF;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,eAAe,iBAalF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAahF;AAED;;;;;;GAMG;AACH,wB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;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,MAAM,EAAE,EACf,GAAG,EAAE,wBAAwB,EAC7B,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAwEV"}
@@ -121,7 +121,10 @@ export function applyCRDPostProcessing(content, name, crd, version, opts) {
121
121
  }
122
122
  const foundInterfaces = collectInterfaceNames(lines);
123
123
  // Process the lines, focusing on classes extending `GenericKind`
124
- const processedLines = processLines(lines, genericKindProperties, foundInterfaces);
124
+ let processedLines = processLines(lines, genericKindProperties, foundInterfaces);
125
+ if (opts.language === "ts") {
126
+ processedLines = extendMetadataWithV1ObjectMeta(processedLines, crd, version);
127
+ }
125
128
  // Normalize the final output
126
129
  const normalizedLines = normalizeIndentationAndSpacing(processedLines, opts);
127
130
  return normalizedLines.join("\n");
@@ -254,3 +257,68 @@ export function logError(error, filePath, logFn) {
254
257
  logFn(`❌ Error processing file: ${filePath} - ${error.message}`);
255
258
  logFn(`Stack trace: ${error.stack}`);
256
259
  }
260
+ /**
261
+ * Extends the generated Metadata interface with V1ObjectMeta when the CRD
262
+ * schema for this version defines a metadata property.
263
+ *
264
+ * This ensures that generated types keep the full Kubernetes ObjectMeta
265
+ * contract while still including CRD-specific constraints like name enums.
266
+ *
267
+ * @param lines
268
+ * @param crd
269
+ * @param version
270
+ */
271
+ export function extendMetadataWithV1ObjectMeta(lines, crd, version) {
272
+ // Find the matching version in the CRD
273
+ const versionSchema = crd.spec?.versions?.find(v => v.name === version);
274
+ const openAPIV3Schema = versionSchema?.schema?.openAPIV3Schema;
275
+ // Only proceed if this version actually defines a metadata schema
276
+ const metadataSchema = openAPIV3Schema?.properties?.metadata;
277
+ if (!metadataSchema) {
278
+ return lines;
279
+ }
280
+ // Check if there's a Metadata interface at all
281
+ const metadataInterfaceRegex = /export interface Metadata\s*{/;
282
+ const hasMetadataInterface = lines.some(line => metadataInterfaceRegex.test(line));
283
+ if (!hasMetadataInterface) {
284
+ return lines;
285
+ }
286
+ // Avoid double-extending if we've already patched this file
287
+ const alreadyExtends = lines.some(line => /export interface Metadata\s+extends\s+V1ObjectMeta\s*{/.test(line));
288
+ let updatedLines = lines;
289
+ if (!alreadyExtends) {
290
+ updatedLines = updatedLines.map(line => line.replace(metadataInterfaceRegex, "export interface Metadata extends V1ObjectMeta {"));
291
+ }
292
+ // Ensure we import V1ObjectMeta from @kubernetes/client-node
293
+ const hasV1ObjectMetaImport = updatedLines.some(line => line.includes("V1ObjectMeta") &&
294
+ line.includes("@kubernetes/client-node") &&
295
+ line.includes("import"));
296
+ if (!hasV1ObjectMetaImport) {
297
+ const importStatement = 'import type { V1ObjectMeta } from "@kubernetes/client-node";';
298
+ // Insert after existing imports, if any; otherwise right after any auto-gen notice
299
+ let insertIndex = 0;
300
+ // Prefer to insert after the last import line at the top of the file
301
+ const firstImportIdx = updatedLines.findIndex(line => line.startsWith("import "));
302
+ if (firstImportIdx !== -1) {
303
+ let lastImportIdx = firstImportIdx;
304
+ for (let i = firstImportIdx + 1; i < updatedLines.length; i++) {
305
+ if (updatedLines[i].startsWith("import ")) {
306
+ lastImportIdx = i;
307
+ }
308
+ else {
309
+ break;
310
+ }
311
+ }
312
+ insertIndex = lastImportIdx + 1;
313
+ }
314
+ else {
315
+ // Otherwise, place after auto-gen notice if present
316
+ const autoGenIdx = updatedLines.findIndex(line => line.includes("auto-generated") || line.includes("auto generated"));
317
+ if (autoGenIdx !== -1) {
318
+ insertIndex = autoGenIdx + 1;
319
+ }
320
+ }
321
+ updatedLines.splice(insertIndex, 0, importStatement);
322
+ }
323
+ return updatedLines;
324
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubernetes-fluent-client",
3
- "version": "3.10.8",
3
+ "version": "3.10.9-nightly.0",
4
4
  "description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply.",
5
5
  "bin": "./dist/cli.js",
6
6
  "main": "dist/index.js",
@@ -72,15 +72,15 @@
72
72
  "@types/urijs": "^1.19.25",
73
73
  "@types/ws": "^8.18.1",
74
74
  "@types/yargs": "17.0.35",
75
- "@typescript-eslint/eslint-plugin": "8.47.0",
76
- "@typescript-eslint/parser": "8.47.0",
75
+ "@typescript-eslint/eslint-plugin": "8.48.0",
76
+ "@typescript-eslint/parser": "8.48.0",
77
77
  "@vitest/coverage-v8": "^4.0.1",
78
78
  "command-line-args": "^6.0.1",
79
- "eslint-plugin-jsdoc": "61.4.0",
79
+ "eslint-plugin-jsdoc": "61.4.1",
80
80
  "globals": "^16.0.0",
81
81
  "husky": "^9.1.6",
82
82
  "lint-staged": "^16.0.0",
83
- "prettier": "3.6.2",
83
+ "prettier": "3.7.3",
84
84
  "semantic-release": "25.0.2",
85
85
  "typescript": "5.9.3",
86
86
  "vitest": "^4.0.1"
@@ -164,7 +164,11 @@ export function applyCRDPostProcessing(
164
164
  const foundInterfaces = collectInterfaceNames(lines);
165
165
 
166
166
  // Process the lines, focusing on classes extending `GenericKind`
167
- const processedLines = processLines(lines, genericKindProperties, foundInterfaces);
167
+ let processedLines = processLines(lines, genericKindProperties, foundInterfaces);
168
+
169
+ if (opts.language === "ts") {
170
+ processedLines = extendMetadataWithV1ObjectMeta(processedLines, crd, version);
171
+ }
168
172
 
169
173
  // Normalize the final output
170
174
  const normalizedLines = normalizeIndentationAndSpacing(processedLines, opts);
@@ -348,3 +352,92 @@ export function logError(error: Error, filePath: string, logFn: (msg: string) =>
348
352
  logFn(`❌ Error processing file: ${filePath} - ${error.message}`);
349
353
  logFn(`Stack trace: ${error.stack}`);
350
354
  }
355
+
356
+ /**
357
+ * Extends the generated Metadata interface with V1ObjectMeta when the CRD
358
+ * schema for this version defines a metadata property.
359
+ *
360
+ * This ensures that generated types keep the full Kubernetes ObjectMeta
361
+ * contract while still including CRD-specific constraints like name enums.
362
+ *
363
+ * @param lines
364
+ * @param crd
365
+ * @param version
366
+ */
367
+ export function extendMetadataWithV1ObjectMeta(
368
+ lines: string[],
369
+ crd: CustomResourceDefinition,
370
+ version: string,
371
+ ): string[] {
372
+ // Find the matching version in the CRD
373
+ const versionSchema = crd.spec?.versions?.find(v => v.name === version);
374
+ const openAPIV3Schema = versionSchema?.schema?.openAPIV3Schema as
375
+ | { properties?: Record<string, unknown> }
376
+ | undefined;
377
+
378
+ // Only proceed if this version actually defines a metadata schema
379
+ const metadataSchema = openAPIV3Schema?.properties?.metadata;
380
+ if (!metadataSchema) {
381
+ return lines;
382
+ }
383
+
384
+ // Check if there's a Metadata interface at all
385
+ const metadataInterfaceRegex = /export interface Metadata\s*{/;
386
+ const hasMetadataInterface = lines.some(line => metadataInterfaceRegex.test(line));
387
+ if (!hasMetadataInterface) {
388
+ return lines;
389
+ }
390
+
391
+ // Avoid double-extending if we've already patched this file
392
+ const alreadyExtends = lines.some(line =>
393
+ /export interface Metadata\s+extends\s+V1ObjectMeta\s*{/.test(line),
394
+ );
395
+ let updatedLines = lines;
396
+
397
+ if (!alreadyExtends) {
398
+ updatedLines = updatedLines.map(line =>
399
+ line.replace(metadataInterfaceRegex, "export interface Metadata extends V1ObjectMeta {"),
400
+ );
401
+ }
402
+
403
+ // Ensure we import V1ObjectMeta from @kubernetes/client-node
404
+ const hasV1ObjectMetaImport = updatedLines.some(
405
+ line =>
406
+ line.includes("V1ObjectMeta") &&
407
+ line.includes("@kubernetes/client-node") &&
408
+ line.includes("import"),
409
+ );
410
+
411
+ if (!hasV1ObjectMetaImport) {
412
+ const importStatement = 'import type { V1ObjectMeta } from "@kubernetes/client-node";';
413
+
414
+ // Insert after existing imports, if any; otherwise right after any auto-gen notice
415
+ let insertIndex = 0;
416
+
417
+ // Prefer to insert after the last import line at the top of the file
418
+ const firstImportIdx = updatedLines.findIndex(line => line.startsWith("import "));
419
+ if (firstImportIdx !== -1) {
420
+ let lastImportIdx = firstImportIdx;
421
+ for (let i = firstImportIdx + 1; i < updatedLines.length; i++) {
422
+ if (updatedLines[i].startsWith("import ")) {
423
+ lastImportIdx = i;
424
+ } else {
425
+ break;
426
+ }
427
+ }
428
+ insertIndex = lastImportIdx + 1;
429
+ } else {
430
+ // Otherwise, place after auto-gen notice if present
431
+ const autoGenIdx = updatedLines.findIndex(
432
+ line => line.includes("auto-generated") || line.includes("auto generated"),
433
+ );
434
+ if (autoGenIdx !== -1) {
435
+ insertIndex = autoGenIdx + 1;
436
+ }
437
+ }
438
+
439
+ updatedLines.splice(insertIndex, 0, importStatement);
440
+ }
441
+
442
+ return updatedLines;
443
+ }