Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d7cfec6

Browse filesBrowse files
authored
Merge pull request #2359 from cjihrig/revert
Revert "begin migration to native fetch()"
2 parents b0a62db + 77380b8 commit d7cfec6
Copy full SHA for d7cfec6

13 files changed

+1199
-1112
lines changed

‎package-lock.json

Copy file name to clipboardExpand all lines: package-lock.json
+1,180-1,104Lines changed: 1180 additions & 1104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"eslint-plugin-erasable-syntax-only": "^0.3.0",
8484
"husky": "^9.0.6",
8585
"mock-fs": "^5.2.0",
86-
"nock": "^14.0.2",
86+
"nock": "^13.2.9",
8787
"prettier": "^3.0.0",
8888
"pretty-quick": "^4.0.0",
8989
"ts-mockito": "^2.3.1",

‎src/config.ts

Copy file name to clipboardExpand all lines: src/config.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import yaml from 'js-yaml';
44
import net from 'node:net';
55
import path from 'node:path';
66

7+
import { Headers, RequestInit } from 'node-fetch';
78
import { RequestContext } from './api.js';
89
import { Authenticator } from './auth.js';
910
import { AzureAuth } from './azure_auth.js';

‎src/config_test.ts

Copy file name to clipboardExpand all lines: src/config_test.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { fileURLToPath } from 'node:url';
1010
import mockfs from 'mock-fs';
1111

1212
import { Authenticator } from './auth.js';
13+
import { Headers } from 'node-fetch';
1314
import { HttpMethod } from './index.js';
1415
import { assertRequestAgentsEqual, assertRequestOptionsEqual } from './test/match-buffer.js';
1516
import { CoreV1Api, RequestContext } from './api.js';
@@ -294,7 +295,7 @@ describe('KubeConfig', () => {
294295
strictEqual(headers.get('list'), 'a, b');
295296
strictEqual(headers.get('number'), '5');
296297
strictEqual(headers.get('string'), 'str');
297-
assertRequestAgentsEqual((requestInit as any).agent as Agent, expectedAgent);
298+
assertRequestAgentsEqual(requestInit.agent as Agent, expectedAgent);
298299
});
299300
});
300301

‎src/health.ts

Copy file name to clipboardExpand all lines: src/health.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fetch from 'node-fetch';
12
import { KubeConfig } from './config.js';
23
import { RequestOptions } from 'node:https';
34

‎src/index.ts

Copy file name to clipboardExpand all lines: src/index.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ export * from './health.js';
1818
export * from './middleware.js';
1919
export * from './patch.js';
2020
export { type ConfigOptions, type User, type Cluster, type Context } from './config_types.js';
21+
22+
// Export FetchError so that instanceof checks in user code will definitely use the same instance
23+
export { FetchError } from 'node-fetch';

‎src/log.ts

Copy file name to clipboardExpand all lines: src/log.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Readable, Writable } from 'node:stream';
1+
import fetch from 'node-fetch';
2+
import { Writable } from 'node:stream';
23
import { ApiException } from './api.js';
34
import { KubeConfig } from './config.js';
45
import { V1Status } from './gen/index.js';
@@ -139,7 +140,7 @@ export class Log {
139140
const status = response.status;
140141
if (status === 200) {
141142
// TODO: the follow search param still has the stream close prematurely based on my testing
142-
Readable.fromWeb(response.body!).pipe(stream);
143+
response.body!.pipe(stream);
143144
} else if (status === 500) {
144145
const v1status = (await response.json()) as V1Status;
145146
const v1code = v1status.code;

‎src/metrics.ts

Copy file name to clipboardExpand all lines: src/metrics.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fetch from 'node-fetch';
12
import { KubeConfig } from './config.js';
23
import { ApiException, V1Status } from './gen/index.js';
34
import { normalizeResponseHeaders } from './util.js';

‎src/metrics_test.ts

Copy file name to clipboardExpand all lines: src/metrics_test.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('Metrics', () => {
149149
const metricsClient = new Metrics(kc);
150150
await rejects(metricsClient.getPodMetrics(), (err) => {
151151
ok(err instanceof ApiException);
152-
match(err.message, /Error occurred in metrics request: fetch failed/);
152+
match(err.message, /connect ECONNREFUSED 127.0.0.1:51011/);
153153
return true;
154154
});
155155
});

‎src/util.ts

Copy file name to clipboardExpand all lines: src/util.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Response } from 'node-fetch';
12
import { CoreV1Api, V1Container, V1Pod } from './gen/index.js';
23

34
export async function podsForNode(api: CoreV1Api, nodeName: string): Promise<V1Pod[]> {

‎src/util_test.ts

Copy file name to clipboardExpand all lines: src/util_test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it } from 'node:test';
22
import { deepStrictEqual, strictEqual, throws } from 'node:assert';
3+
import { Response } from 'node-fetch';
34
import { CoreV1Api, V1Container, V1Pod } from './api.js';
45
import {
56
normalizeResponseHeaders,

‎src/watch.ts

Copy file name to clipboardExpand all lines: src/watch.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { STATUS_CODES } from 'node:http';
22
import { createInterface } from 'node:readline';
3-
import { Readable } from 'node:stream';
3+
import fetch from 'node-fetch';
44
import { KubeConfig } from './config.js';
55

66
export class Watch {
@@ -55,7 +55,7 @@ export class Watch {
5555
const response = await fetch(watchURL, requestInit);
5656

5757
if (response.status === 200) {
58-
const body = Readable.fromWeb(response.body!);
58+
const body = response.body!;
5959

6060
body.on('error', doneCallOnce);
6161
body.on('close', () => doneCallOnce(null));

‎tsconfig.json

Copy file name to clipboardExpand all lines: tsconfig.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"forceConsistentCasingInFileNames": true,
1616
"importHelpers": true,
1717
"skipLibCheck": true,
18-
"esModuleInterop": true
18+
"esModuleInterop": true,
19+
"useDefineForClassFields": false
1920
// enable this in the future
2021
// "declarationMap": true
2122
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.