Skip to content

Commit 38ab1ca

Browse files
committed
fix: remove unused request dependency
1 parent 82c82bd commit 38ab1ca

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ export class KubeConfig implements SecurityAuthentication {
189189
agentOptions.passphrase = opts.passphrase;
190190
agentOptions.rejectUnauthorized = opts.rejectUnauthorized;
191191
agentOptions.timeout = opts.timeout;
192-
agentOptions.host = opts.host;
193-
agentOptions.path = opts.path;
194192
agentOptions.servername = opts.servername;
195193
agentOptions.ciphers = opts.ciphers;
196194
agentOptions.honorCipherOrder = opts.honorCipherOrder;
@@ -201,10 +199,6 @@ export class KubeConfig implements SecurityAuthentication {
201199
agentOptions.secureOptions = opts.secureOptions;
202200
agentOptions.secureProtocol = opts.secureProtocol;
203201
agentOptions.sessionIdContext = opts.sessionIdContext;
204-
// setting undefined will cause tls error
205-
if (opts.hasOwnProperty('port')) {
206-
agentOptions.port = typeof opts.port === 'string' ? parseInt(opts.port, 10) : opts.port;
207-
}
208202

209203
opts.agent = new https.Agent(agentOptions);
210204
}

src/config_test.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { readFileSync } from 'fs';
22
import * as https from 'https';
3+
import { Agent, RequestOptions } from 'https';
34
import { join } from 'path';
4-
import { RequestOptions, Agent } from 'https';
55

66
import { expect, use } from 'chai';
77
import chaiAsPromised from 'chai-as-promised';
88
import mockfs = require('mock-fs');
99
import * as path from 'path';
1010

11+
import { Headers } from 'node-fetch';
12+
import { HttpMethod } from '.';
13+
import { assertRequestAgentsEqual, assertRequestOptionsEqual } from '../test/match-buffer';
1114
import { CoreV1Api, RequestContext } from './api';
1215
import { bufferFromFileOrString, findHomeDir, findObject, KubeConfig, makeAbsolutePath } from './config';
13-
import { Cluster, newClusters, newContexts, newUsers, User, ActionOnInvalid } from './config_types';
16+
import { ActionOnInvalid, Cluster, newClusters, newContexts, newUsers, User } from './config_types';
1417
import { ExecAuth } from './exec_auth';
15-
import { HttpMethod } from '.';
16-
import { assertRequestOptionsEqual, assertRequestAgentsEqual } from '../test/match-buffer';
17-
import { Headers } from 'node-fetch';
1818

1919
const kcFileName = 'testdata/kubeconfig.yaml';
2020
const kc2FileName = 'testdata/kubeconfig-2.yaml';
@@ -264,16 +264,10 @@ describe('KubeConfig', () => {
264264
expect(requestInit.method).to.equal('POST');
265265
expect(requestInit.timeout).to.equal(5);
266266
expect((requestInit.headers as Headers).raw()).to.deep.equal({
267-
"list": [
268-
"a",
269-
"b",
270-
],
271-
"number": [
272-
"5",
273-
],
274-
"string": [
275-
"str",
276-
],
267+
Authorization: ['Basic Zm9vOmJhcg=='],
268+
list: ['a', 'b'],
269+
number: ['5'],
270+
string: ['str'],
277271
});
278272
assertRequestAgentsEqual(requestInit.agent as Agent, expectedAgent);
279273
});
@@ -316,7 +310,7 @@ describe('KubeConfig', () => {
316310
pfx: undefined,
317311
rejectUnauthorized: false,
318312
});
319-
let expectedOptions: https.RequestOptions = {
313+
const expectedOptions: https.RequestOptions = {
320314
auth: 'foo:bar',
321315
headers: {},
322316
rejectUnauthorized: false,
@@ -1180,10 +1174,10 @@ describe('KubeConfig', () => {
11801174
// TODO: inject the exec command here?
11811175
const opts = {} as RequestOptions;
11821176
await config.applytoHTTPSOptions(opts);
1183-
let execAuthenticator = (KubeConfig as any).authenticators.find(
1177+
const execAuthenticator = (KubeConfig as any).authenticators.find(
11841178
(authenticator) => authenticator instanceof ExecAuth,
11851179
);
1186-
expect(execAuthenticator.tokenCache['exec']).to.deep.equal(JSON.parse(responseStr));
1180+
expect(execAuthenticator.tokenCache.exec).to.deep.equal(JSON.parse(responseStr));
11871181
});
11881182

11891183
it('should throw with no command.', () => {
@@ -1273,7 +1267,7 @@ describe('KubeConfig', () => {
12731267
const kc = new KubeConfig();
12741268
kc.addCluster({
12751269
name: 'testCluster',
1276-
server: `https://localhost:9889`,
1270+
server: 'https://localhost:9889',
12771271
skipTLSVerify: true,
12781272
caFile: 'foo/bar.crt',
12791273
});
@@ -1509,7 +1503,7 @@ describe('KubeConfig', () => {
15091503
(kc as any).clusters = undefined;
15101504
kc.addCluster({
15111505
name: 'testCluster',
1512-
server: `https://localhost:9889`,
1506+
server: 'https://localhost:9889',
15131507
skipTLSVerify: true,
15141508
});
15151509
(kc as any).users = undefined;

0 commit comments

Comments
 (0)