Skip to content

Commit c1596ea

Browse files
committed
refactor imports in src
This commit uses import instead of require() in all cases, except when importing JSON files. It also removes a number of '* as' imports that appear to be unnecessary.
1 parent c1871c9 commit c1596ea

25 files changed

+54
-55
lines changed

src/attach.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import WebSocket = require('isomorphic-ws');
2-
import querystring = require('node:querystring');
3-
import stream = require('node:stream');
1+
import WebSocket from 'isomorphic-ws';
2+
import querystring from 'node:querystring';
3+
import stream from 'node:stream';
44

55
import { KubeConfig } from './config';
66
import { isResizable, ResizableStream, TerminalSizeQueue } from './terminal-size-queue';

src/attach_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'chai';
2-
import WebSocket = require('isomorphic-ws');
2+
import WebSocket from 'isomorphic-ws';
33
import { ReadableStreamBuffer, WritableStreamBuffer } from 'stream-buffers';
44
import { anyFunction, anything, capture, instance, mock, verify, when } from 'ts-mockito';
55

src/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import https = require('node:https');
1+
import https from 'node:https';
22

33
import { User } from './config_types';
4-
import WebSocket = require('isomorphic-ws');
4+
import WebSocket from 'isomorphic-ws';
55

66
export interface Authenticator {
77
isAuthProvider(user: User): boolean;

src/azure_auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as proc from 'node:child_process';
2-
import https = require('node:https');
3-
import * as jsonpath from 'jsonpath-plus';
1+
import proc from 'node:child_process';
2+
import https from 'node:https';
3+
import jsonpath from 'jsonpath-plus';
44

55
import { Authenticator } from './auth';
66
import { User } from './config_types';

src/cache_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, use } from 'chai';
2-
import chaiAsPromised = require('chai-as-promised');
2+
import chaiAsPromised from 'chai-as-promised';
33

4-
import * as mock from 'ts-mockito';
4+
import mock from 'ts-mockito';
55

66
import { V1ListMeta, V1Namespace, V1NamespaceList, V1ObjectMeta, V1Pod } from './api';
77
import { deleteItems, deleteObject, ListWatch } from './cache';
@@ -11,7 +11,7 @@ import { ListPromise } from './informer';
1111

1212
use(chaiAsPromised);
1313

14-
import nock = require('nock');
14+
import nock from 'nock';
1515
import { Watch } from './watch';
1616

1717
const server = 'http://foo.company.com';

src/config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import fs = require('node:fs');
2-
import https = require('node:https');
3-
import yaml = require('js-yaml');
4-
import net = require('node:net');
5-
import path = require('node:path');
1+
import fs from 'node:fs';
2+
import https from 'node:https';
3+
import yaml from 'js-yaml';
4+
import net from 'node:net';
5+
import path from 'node:path';
66

