kubernetes-fluent-client 3.10.12-nightly.7 → 3.10.12-nightly.9
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/fetch.d.ts.map +1 -1
- package/dist/fetch.js +0 -5
- package/dist/fluent/watch.d.ts.map +1 -1
- package/dist/fluent/watch.js +7 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/package.json +3 -3
- package/src/fetch.ts +0 -8
- package/src/fluent/watch.ts +7 -33
- package/src/index.ts +0 -1
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAExE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAC3B,GAAG,EAAE,GAAG,GAAG,WAAW,EACtB,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAExE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAC3B,GAAG,EAAE,GAAG,GAAG,WAAW,EACtB,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CA+B3B"}
|
package/dist/fetch.js
CHANGED
|
@@ -20,11 +20,6 @@ export async function fetch(url, init) {
|
|
|
20
20
|
try {
|
|
21
21
|
const resp = await undiciFetch(url, init);
|
|
22
22
|
const contentType = resp.headers.get("content-type") || "";
|
|
23
|
-
console.log(`FETCH_HEADERS: `, JSON.stringify([...resp.headers]) +
|
|
24
|
-
"\nFETCH_URL: " +
|
|
25
|
-
url.toString() +
|
|
26
|
-
"\nFETCH_STATUS: " +
|
|
27
|
-
resp.status);
|
|
28
23
|
// Parse the response as JSON if the content type is JSON
|
|
29
24
|
if (contentType.includes("application/json")) {
|
|
30
25
|
data = (await resp.json());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/fluent/watch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,YAAY,EAAwB,MAAM,aAAa,CAAC;AAGjE,OAAO,EAGL,WAAW,EACX,OAAO,EAER,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/fluent/watch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,YAAY,EAAwB,MAAM,aAAa,CAAC;AAGjE,OAAO,EAGL,WAAW,EACX,OAAO,EAER,MAAM,mBAAmB,CAAC;AAC3B,oBAAY,UAAU;IACpB,sCAAsC;IACtC,OAAO,YAAY;IACnB,2BAA2B;IAC3B,aAAa,kBAAkB;IAC/B,kDAAkD;IAClD,UAAU,eAAe;IACzB,0BAA0B;IAC1B,SAAS,cAAc;IACvB,8BAA8B;IAC9B,OAAO,YAAY;IACnB,sBAAsB;IACtB,KAAK,UAAU;IACf,mCAAmC;IACnC,IAAI,SAAS;IACb,wCAAwC;IACxC,oBAAoB,yBAAyB;IAC7C,qCAAqC;IACrC,iBAAiB,sBAAsB;IACvC,kCAAkC;IAClC,IAAI,SAAS;IACb,2BAA2B;IAC3B,UAAU,eAAe;IACzB,mBAAmB;IACnB,UAAU,eAAe;IACzB,qCAAqC;IACrC,wBAAwB,6BAA6B;IACrD,iCAAiC;IACjC,eAAe,oBAAoB;CACpC;AAED,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,GAAG;IACrB,+HAA+H;IAC/H,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wHAAwH;IACxH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAKF,iDAAiD;AACjD,qBAAa,OAAO,CAAC,CAAC,SAAS,YAAY;;IAyBzC,YAAY,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IAc9B;;;;;;;;;;;OAWG;gBACS,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAE,QAAa;IA0CzF;;;;OAIG;IACU,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC;IAO9C,gGAAgG;IACzF,KAAK;IAQZ;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,YAAY,CAEhC;CA0VF"}
|
package/dist/fluent/watch.js
CHANGED
|
@@ -6,9 +6,6 @@ import { fetch as wrappedFetch } from "../fetch.js";
|
|
|
6
6
|
import { k8sCfg, pathBuilder, getHeaders } from "./utils.js";
|
|
7
7
|
import { Readable } from "stream";
|
|
8
8
|
import { WatchPhase, FetchMethods, } from "./shared-types.js";
|
|
9
|
-
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
10
|
-
let startSleep = 5000;
|
|
11
|
-
const maxSleep = 120000;
|
|
12
9
|
export var WatchEvent;
|
|
13
10
|
(function (WatchEvent) {
|
|
14
11
|
/** Watch is connected successfully */
|
|
@@ -103,7 +100,7 @@ export class Watcher {
|
|
|
103
100
|
void this.#list();
|
|
104
101
|
}, watchCfg.relistIntervalSec * 1000 + jitter);
|
|
105
102
|
// Rebuild the watch every resync delay interval
|
|
106
|
-
this.#resyncTimer = setInterval(
|
|
103
|
+
this.#resyncTimer = setInterval(this.#checkResync, watchCfg.resyncDelaySec * 1000 + jitter);
|
|
107
104
|
// Bind class properties
|
|
108
105
|
this.#model = model;
|
|
109
106
|
this.#filters = filters;
|
|
@@ -186,10 +183,6 @@ export class Watcher {
|
|
|
186
183
|
const list = response.data;
|
|
187
184
|
// If the request fails, emit an error event and return
|
|
188
185
|
if (!response.ok) {
|
|
189
|
-
// Backoff here
|
|
190
|
-
await sleep(startSleep);
|
|
191
|
-
startSleep = Math.min(startSleep * 2, maxSleep);
|
|
192
|
-
await this.#list(continueToken, removedItems);
|
|
193
186
|
this.#events.emit(WatchEvent.LIST_ERROR, new Error(`list failed: ${response.status} ${response.statusText}`));
|
|
194
187
|
return;
|
|
195
188
|
}
|
|
@@ -309,11 +302,6 @@ export class Watcher {
|
|
|
309
302
|
headers: await getHeaders(),
|
|
310
303
|
...opts,
|
|
311
304
|
});
|
|
312
|
-
console.log(`WATCH_FETCH: `, JSON.stringify([...response.headers]) +
|
|
313
|
-
"\nWATCH_URL: " +
|
|
314
|
-
serverUrl.toString() +
|
|
315
|
-
"\nWATCH_STATUS: " +
|
|
316
|
-
response.status);
|
|
317
305
|
const url = serverUrl instanceof URL ? serverUrl : new URL(serverUrl);
|
|
318
306
|
// If the request is successful, start listening for events
|
|
319
307
|
if (response.ok) {
|
|
@@ -325,7 +313,6 @@ export class Watcher {
|
|
|
325
313
|
throw new Error("No response body found");
|
|
326
314
|
}
|
|
327
315
|
// Reset the retry count
|
|
328
|
-
startSleep = 5000;
|
|
329
316
|
this.#resyncFailureCount = 0;
|
|
330
317
|
this.#events.emit(WatchEvent.INC_RESYNC_FAILURE_COUNT, this.#resyncFailureCount);
|
|
331
318
|
this.#stream = Readable.from(body);
|
|
@@ -345,24 +332,21 @@ export class Watcher {
|
|
|
345
332
|
void this.#errHandler(err);
|
|
346
333
|
}
|
|
347
334
|
});
|
|
348
|
-
this.#stream.on("close",
|
|
349
|
-
this.#stream.on("end",
|
|
335
|
+
this.#stream.on("close", this.#cleanupAndReconnect);
|
|
336
|
+
this.#stream.on("end", this.#cleanupAndReconnect);
|
|
350
337
|
this.#stream.on("error", this.#errHandler);
|
|
351
|
-
this.#stream.on("finish",
|
|
338
|
+
this.#stream.on("finish", this.#cleanupAndReconnect);
|
|
352
339
|
}
|
|
353
340
|
else {
|
|
354
341
|
throw new Error(`watch connect failed: ${response.status} ${response.statusText}`);
|
|
355
342
|
}
|
|
356
343
|
}
|
|
357
344
|
catch (e) {
|
|
358
|
-
// await sleep(startSleep);
|
|
359
|
-
// startSleep = Math.min(startSleep * 2, maxSleep);
|
|
360
|
-
console.log(`WATCH_ERROR: `, e);
|
|
361
345
|
void this.#errHandler(e);
|
|
362
346
|
}
|
|
363
347
|
};
|
|
364
348
|
/** Clear the resync timer and schedule a new one. */
|
|
365
|
-
#checkResync =
|
|
349
|
+
#checkResync = () => {
|
|
366
350
|
// Ignore if the last seen time is not set
|
|
367
351
|
if (this.#lastSeenTime === NONE) {
|
|
368
352
|
return;
|
|
@@ -385,7 +369,7 @@ export class Watcher {
|
|
|
385
369
|
else {
|
|
386
370
|
this.#pendingReconnect = true;
|
|
387
371
|
this.#events.emit(WatchEvent.RECONNECT, this.#resyncFailureCount);
|
|
388
|
-
|
|
372
|
+
this.#cleanupAndReconnect();
|
|
389
373
|
}
|
|
390
374
|
}
|
|
391
375
|
else {
|
|
@@ -421,10 +405,8 @@ export class Watcher {
|
|
|
421
405
|
this.#lastSeenTime = OVERRIDE;
|
|
422
406
|
};
|
|
423
407
|
/** Cleanup the stream and connect */
|
|
424
|
-
#cleanupAndReconnect =
|
|
408
|
+
#cleanupAndReconnect = () => {
|
|
425
409
|
this.#streamCleanup();
|
|
426
|
-
await sleep(startSleep);
|
|
427
|
-
startSleep = Math.min(startSleep * 2, maxSleep);
|
|
428
410
|
void this.#watch();
|
|
429
411
|
};
|
|
430
412
|
/** Cleanup the stream and listeners. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,CAAC;AAGpB,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,oGAAoG;AACpG,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,CAAC;AAGpB,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,oGAAoG;AACpG,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,cAAc,YAAY,CAAC;AAG3B,OAAO,KAAK,MAAM,MAAM,gDAAgD,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export { fetch } from "./fetch.js";
|
|
|
10
10
|
// Export the HTTP status codes
|
|
11
11
|
export { StatusCodes as fetchStatus } from "http-status-codes";
|
|
12
12
|
// Export the Watch Config and Event types
|
|
13
|
-
// export { WatchCfg, WatchEvent, type DisposableWatcher } from "./fluent/watch.js";
|
|
14
13
|
export { WatchEvent } from "./fluent/watch.js";
|
|
15
14
|
// Export the fluent API entrypoint
|
|
16
15
|
export { K8s } from "./fluent/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kubernetes-fluent-client",
|
|
3
|
-
"version": "3.10.12-nightly.
|
|
3
|
+
"version": "3.10.12-nightly.9",
|
|
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,8 +72,8 @@
|
|
|
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.
|
|
76
|
-
"@typescript-eslint/parser": "8.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "8.53.0",
|
|
76
|
+
"@typescript-eslint/parser": "8.53.0",
|
|
77
77
|
"@vitest/coverage-v8": "^4.0.1",
|
|
78
78
|
"command-line-args": "^6.0.1",
|
|
79
79
|
"eslint-plugin-jsdoc": "62.0.0",
|
package/src/fetch.ts
CHANGED
|
@@ -32,14 +32,6 @@ export async function fetch<T>(
|
|
|
32
32
|
try {
|
|
33
33
|
const resp = await undiciFetch(url, init);
|
|
34
34
|
const contentType = resp.headers.get("content-type") || "";
|
|
35
|
-
console.log(
|
|
36
|
-
`FETCH_HEADERS: `,
|
|
37
|
-
JSON.stringify([...resp.headers]) +
|
|
38
|
-
"\nFETCH_URL: " +
|
|
39
|
-
url.toString() +
|
|
40
|
-
"\nFETCH_STATUS: " +
|
|
41
|
-
resp.status,
|
|
42
|
-
);
|
|
43
35
|
|
|
44
36
|
// Parse the response as JSON if the content type is JSON
|
|
45
37
|
if (contentType.includes("application/json")) {
|
package/src/fluent/watch.ts
CHANGED
|
@@ -14,10 +14,6 @@ import {
|
|
|
14
14
|
Filters,
|
|
15
15
|
FetchMethods,
|
|
16
16
|
} from "./shared-types.js";
|
|
17
|
-
|
|
18
|
-
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
|
19
|
-
let startSleep = 5000;
|
|
20
|
-
const maxSleep = 120000;
|
|
21
17
|
export enum WatchEvent {
|
|
22
18
|
/** Watch is connected successfully */
|
|
23
19
|
CONNECT = "connect",
|
|
@@ -146,10 +142,7 @@ export class Watcher<T extends GenericClass> {
|
|
|
146
142
|
);
|
|
147
143
|
|
|
148
144
|
// Rebuild the watch every resync delay interval
|
|
149
|
-
this.#resyncTimer = setInterval(
|
|
150
|
-
async () => await this.#checkResync(),
|
|
151
|
-
watchCfg.resyncDelaySec * 1000 + jitter,
|
|
152
|
-
);
|
|
145
|
+
this.#resyncTimer = setInterval(this.#checkResync, watchCfg.resyncDelaySec * 1000 + jitter);
|
|
153
146
|
|
|
154
147
|
// Bind class properties
|
|
155
148
|
this.#model = model;
|
|
@@ -253,10 +246,6 @@ export class Watcher<T extends GenericClass> {
|
|
|
253
246
|
|
|
254
247
|
// If the request fails, emit an error event and return
|
|
255
248
|
if (!response.ok) {
|
|
256
|
-
// Backoff here
|
|
257
|
-
await sleep(startSleep);
|
|
258
|
-
startSleep = Math.min(startSleep * 2, maxSleep);
|
|
259
|
-
await this.#list(continueToken, removedItems);
|
|
260
249
|
this.#events.emit(
|
|
261
250
|
WatchEvent.LIST_ERROR,
|
|
262
251
|
new Error(`list failed: ${response.status} ${response.statusText}`),
|
|
@@ -405,15 +394,6 @@ export class Watcher<T extends GenericClass> {
|
|
|
405
394
|
...opts,
|
|
406
395
|
});
|
|
407
396
|
|
|
408
|
-
console.log(
|
|
409
|
-
`WATCH_FETCH: `,
|
|
410
|
-
JSON.stringify([...response.headers]) +
|
|
411
|
-
"\nWATCH_URL: " +
|
|
412
|
-
serverUrl.toString() +
|
|
413
|
-
"\nWATCH_STATUS: " +
|
|
414
|
-
response.status,
|
|
415
|
-
);
|
|
416
|
-
|
|
417
397
|
const url = serverUrl instanceof URL ? serverUrl : new URL(serverUrl);
|
|
418
398
|
|
|
419
399
|
// If the request is successful, start listening for events
|
|
@@ -430,7 +410,6 @@ export class Watcher<T extends GenericClass> {
|
|
|
430
410
|
}
|
|
431
411
|
|
|
432
412
|
// Reset the retry count
|
|
433
|
-
startSleep = 5000;
|
|
434
413
|
this.#resyncFailureCount = 0;
|
|
435
414
|
this.#events.emit(WatchEvent.INC_RESYNC_FAILURE_COUNT, this.#resyncFailureCount);
|
|
436
415
|
|
|
@@ -453,23 +432,20 @@ export class Watcher<T extends GenericClass> {
|
|
|
453
432
|
}
|
|
454
433
|
});
|
|
455
434
|
|
|
456
|
-
this.#stream.on("close",
|
|
457
|
-
this.#stream.on("end",
|
|
435
|
+
this.#stream.on("close", this.#cleanupAndReconnect);
|
|
436
|
+
this.#stream.on("end", this.#cleanupAndReconnect);
|
|
458
437
|
this.#stream.on("error", this.#errHandler);
|
|
459
|
-
this.#stream.on("finish",
|
|
438
|
+
this.#stream.on("finish", this.#cleanupAndReconnect);
|
|
460
439
|
} else {
|
|
461
440
|
throw new Error(`watch connect failed: ${response.status} ${response.statusText}`);
|
|
462
441
|
}
|
|
463
442
|
} catch (e) {
|
|
464
|
-
// await sleep(startSleep);
|
|
465
|
-
// startSleep = Math.min(startSleep * 2, maxSleep);
|
|
466
|
-
console.log(`WATCH_ERROR: `, e);
|
|
467
443
|
void this.#errHandler(e);
|
|
468
444
|
}
|
|
469
445
|
};
|
|
470
446
|
|
|
471
447
|
/** Clear the resync timer and schedule a new one. */
|
|
472
|
-
#checkResync =
|
|
448
|
+
#checkResync = () => {
|
|
473
449
|
// Ignore if the last seen time is not set
|
|
474
450
|
if (this.#lastSeenTime === NONE) {
|
|
475
451
|
return;
|
|
@@ -497,7 +473,7 @@ export class Watcher<T extends GenericClass> {
|
|
|
497
473
|
} else {
|
|
498
474
|
this.#pendingReconnect = true;
|
|
499
475
|
this.#events.emit(WatchEvent.RECONNECT, this.#resyncFailureCount);
|
|
500
|
-
|
|
476
|
+
this.#cleanupAndReconnect();
|
|
501
477
|
}
|
|
502
478
|
} else {
|
|
503
479
|
// Otherwise, call the finally function if it exists
|
|
@@ -542,10 +518,8 @@ export class Watcher<T extends GenericClass> {
|
|
|
542
518
|
};
|
|
543
519
|
|
|
544
520
|
/** Cleanup the stream and connect */
|
|
545
|
-
#cleanupAndReconnect =
|
|
521
|
+
#cleanupAndReconnect = () => {
|
|
546
522
|
this.#streamCleanup();
|
|
547
|
-
await sleep(startSleep);
|
|
548
|
-
startSleep = Math.min(startSleep * 2, maxSleep);
|
|
549
523
|
void this.#watch();
|
|
550
524
|
};
|
|
551
525
|
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,6 @@ export { fetch } from "./fetch.js";
|
|
|
16
16
|
export { StatusCodes as fetchStatus } from "http-status-codes";
|
|
17
17
|
|
|
18
18
|
// Export the Watch Config and Event types
|
|
19
|
-
// export { WatchCfg, WatchEvent, type DisposableWatcher } from "./fluent/watch.js";
|
|
20
19
|
export { WatchCfg, WatchEvent } from "./fluent/watch.js";
|
|
21
20
|
|
|
22
21
|
// Export the fluent API entrypoint
|