77
import { Headers, RequestInit } from 'node-fetch';
8-
import * as api from './api';
8+
import { RequestContext } from './api';
99
import { Authenticator } from './auth';
1010
import { AzureAuth } from './azure_auth';
1111
import {
@@ -31,8 +31,8 @@ import {
3131
ServerConfiguration,
3232
} from './gen';
3333
import { OpenIDConnectAuth } from './oidc_auth';
34-
import WebSocket = require('isomorphic-ws');
35-
import child_process = require('node:child_process');
34+
import WebSocket from 'isomorphic-ws';
35+
import child_process from 'node:child_process';
3636

3737
const SERVICEACCOUNT_ROOT: string = '/var/run/secrets/kubernetes.io/serviceaccount';
3838
const SERVICEACCOUNT_CA_PATH: string = SERVICEACCOUNT_ROOT + '/ca.crt';
@@ -212,7 +212,7 @@ export class KubeConfig implements SecurityAuthentication {
212212
* Applies SecurityAuthentication to RequestContext of an API Call from API Client
213213
* @param context
214214
*/
215-
public async applySecurityAuthentication(context: api.RequestContext): Promise<void> {
215+
public async applySecurityAuthentication(context: RequestContext): Promise<void> {
216216
const cluster = this.getCurrentCluster();
217217
const user = this.getCurrentUser();
218218

src/config_test.ts

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

66
import { expect, use } from 'chai';
77
import chaiAsPromised from 'chai-as-promised';
8-
import mockfs = require('mock-fs');
9-
import * as path from 'node:path';
8+
import mockfs from 'mock-fs';
109

1110
import { Headers } from 'node-fetch';
1211
import { HttpMethod } from '.';

src/config_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from 'node:fs';
1+
import fs from 'node:fs';
22

33
export enum ActionOnInvalid {
44
THROW = 'throw',

src/cp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as fs from 'node:fs';
1+
import fs from 'node:fs';
22
import { WritableStreamBuffer } from 'stream-buffers';
33
import * as tar from 'tar';
4-
import * as tmp from 'tmp-promise';
4+
import tmp from 'tmp-promise';
55

66
import { KubeConfig } from './config';
77
import { Exec } from './exec';

src/cp_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { anything, anyFunction, instance, mock, verify, when } from 'ts-mockito';
2-
import * as querystring from 'node:querystring';
3-
import WebSocket = require('isomorphic-ws');
2+
import querystring from 'node:querystring';
3+
import WebSocket from 'isomorphic-ws';
44

55
import { CallAwaiter } from '../test';
66
import { KubeConfig } from './config';

src/exec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import WebSocket = require('isomorphic-ws');
2-
import querystring = require('node:querystring');
3-
import stream = require('stream');
1+
import WebSocket from 'isomorphic-ws';
2+
import querystring from 'node:querystring';
3+
import stream from 'stream';
44

55
import { V1Status } from './api';
66
import { KubeConfig } from './config';

src/exec_auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { OutgoingHttpHeaders } from 'node:http';
2-
import https = require('node:https');
2+
import https from 'node:https';
33

44
import { Authenticator } from './auth';
55
import { User } from './config_types';
66

7-
import child_process = require('node:child_process');
7+
import child_process from 'node:child_process';
88

99
export interface CredentialStatus {
1010
readonly token: string;

src/exec_auth_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ExecAuth } from './exec_auth';
99
import { User } from './config_types';
1010
import { fail } from 'node:assert';
1111

12-
import child_process = require('node:child_process');
12+
import child_process from 'node:child_process';
1313

1414
describe('ExecAuth', () => {
1515
it('should claim correctly', () => {

src/file_auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs = require('node:fs');
2-
import https = require('node:https');
1+
import fs from 'node:fs';
2+
import https from 'node:https';
33

44
import { Authenticator } from './auth';
55
import { User } from './config_types';

src/gcp_auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as proc from 'node:child_process';
2-
import https = require('node:https');
3-
import * as jsonpath from 'jsonpath-plus';
1+
import proc from 'node:child_process';
2+
import https from 'node:https';
3+
import jsonpath from 'jsonpath-plus';
44

55
import { Authenticator } from './auth';
66
import { User } from './config_types';

src/integration_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, use } from 'chai';
2-
import chaiAsPromised = require('chai-as-promised');
3-
import nock = require('nock');
2+
import chaiAsPromised from 'chai-as-promised';
3+
import nock from 'nock';
44

55
import { CoreV1Api } from './api';
66
import { KubeConfig } from './config';

src/metrics_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fail } from 'node:assert';
22
import { expect } from 'chai';
3-
import nock = require('nock');
3+
import nock from 'nock';
44
import { KubeConfig } from './config';
55
import { V1Status, ApiException } from './gen';
66
import { Metrics, NodeMetricsList, PodMetricsList } from './metrics';

src/object_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fail } from 'node:assert';
22
import { expect } from 'chai';
3-
import nock = require('nock');
3+
import nock from 'nock';
44
import { Configuration, V1APIResource, V1APIResourceList, V1Secret } from './api';
55
import { KubeConfig } from './config';
66
import { KubernetesObjectApi } from './object';

src/portforward.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import WebSocket = require('isomorphic-ws');
2-
import querystring = require('node:querystring');
3-
import stream = require('node:stream');
1+
import WebSocket from 'isomorphic-ws';
2+
import querystring from 'node:querystring';
3+
import stream from 'node:stream';
44

55
import { KubeConfig } from './config';
66
import { WebSocketHandler, WebSocketInterface } from './web-socket-handler';

src/proto-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http = require('node:http');
1+
import http from 'node:http';
22

33
import { KubeConfig } from './config';
44

src/top_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'chai';
2-
import nock = require('nock');
2+
import nock from 'nock';
33
import { KubeConfig } from './config';
44
import { Metrics, PodMetricsList } from './metrics';
55
import { topPods } from './top';

src/watch_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'chai';
2-
import nock = require('nock');
2+
import nock from 'nock';
33
import { PassThrough } from 'node:stream';
44
import { KubeConfig } from './config';
55
import { Cluster, Context, User } from './config_types';

src/web-socket-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import WebSocket = require('isomorphic-ws');
2-
import stream = require('node:stream');
1+
import WebSocket from 'isomorphic-ws';
2+
import stream from 'node:stream';
33

44
import { V1Status } from './api';
55
import { KubeConfig } from './config';

src/web-socket-handler_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Readable } from 'node:stream';
22
import { setImmediate as setImmediatePromise } from 'node:timers/promises';
33
import { expect } from 'chai';
4-
import WebSocket = require('isomorphic-ws');
4+
import WebSocket from 'isomorphic-ws';
55
import { WritableStreamBuffer } from 'stream-buffers';
66

77
import { V1Status } from './api';

src/yaml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as yaml from 'js-yaml';
1+
import yaml from 'js-yaml';
22

33
export function loadYaml<T>(data: string, opts?: yaml.LoadOptions): T {
44
return yaml.load(data, opts) as any as T;

0 commit comments

Comments
 (0)